[SOLVED] Sketch constraint flips direction

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
Artem_Zh
Posts: 20
Joined: Thu Oct 05, 2017 1:27 pm

[SOLVED] Sketch constraint flips direction

Post by Artem_Zh »

Hello I have a red color sketch and blue sketch which depends on red. Once I move to the right the red sketch, the blue one flips its direction. I don't want that. Pictures:
Image
Image
Image
Image

By the way, I found, if I make an angle constraint (90deg) instead of perpendicular, it seems the problem solved. But then, why?
Last edited by Artem_Zh on Tue Oct 10, 2017 6:09 am, edited 1 time in total.
chrisb
Veteran
Posts: 53922
Joined: Tue Mar 17, 2015 9:14 am

Re: Sketch constraint flips direction

Post by chrisb »

Both versions, the flipped one and the not flipped, satisfy the constraints you gave. It is sometimes irritating that the solver does in this case not show degrees of freedom and the sketch is green and fully constraint and yet there are several different solutions.
The solver can only detect an infinite number of different solutions. As soon as there is only a finite number it is marked as solved. You found the solution yourself: Use constraints that make the solution a unique one.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
triplus
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Re: Sketch constraint flips direction

Post by triplus »

I am not 100% sure but based on your description i feel you are talking about geometry flip occurring when you change the constraint value manually while in the Sketcher edit mode?

Edit -> Preferences ... -> Sketcher -> Enable Show advanced Solver Control in the Task bar

After you will enter the Sketcher edit mode the next time look in the sidebar and under Advanced solver control change the solver from default DogLeg to LevenbergMarquardt.

P.S. Complete the test again to see if the mentioned issue will still occur.
Artem_Zh
Posts: 20
Joined: Thu Oct 05, 2017 1:27 pm

Re: [SOLVED] Sketch constraint flips direction

Post by Artem_Zh »

triplus wrote: Mon Oct 09, 2017 9:56 pm I am not 100% sure but based on your description i feel you are talking about geometry flip occurring when you change the constraint value manually while in the Sketcher edit mode?

Edit -> Preferences ... -> Sketcher -> Enable Show advanced Solver Control in the Task bar

After you will enter the Sketcher edit mode the next time look in the sidebar and under Advanced solver control change the solver from default DogLeg to LevenbergMarquardt.

P.S. Complete the test again to see if the mentioned issue will still occur.
I tested your solution, it works as well. As far as I understood, LevenbergMarquardt is more reliable solver, but could you provide some good practices, when do we need to use LevenbergMarquardt or DogLeg? Should we still use angle constraint against Perpendicular?
triplus
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Re: [SOLVED] Sketch constraint flips direction

Post by triplus »

Artem_Zh wrote: Tue Oct 10, 2017 6:11 am I tested your solution, it works as well.
Good to hear that.
As far as I understood, LevenbergMarquardt is more reliable solver, but could you provide some good practices, when do we need to use LevenbergMarquardt or DogLeg? Should we still use angle constraint against Perpendicular?
It was discovered a while back LevenbergMarquardt solver doesn't have the "flip issue".

https://forum.freecadweb.org/viewtopic. ... =30#p92119

And i didn't find any issues compared to DogLeg solver. Therefore it should be safe to always use LevenbergMarquardt solver to avoid the "flip issue". I am assuming there is some bug or something is missing in DogLeg solver implementation. That would address the "flip issue". But we are a bit short on developers having enough knowledge and determination to tackle this ATM.

P.S. Note that unfortunately when using expressions (this is just assumption) DogLeg solver is always being used. Therefore you can't avoid the "flip issue" ATM when using expressions.
Artem_Zh
Posts: 20
Joined: Thu Oct 05, 2017 1:27 pm

Re: [SOLVED] Sketch constraint flips direction

Post by Artem_Zh »

Understood.

Thank you
User avatar
flachyjoe
Veteran
Posts: 1869
Joined: Sat Mar 31, 2012 12:00 pm
Location: Limoges, France

Re: Sketch constraint flips direction

Post by flachyjoe »

triplus wrote: Tue Oct 10, 2017 11:58 am P.S. Note that unfortunately when using expressions (this is just assumption) DogLeg solver is always being used. Therefore you can't avoid the "flip issue" ATM when using expressions.
What's new about this :?:
- Flachy Joe -
Image
Post Reply