Sketcher - Keeping shape features when applying a constraint

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!
nahshon
Posts: 225
Joined: Wed Jul 24, 2013 8:06 pm

Sketcher - Keeping shape features when applying a constraint

Post by nahshon »

I do not know if it's my usage error or a limitation of FreeCAD.

Here's a tiny example.
I built a basic shape (meant to be extruded to a slotted bar). After applying the width constraint the shape is deformed to kind of a staircase.



Image

slot-sketch.fcstd
(Sketch before applying width constraint)
(2.96 KiB) Downloaded 40 times
Tried with FreeCAD 0.14 git.

-- Itai
User avatar
ralvejd
Posts: 58
Joined: Wed Feb 20, 2013 10:31 pm
Location: Sweden

Re: Sketcher - Keeping shape features when applying a constraint

Post by ralvejd »

Hi
Move the width constraint

Image
sorry for my outrageous English, but I have a bad excuse
User avatar
NormandC
Veteran
Posts: 18589
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: Sketcher - Keeping shape features when applying a constraint

Post by NormandC »

nahshon wrote:I do not know if it's my usage error or a limitation of FreeCAD.
Probably the solver acting up, I get the same result on FreeCAD 0.13.1828 on Windows 7.

If you drag the right corner of your rectangle nearer to the intended dimension before applying it, then the slot does not switch direction when you input 30mm.
logari81
Posts: 658
Joined: Mon Jun 14, 2010 6:00 pm

Re: Sketcher - Keeping shape features when applying a constraint

Post by logari81 »

this in an acknowledged issue there is a bug report about sketches with multiple solutions. Not so easy to solve. Changing the datum value in small steps from its original value is a workaround.
wmayer
Founder
Posts: 20245
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Sketcher - Keeping shape features when applying a constraint

Post by wmayer »

IMO the self-diagnosis function of the sketcher is wrong. If you open the sketch it says that it has 1 degree of freedom. But look at all the parallel constraints, they are all totally unnecessary because if you already say that two lines must be vertical then a parallelism between them is automatically achieved. The self-diagnosis tool, however, subtracts these three unneeded constraints from the actual degrees of freedom and thus you cannot set the really required constraints any more.

So, delete the three parallel constraints and you are fine. You have to set three further length constraints 1x30mm and 2x10mm.
logari81
Posts: 658
Joined: Mon Jun 14, 2010 6:00 pm

Re: Sketcher - Keeping shape features when applying a constraint

Post by logari81 »

@wmayer, no the self-diagnostics of the sketcher are slow but quite reliable, there are no parallel constraints, they are equal length constraints.
User avatar
bejant
Veteran
Posts: 6075
Joined: Thu Jul 11, 2013 3:06 pm

Re: Sketcher - Keeping shape features when applying a constraint

Post by bejant »

The order in which you apply Constraints matters. First you need to apply the Equality Constraint to the top and bottom lines, then apply a Length Constraint to one of these lines, otherwise the stairstep shape is a valid solution to your sketch given the applied Constraints.

This solves your problem but when I add a length constraint to the top horizontal line (or the bottom horizontal line) FreeCAD says the sketch is fully constrained. I think this is behavior is wrong because:

1. Given only the original constraints a stairstep sketch (where the bottom horizontal line is longer than the top line) IS a valid solution (until we tell FreeCAD that the top and bottom lines are equal length by applying the Equality Constraint).

2. Similarly given only the original constraints a kind of upside-down stairstep sketch (where the top horizontal line is longer than the bottom line) is also a valid solution, again until we apply the Equality Constraint to the top and bottom lines.

3. Given only the original constraints another valid solution exists where instead of a notch on the right of the sketch there would be a square ridge protruding there. The three vertical lines on the right are still equal lengths by Equality Constraints 17 and 18, and the two horizontal lines on the right are still the same length by Equality Constraint 19.

Comments?
Last edited by bejant on Sat Aug 31, 2013 4:59 pm, edited 1 time in total.
triplus
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Re: Sketcher - Keeping shape features when applying a constraint

Post by triplus »

I would not say it's a limitation because it's usually fixable with changing the constraint value or to set constraints a bit differently. Undo is your friend here to go back one step and try to rethink the situation. I experience this every now and then when doing sketches but never was in situation i couldn't fix it with few mouse clicks:

viewtopic.php?f=3&t=4300

If it's a bug? Developers would probably need to rethink how to get more predictable results in this situations but probably easier said then done.
nahshon
Posts: 225
Joined: Wed Jul 24, 2013 8:06 pm

Re: Sketcher - Keeping shape features when applying a constraint

Post by nahshon »

Thanks for all the answers!
I am looking at a wider problem - what's required in order to be able to achieve tru-parametric design.

As a case study I have made this little box (design with FreeCAD to production on a CNC router):
Image

I would like to be able to assign external values to constraints (Width, Length, Hight, Material thickness etc...). Sketches should get resolved when an external value is changed.

Apparently the sketch resolver is not quite ready for that.

-- Itai
triplus
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Re: Sketcher - Keeping shape features when applying a constraint

Post by triplus »

Apparently the sketch resolver is not quite ready for that.
If that would not be achievable i would agree but as i said sometimes you just have to rethink how to place constraints or to test how constraint behave when changing value and what "resets it" to the correct position/design. I usually increase/decrease value of troublesome constraint substantially to see what is happening on the screen and how to get to the right result.
I would like to be able to assign external values to constraints (Width, Length, Hight, Material thickness etc...).
I am not sure if this is possible ATM to control individual constraint inside sketcher from external reference. I was thinking about this when spreadsheet landed and i saw potential for exactly this use case scenarios. For now you will probably have to create individual sketch and control everything from the sketch itself. This would probably work OK for your example.
Post Reply