#6226 - Warning message during geometry creation

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
drmacro
Veteran
Posts: 8870
Joined: Sun Mar 02, 2014 4:35 pm

#6226 - Warning message during geometry creation

Post by drmacro »

When programmatically building geometry the following error is displayed, but, only with certain sets of valid input data.

Code: Select all

Updating geometry: Error build geometry(6): gp_Circ::SetRadius() - radius should be positive number
Invalid solution from DogLeg solver.
I get the obvious part about being a positive number. Sometimes it lists all three solvers and not just DogLeg.

But, the input doesn't generate any negative values that are being used as arguments.

And, the geometry is correct when the routine exits. And, the solver message in the Tasks pane says solved

It's a rather lengthy bit of code, and I'm pretty new at the FC/Python thing, I figured I'd ask if there is something obvious, before I attempt to make a stripped down version to exemplify the message.

Basically the code creates 4 arcs, 2 construction lines, and sets some constraints.
Last edited by Kunda1 on Sat Mar 19, 2022 11:03 am, edited 2 times in total.
Reason: Added GH ticket number to thread title
Star Trek II: The Wrath of Khan: Spock: "...His pattern indicates two-dimensional thinking."
User avatar
onekk
Veteran
Posts: 6146
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: Warning message during geometry creation

Post by onekk »

Without a some code, it is not possible to guess what is doing wrong.

As a first try you could simply add some print statement in "strategical places" and see what values are used.

Sometimes at a first glance there are no errors, but sometimes not, a 0.0 value due to floating point error could became "slightly negative" so maybe this is the reason to the error, but without a code to test, is hard to guess.

Regards

Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.

Blog: https://okkmkblog.wordpress.com/
drmacro
Veteran
Posts: 8870
Joined: Sun Mar 02, 2014 4:35 pm

Re: Warning message during geometry creation

Post by drmacro »

onekk wrote: Tue May 11, 2021 5:33 pm Without a some code, it is not possible to guess what is doing wrong.

As a first try you could simply add some print statement in "strategical places" and see what values are used.

Sometimes at a first glance there are no errors, but sometimes not, a 0.0 value due to floating point error could became "slightly negative" so maybe this is the reason to the error, but without a code to test, is hard to guess.

Regards

Carlo D.
I can stop the code in the debugger an look at any value I choose...as I said, there are no negative values...


I have attached the code. You'll note the dialog code will probably look somewhat familiar. 8-)

One set of data is radius=44, width =4, angle = 44 you need a sketch open with a vertex selected before executing the code.
Attachments
ArcSlot.png
ArcSlot.png (161.62 KiB) Viewed 2560 times
ArcSlotAtPoint-1.py
(10.69 KiB) Downloaded 52 times
Carlo3.py
(5.2 KiB) Downloaded 55 times
Star Trek II: The Wrath of Khan: Spock: "...His pattern indicates two-dimensional thinking."
User avatar
onekk
Veteran
Posts: 6146
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: Warning message during geometry creation

Post by onekk »

No need to stop debugger it suffice to do

Code: Select all

print("value label", value)
Poor man debugging ;-D

It is printed in report window and in terminal if you are running using a console terminal.

Now I'm on mobile so no code analysis is possible.

Regards

Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.

Blog: https://okkmkblog.wordpress.com/
drmacro
Veteran
Posts: 8870
Joined: Sun Mar 02, 2014 4:35 pm

Re: Warning message during geometry creation

Post by drmacro »

onekk wrote: Wed May 12, 2021 9:44 am No need to stop debugger it suffice to do

Code: Select all

print("value label", value)
Poor man debugging ;-D

It is printed in report window and in terminal if you are running using a console terminal.

Now I'm on mobile so no code analysis is possible.

Regards

Carlo D.
Unfortunately, when using debugger, that print message shows up after the script has completed. (you will also note plenty of print statements...already.)

In any case, as I've said there are no negative values to be seen. This a negative value that is produced by the solver during its execution, not the execution of my code. (I think... :? )
Star Trek II: The Wrath of Khan: Spock: "...His pattern indicates two-dimensional thinking."
User avatar
onekk
Veteran
Posts: 6146
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: Warning message during geometry creation

Post by onekk »

Ok as I don't use debugger other than the poor man print statements ones I didn't know this thing.

Regards

Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.

Blog: https://okkmkblog.wordpress.com/
drmacro
Veteran
Posts: 8870
Joined: Sun Mar 02, 2014 4:35 pm

Re: Warning message during geometry creation

Post by drmacro »

There may be a setting that allows the print statement to happen "real time" but I've not found it yet. :(
Star Trek II: The Wrath of Khan: Spock: "...His pattern indicates two-dimensional thinking."
User avatar
onekk
Veteran
Posts: 6146
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: Warning message during geometry creation

Post by onekk »

Some tought,

See in sources ,/Mod/Sketcher/SketcherExample.py

You will note that after applying a constraints, a document recompute, is done.

In your code this is lacking, maybe this could be a problem, as some geometry are not updated correctly without recomputing.

I suggesto to modify the code putting a recompute after the endarc1 add prior to adding costraints.

A simple example:

Code: Select all

	endarc1 = CurDoc.addGeometry(endarc1_geo)

	CurDoc.recompute()	

But there are other places.

as you are referring to endarc0 that is a "document object" that you have added, maybe the object is not "ready" to be readed when you refer to some of his property, putting a recompute, you force FreeCAD to "make all object properly closed" so a subsequent "property read" is assured to be correct.

It'a a guess, but maybe this will solve problems.

in the source code I've seen that sometimes costraints are nod added using addCostraints, but append a list and then assigning the list as a whole "costraints", try to see the code in


./Mod/Sketcher/TestSketcherApp.py

Maybe some other people more skilled than me could tell if I'm right or not, as I've never user Skectcher.

Hope it helps

Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.

Blog: https://okkmkblog.wordpress.com/
drmacro
Veteran
Posts: 8870
Joined: Sun Mar 02, 2014 4:35 pm

Re: Warning message during geometry creation

Post by drmacro »

Tried those suggestions.

Made the code a bit neater :) ...but, still gets the error. :cry:
Star Trek II: The Wrath of Khan: Spock: "...His pattern indicates two-dimensional thinking."
drmacro
Veteran
Posts: 8870
Joined: Sun Mar 02, 2014 4:35 pm

Re: Warning message during geometry creation

Post by drmacro »

Sorry for the direct ping, but I'm interested if you have any insight on this since it is a solver meassage?
abdullah wrote: pinged by pinger macro
Star Trek II: The Wrath of Khan: Spock: "...His pattern indicates two-dimensional thinking."
Post Reply