Problem with constraints based sketcher

Post here for help on using FreeCAD's graphical user interface (GUI).
Forum rules
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!
Hypercube3D
Posts: 1
Joined: Sun Aug 23, 2020 12:50 pm

Problem with constraints based sketcher

Postby Hypercube3D » Sun Aug 23, 2020 12:59 pm

It seems sketcher can't tell left from right (and top to bottom etc).

Attached is file where changing the spreadsheet value of square_width from 10 to 50 lets say leads to a completely different drawing.

The constraints can be redone to avoid this as a work around.
e.g. instead of making the outer border 1mm from inner border, it could be made 6mm from center for example.
But this failure of constraints needs addressing at some stage (probably).
Attachments
test_constraints.FCStd
(6.11 KiB) Downloaded 18 times
User avatar
Kunda1
Posts: 8772
Joined: Thu Jan 05, 2017 9:03 pm

Re: Problem with constraints based sketcher

Postby Kunda1 » Sun Aug 23, 2020 1:29 pm

Please post what version of FreeCAD you're using. See About.
Want to contribute back to FC? Checkout:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features
jmaustpc
Posts: 10382
Joined: Tue Jul 26, 2011 6:28 am
Location: Australia

Re: Problem with constraints based sketcher

Postby jmaustpc » Sun Aug 23, 2020 1:30 pm

Your first post, welcome to FreeCAD. :)
Hypercube3D wrote:
Sun Aug 23, 2020 12:59 pm
It seems sketcher
I moved this topic to this forum. Please read and follow the bug submission guide lines above.

Always include your FreeCAD version data in the manner explained in the forum rules link above, and test in the development version.

I have not yet looked at your file, but I think this might be another example of a known limitation, if so, your file may be useful for testing any related improvements in the future.
User avatar
papyblaise
Posts: 2679
Joined: Thu Jun 13, 2019 4:28 pm
Location: France

Re: Problem with constraints based sketcher

Postby papyblaise » Sun Aug 23, 2020 3:04 pm

it is a rare case where the direction of the constraint is not controlled, it is positive by default, and the negative is not valid
This does not seem to be possible to correct, except maybe in Australia where you walk with your feet to the ceiling :lol:
The only solution is to constraint from the axis OX or OY
jmaustpc
Posts: 10382
Joined: Tue Jul 26, 2011 6:28 am
Location: Australia

Re: Problem with constraints based sketcher

Postby jmaustpc » Sun Aug 23, 2020 4:01 pm

Although this is not the solution you wanted or expected, it is still technically a valid soliution. This issue shows up using the DogLeg and the BFGS solvers but not the LevenbergMarquardt solver.

Abdullah might be interested in this file for solver testing. I have sent him a message to find out.
Hypercube3D wrote:
Sun Aug 23, 2020 12:59 pm
The constraints can be redone to avoid this as a work around.
e.g. instead of making the outer border 1mm from inner border, it could be made 6mm from center for example.
Yes, there are several other ways you could constrain this and in this specific example you could have created this sketch more efficiently as well. For example since in this case both squares are centred on origin, you could have just applied the symmetry constraint between diagonally opposed corners and origin, that way this would also work with rectangles and you would have only needed on symmetry constraint on the outer square. You also don't need any of the construction lines if you simply used another symmetry constraint on diagonally opposed corners of the smaller square as well. Distance constraint can be applied between two points on the end of lines without a construction line.

Also to make a more robust sketch you could just use two horizontal distance constraints, one on an edge of each square, then you have defined the inner square so add the same expression that you did to read its value from the spreadsheet, but for the outer square just use an expression that reads the inner square value then adds twice the border distance value, the Expression would be "Spreadsheet.border_distance * 2 + Spreadsheet.square_width"




OS: Ubuntu 18.04.5 LTS (KDE/plasma)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.
Build type: Release
Branch: unknown
Hash: 1cad17c5f59883cf8f07855cecab350d93a25c30
Python version: 3.6.9
Qt version: 5.9.5
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/Australia (en_AU)
jmaustpc
Posts: 10382
Joined: Tue Jul 26, 2011 6:28 am
Location: Australia

Re: Problem with constraints based sketcher

Postby jmaustpc » Sun Aug 23, 2020 4:16 pm

jmaustpc wrote:
Sun Aug 23, 2020 4:01 pm
Expression would be "Spreadsheet.border_distance * 2 + Spreadsheet.square_width"
Just using that to define the lager square edge length solved the original issue even with using the DogLeg solver.
Screenshot_20200824_020450.png
Screenshot_20200824_020450.png (33.61 KiB) Viewed 601 times
However this is a more efficient way to model the same thing.
test_constraints2.FCStd
(11.03 KiB) Downloaded 14 times
Screenshot_20200824_021221.png
Screenshot_20200824_021221.png (9.91 KiB) Viewed 601 times
User avatar
Kunda1
Posts: 8772
Joined: Thu Jan 05, 2017 9:03 pm

Re: Problem with constraints based sketcher

Postby Kunda1 » Sun Aug 23, 2020 5:02 pm

jmaustpc wrote:
Sun Aug 23, 2020 4:01 pm
Abdullah might be interested in this file for solver testing. I have sent him a message to find out.
abdullah wrote: pinged by pinger macro
Want to contribute back to FC? Checkout:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features
abdullah
Posts: 3583
Joined: Sun May 04, 2014 3:16 pm

Re: Problem with constraints based sketcher

Postby abdullah » Tue Aug 25, 2020 2:57 am

jmaustpc wrote:
Sun Aug 23, 2020 4:01 pm
Although this is not the solution you wanted or expected, it is still technically a valid soliution. This issue shows up using the DogLeg and the BFGS solvers but not the LevenbergMarquardt solver.

Abdullah might be interested in this file for solver testing. I have sent him a message to find out.
Ok. Let's make a bug category (tag = "flipping" or "jumping" or "solver can tell right from left") in the bugtracker. This way it will be possible in the future to investigate and test improvements. :)
chrisb
Posts: 29060
Joined: Tue Mar 17, 2015 9:14 am

Re: Problem with constraints based sketcher

Postby chrisb » Tue Aug 25, 2020 6:00 am

I wouldn't create a new category, but we may add links to one of the existing tickets, e.g. issue #4279. They are all closed though, because flipping is not considered to be a bug.
A Sketcher Lecture with in-depth information is available in English, auf deutsch, en français, en español.
Smiling_user
Posts: 173
Joined: Tue Jul 28, 2020 7:31 am

Re: Problem with constraints based sketcher

Postby Smiling_user » Tue Aug 25, 2020 9:56 am

Have the same problem as mentioned in the head-post.
Faced this problem on Win/Lin 0.19_0pre from 2020.05 till now: after changing a value in spreadsheet, (or rarely in dd-object) - face a flip-direction in sketches and a2Plus assembles. Sometimes faced a complete break of a sketch if based on shape binder and/or external geometry..

The last time - faced today on
OS: Ubuntu 18.04.4 LTS (ubuntu:GNOME/ubuntu)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.
Build type: Release (#daily-ppa)
Branch: unknown
Hash: 0cf8279f00017ed2913e0c17beda77c733f98350
Python version: 3.6.9
Qt version: 5.9.5
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/UnitedStates (en_US)