How to model offset constraints.

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
benngiro
Posts: 3
Joined: Wed Jul 27, 2016 8:07 pm

How to model offset constraints.

Post by benngiro »

Hi everybody,

I am new to using FreeCAD and so far I love it.
I installed it in order to model a cabinet. Since I didn't know the final dimensions yet, I made heavy use of the constraints. The problem I stumbled upon when I was done, was that when I tried to adjust the size, the parts didn't behave like I expected. While describing all that went wrong in this particular model would be too much, I want to demonstrate what my problem is with a smaller example (see attached file if you want to try for youselfes):

So lets assume I have a baseplate of a furniture piece with a variable width/depth and I want to place some feet such that they have some offset from the edges.
Here is what it would look like in the sketcher:
offset-test-start.png
offset-test-start.png (37.48 KiB) Viewed 2002 times
Now if I want to change the dimensions of the baseplate from 200mm to 100mm I would expect the result to look like this:
offset-test-expectation.png
offset-test-expectation.png (37.07 KiB) Viewed 2002 times
But instead it results in this:
offset-test-result.png
offset-test-result.png (40.45 KiB) Viewed 2002 times
Funny enough, if I change the size incrementally from 200 to 150 then 100 I get the correct result.
So after looking in the issue tracker i found a similar problem: http://www.freecadweb.org/tracker/view.php?id=1519.
Apparently, the solver can have multiple solutions and looking at my example I can also see why this is the case:
The distance constraint works in both directions.
Now my question is how then would I be able to model an offset like I wanted to do in this simple example and make sure the feet stay within the baseplate? Is there something like a directed distance modifier?

I would also like to know how the distance modifier is supposed to be working exactly. For example if I put negative offsets in the example above it will put the foot outside (to the left/top) of the plate as expected. So it seems the distance has some notion of direction and I would expect it to stay the same when changeing the size of the board. And if there is no direction then it doesn't seem to make sense to me why a negative distance would move the foot outside and how the sketch would be fully constraint then.

Hope somebody can give me some answer as to how I would achieve the offset constraints and maybe some insight into how the distance modifier is supposed to work.

Kind regards,

Ben

OS: Linux
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.16.Unknown
Build type: Release
Python version: 2.7.11
Qt version: 4.8.7
Coin version: 3.1.3
OCC version: 6.9.1
Attachments
offset-test.fcstd
(3.32 KiB) Downloaded 18 times
User avatar
salp
Posts: 250
Joined: Thu Nov 21, 2013 11:58 pm
Location: Putnam, NY

Re: How to model offset constraints.

Post by salp »

Ben,

Instead of relying on the solver you can force the parts to move as required by using construction lines.

I edited your sketch and replaced the offset dimensions to the edge of the platform with two construction lines and linked the length of these lines to the spreadsheet offset variable. Now you can edit the spreadsheet as you like.
original sketch
original sketch
Using_Dimensions.png (11.66 KiB) Viewed 1990 times
Modified sketch
Modified sketch
Using_Construction_Lines.png (12.21 KiB) Viewed 1990 times
OS: Ubuntu 16.04.1 LTS
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.16.6703 (Git)
Build type: None
Branch: releases/FreeCAD-0-16
Hash: 2ce5c8d2e3020d05005ed71f710e09e9aa561f40
Python version: 2.7.11+
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 6.8.0.oce-0.17
Attachments
offset-test_mod.fcstd
(6.58 KiB) Downloaded 20 times
jmaustpc
Veteran
Posts: 11207
Joined: Tue Jul 26, 2011 6:28 am
Location: Australia

Re: How to model offset constraints.

Post by jmaustpc »

benngiro wrote: Hope somebody can give me some answer as to how I would achieve the offset constraints
The order in which you first select the two points on which you will apply the distance constraint is important, in the sketcher's decision over where to place the geometry considering positive and negative direction. There has been subtle changes to this behaviour at different times in FreeCAD's development. Basically I think you have selected first a point on the small square then a point on the outer larger rectangle, the distance you are trying to set would in that case be "-10mm" but you are entering "+10mm", so the solver moves the point such that it is +10mm from the second selected point rather than -10mm.
benngiro
Posts: 3
Joined: Wed Jul 27, 2016 8:07 pm

Re: How to model offset constraints.

Post by benngiro »

Hi,

thanks a lot for the replies.
The order in which you first select the two points on which you will apply the distance constraint is important, in the sketcher's decision over where to place the geometry considering positive and negative direction
Yes I figured that out but as described, the direction might change if the new solution is "closer" to the original as described above.

Salp's answer was exactly what I was looking for and solves my problems. Although I still think the solver behaviour with the distances is unintuitive.

Thanks a lot,

Ben
User avatar
NormandC
Veteran
Posts: 18587
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: How to model offset constraints.

Post by NormandC »

Hi Ben,

You might find this of use: Sketcher_Tutorial
benngiro wrote:I still think the solver behaviour with the distances is unintuitive.
The tutorial goes over this. To be honest, it would be very difficult or impossible to program the sketcher solver to what amounts to guessing the end user's intent.

For my work, I use everyday a mature commercial CAD system (which has benefited from years of development by a full-time team), and its sketch solver can do unexpected things like that too.
benngiro
Posts: 3
Joined: Wed Jul 27, 2016 8:07 pm

Re: How to model offset constraints.

Post by benngiro »

Yes the tutorial explains the issue well and using the construction lines should provide a way to overcome this issue.
But I still have to figure out how I would exactly solve the problem with the offset.

After playing around a bit I realized that while salp's solution works for changing from a size of 200 to 100 it still results in the same thing when I scale it from 1000 to 50 (a bigger jump still gives unwanted results).
Adding more constraints (e.g. more construction lines) could easily solve it but then it's over constraint. So I still have to figure out a way to get this offset thing done with the right combination of constraints.

Kind regards,

Ben
Post Reply