Constrained Arcs Getting Screwy on Recalculations

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!
Post Reply
zardozer
Posts: 49
Joined: Sat Nov 07, 2020 2:35 am

Constrained Arcs Getting Screwy on Recalculations

Post by zardozer »

I've spent a couple hours trying to find out why my fairly simple design of a parametric retro joystick is getting screwed-up when recalculating dimensions, but only SOMETIMES and I'm not sure if it's something I'm doing wrong or if it's a bug.
Joystick Box.png
Joystick Box.png (496.67 KiB) Viewed 1085 times
To recreate this bug, go to the dynamic data table (just named 'dd'), and change Base Length to 250mm. Then change Base Width to 250mm. Finally, change Base Width to 100mm. The fully constrained sketch called 'Screw Posts' in the Bottom Box body gets messed-up, but I'm not sure why. If you change Base Length to 250mm, then directly change Base Width to 100mm, it seems to work. And many combinations of changing these parameters make the recalculation work fine. Here are the parameters:
Base Width.png
Base Width.png (96.31 KiB) Viewed 1085 times
Here's what the sketch of the screw posts looks like normally:
Screw Posts Normal.png
Screw Posts Normal.png (96.02 KiB) Viewed 1085 times
And here's what it looks like when the recalculations screw up:
Screw Posts Screwed.png
Screw Posts Screwed.png (74.99 KiB) Viewed 1085 times

It's just sometimes, for reasons I can't quite figure out, the calculations break when you change the parameters in a certain order. It seems maybe that the arcs get resolved differently sometimes and are still 'valid' according to constraints, but they're obviously messed-up. Hopefully, someone can shed some light on why. I've attached the project file.

I'm using the latest weekly, but I tried this in latest realthunder branch and it did the same thing, so it might be sketcher related.

OS: macOS 10.15
Word size of FreeCAD: 64-bit
Version: 0.20.25645 (Git)
Build type: Release
Branch: master
Hash: 37d9757399b4c2ec30318eb88d7cd7c508246345
Python version: 3.9.7
Qt version: 5.12.9
Coin version: 4.0.0
OCC version: 7.5.2
Locale: C/Default (C)
Attachments
Retro Joystick 2 Button_v4.FCStd
(684.99 KiB) Downloaded 30 times
User avatar
Shalmeneser
Veteran
Posts: 9475
Joined: Wed Dec 23, 2020 12:04 am
Location: Fr

Re: Constrained Arcs Getting Screwy on Recalculations

Post by Shalmeneser »

Sketch solver can do weird things when you really change a dimension.
Try to be gentle with your modifications, doing them gradually.
zardozer
Posts: 49
Joined: Sat Nov 07, 2020 2:35 am

Re: Constrained Arcs Getting Screwy on Recalculations

Post by zardozer »

Shalmeneser wrote: Sat Sep 18, 2021 9:05 pm Sketch solver can do weird things when you really change a dimension.
Try to be gentle with your modifications, doing them gradually.
But what do you mean by doing them gradually though? What I'm doing seems to be a pretty basic use of parametric modeling, where I'm changing width and length of the model. Granted, those width and length dimensions are used to calculate some other dimensions, to keep everything proper. But I don't think I'm doing anything really outlandish here. In fact, if you look at the sketch itself, it's very simple and only on dimension gets changed at a time. Add to this that it works in some cases, and then inexplicably the solver breaks... I'm trying to understand if it's a bug or if it has something to do with the way I'm constraining the sketch.
chrisb
Veteran
Posts: 53930
Joined: Tue Mar 17, 2015 9:14 am

Re: Constrained Arcs Getting Screwy on Recalculations

Post by chrisb »

The solver doesn't break: all constraints are still fulfilled. But there are several - different - solution to the set of constraints. "Changing gradually" means to change such values rather in multiple small steps than in a single big one.
There are some techniques to improve things, e.g. by using angle constraints or expressions.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
chrisb
Veteran
Posts: 53930
Joined: Tue Mar 17, 2015 9:14 am

Re: Constrained Arcs Getting Screwy on Recalculations

Post by chrisb »

In this case you could do something like this and calculate the vertical position of the big arc's center.
Attachments
RetroJoystick_cb.FCStd
(49.53 KiB) Downloaded 30 times
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
Post Reply