Warning message during geometry creation

Need help, or want to share a macro? Post here!
drmacro
Posts: 3410
Joined: Sun Mar 02, 2014 4:35 pm

Warning message during geometry creation

Postby drmacro » Tue May 11, 2021 5:13 pm

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.
Star Trek II: The Wrath of Khan: Spock: "...His pattern indicates two-dimensional thinking."

My beginners, written treatise: Learning FreeCAD
User avatar
onekk
Posts: 965
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: Warning message during geometry creation

Postby onekk » 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.
Il mio Blog: https://onekk-maker.blogspot.com/

Introduzione a FreeCAD in Italiano: https://github.com/onekk/freecad-doc
drmacro
Posts: 3410
Joined: Sun Mar 02, 2014 4:35 pm

Re: Warning message during geometry creation

Postby drmacro » Tue May 11, 2021 5:43 pm

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 880 times
ArcSlotAtPoint-1.py
(10.69 KiB) Downloaded 22 times
Carlo3.py
(5.2 KiB) Downloaded 25 times
Star Trek II: The Wrath of Khan: Spock: "...His pattern indicates two-dimensional thinking."

My beginners, written treatise: Learning FreeCAD
User avatar
onekk
Posts: 965
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: Warning message during geometry creation

Postby onekk » 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.
Il mio Blog: https://onekk-maker.blogspot.com/

Introduzione a FreeCAD in Italiano: https://github.com/onekk/freecad-doc
drmacro
Posts: 3410
Joined: Sun Mar 02, 2014 4:35 pm

Re: Warning message during geometry creation

Postby drmacro » Wed May 12, 2021 10:04 am

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."

My beginners, written treatise: Learning FreeCAD
User avatar
onekk
Posts: 965
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: Warning message during geometry creation

Postby onekk » Wed May 12, 2021 10:22 am

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

Regards

Carlo D.
Il mio Blog: https://onekk-maker.blogspot.com/

Introduzione a FreeCAD in Italiano: https://github.com/onekk/freecad-doc
drmacro
Posts: 3410
Joined: Sun Mar 02, 2014 4:35 pm

Re: Warning message during geometry creation

Postby drmacro » Wed May 12, 2021 10:51 am

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."

My beginners, written treatise: Learning FreeCAD
User avatar
onekk
Posts: 965
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: Warning message during geometry creation

Postby onekk » Wed May 12, 2021 4:45 pm

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.
Il mio Blog: https://onekk-maker.blogspot.com/

Introduzione a FreeCAD in Italiano: https://github.com/onekk/freecad-doc
drmacro
Posts: 3410
Joined: Sun Mar 02, 2014 4:35 pm

Re: Warning message during geometry creation

Postby drmacro » Wed May 12, 2021 6:48 pm

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."

My beginners, written treatise: Learning FreeCAD
drmacro
Posts: 3410
Joined: Sun Mar 02, 2014 4:35 pm

Re: Warning message during geometry creation

Postby drmacro » Thu May 13, 2021 3:00 pm

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."

My beginners, written treatise: Learning FreeCAD