It happened several times to me now that points or lines switched places when changing constraints in a sketch.
Check this starting sketch, especially the horizontal constraint of 20mm:
If I change it to 60mm, the shape is the same, except being longer (as expected):
But if I change the constraint to 70mm (from 20mm only; it does not do that when going from 60mm), the two right vertical lines "switch" sides:
This is a simple sketch, the "problem" is easily visible and there are other ways this sketch could be constrained that would most likely not lead to the "switch". But with more complicated sketches, especially when using parameters from a spreadsheet or referencing constraints of another sketch, it's much worse, because then things go wrong somewhere and you don't even notice it until it's way too late (e. g. when a part is not visible currently, because you work on something else). Quite often even changing back to the original constraint doesn't revert all the "switches" that happened. Pretty much the only hope at that point is that I didn't save my model and make the changes "permanent".
I know that there will often be multiple "solutions" for the constraints given in a sketch, but unfortunately it is not obvious while drawing a sketch where they can hit you. What is the best way to avoid something like this happening? Would it be possible to create constraints (or more like hints for the solver) like "this line should be longer than that line" or "this point should always be left of that point" or similar?
Points/lines flip in sketch when changing constraint
Forum rules
and Helpful information
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help
Also, be nice to others! Read the FreeCAD code of conduct!
Also, be nice to others! Read the FreeCAD code of conduct!
Re: Points/lines flip in sketch when changing constraint
Flipping sketch is a known inconvenience. IIRC in @chrisb 's' Sketcher Lecture', there is a chapter about it and how to deal with this.
-
- Veteran
- Posts: 5513
- Joined: Thu Apr 05, 2018 1:53 am
Re: Points/lines flip in sketch when changing constraint
You can employ if then else logic within the formula editor. For example, here I want the rectangle width to always be the shorter of the 2 variables: width and length, and the length to always be the longer.
There is a similar formula for the length constraint.
Such a construction might also work as a way to mitigate the flipping issue, but I haven't tried it for that.
There is a similar formula for the length constraint.
Such a construction might also work as a way to mitigate the flipping issue, but I haven't tried it for that.
Re: Points/lines flip in sketch when changing constraint
What's in there is pretty much what I'm doing .
As I was wondering in the previous post: would it be possible to implement "hints" for the solver, as in which solution to pick if there are multiple?
Re: Points/lines flip in sketch when changing constraint
I think, the hints should come from your constraint scheme...and, that, unfortunately, comes from experience of what works and fails.
The problem, I "think", the issue is the solver knows little, if anything, about geometry, it just blindly solves equations.
Maybe @abdullah could comment on the possibilities.
Star Trek II: The Wrath of Khan: Spock: "...His pattern indicates two-dimensional thinking."