Reference external construction geometry?

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!
brush701
Posts: 1
Joined: Fri Jun 14, 2019 3:30 pm

Reference external construction geometry?

Postby brush701 » Fri Jun 14, 2019 3:35 pm

Beginner question here, but I couldn't find the answer by googling: is there a way to reference construction geometry from one sketch in a different sketch? For example, I have a reference circle that is driving many of my design constraints across the whole part. I included it as construction geometry in the initial sketch, which then gets padded. In subsequent sketches I'd like to be able to use the circle to drive constraints and dimensions, but I can't figure out a way to make it visible or selectable. I'm coming from SolidWorks, where this is a standard workflow. Is the recommended workflow different in FreeCAD? Thanks!

OS: Windows 10
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.16117 (Git)
Build type: Release
Branch: releases/FreeCAD-0-18
Hash: dbb4cc6415bac848a294f03b80f65e888d531742
Python version: 3.6.6
Qt version: 5.6.2
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/UnitedStates (en_US)
openBrain
Posts: 1128
Joined: Fri Nov 09, 2018 5:38 pm

Re: Reference external construction geometry?

Postby openBrain » Fri Jun 14, 2019 5:53 pm

Hi Brush701, Welcome here !

Actually there are 2 different ways that could fit your need.

First is to use Sketcher External. This feature actually "copies" an edge of the existing geometry into your sketch. You can then reference this edge to build your new geometry. This is the closest way to SolidWorks, except you have to explicitly set the reference geometry in your sketch. Unfortunately, this feature is very sensitive to topological naming issue, and I would recommend the next way if it works for you.

The second way is to use Sketcher CarbonCopy to get a linked copy of your base sketch into your new sketch. You can then either keep the items as building geometry, or convert them to construction to only use them as reference. This method is immune to topological naming issue, but if you modify the shape of the base sketch it won't be reported on the linked one. ;)

In both cases, when you edit the new sketch, you eventually have to make previous part/sketch visible by going in the tree view, select it and press "Space". There are some options in FC preferences to choose if you want to automatically hide existing geometry or not when you edit a sketch. ;)

If you can attach your file in its current state, one can modify it to show you. ;)
Last edited by openBrain on Sat Jun 15, 2019 5:02 pm, edited 1 time in total.
chrisb
Posts: 15781
Joined: Tue Mar 17, 2015 9:14 am

Re: Reference external construction geometry?

Postby chrisb » Fri Jun 14, 2019 8:27 pm

brush701 wrote:
Fri Jun 14, 2019 3:35 pm
Is the recommended workflow different in FreeCAD? Thanks!
No, it's a good workflow; we call it the master sketch approach. If the master sketch does not lie in the current body you may have to import it via ShapeBinder.
jmaustpc
Posts: 9305
Joined: Tue Jul 26, 2011 6:28 am
Location: Australia

Re: Reference external construction geometry?

Postby jmaustpc » Sat Jun 15, 2019 1:52 am

Yet another way to get a similar result is to use an Expression, if you name a constraint in the first sketch then you can reference that via an expression in the constraint in the second sketch.

This is perhaps a better workflow or at least a far more powerful and flexible approach. It allows you to reference any value from anywhere, so you can store a value in a spreadsheet cell or any property of an object. It also allows you to apply maths to the value rather than just coping the original. For example, your first sketch may contain a circle that defines a pin diameter, your second sketch could have a square that is defined as having sides of a length equal to the circle diameter in the first sketch plus a either fix or proportional bit extra for a clearance value or similar.
User avatar
bejant
Posts: 5567
Joined: Thu Jul 11, 2013 3:06 pm

Re: Reference external construction geometry?

Postby bejant » Sat Jun 15, 2019 2:26 pm

openBrain wrote:
Fri Jun 14, 2019 5:53 pm
First is to use Sketcher external.
Try this one instead:
Sketcher_External (<== uppercase E in External)
openBrain
Posts: 1128
Joined: Fri Nov 09, 2018 5:38 pm

Re: Reference external construction geometry?

Postby openBrain » Sat Jun 15, 2019 5:03 pm

bejant wrote:
Sat Jun 15, 2019 2:26 pm
Sketcher_External (<== uppercase E in External)
Ouch. :oops: Looks like I was lazy on checking that time. Know that Wiki is all CamelCase. ;) Thanks for notifying. Fixed. :)
asdaf
Posts: 15
Joined: Sun Oct 21, 2018 8:35 pm

Re: Reference external construction geometry?

Postby asdaf » Sat Jun 15, 2019 5:49 pm

Hello jmaustpc,
jmaustpc wrote:
Sat Jun 15, 2019 1:52 am
Yet another way to get a similar result is to use an Expression, if you name a constraint in the first sketch then you can reference that via an expression in the constraint in the second sketch.
Could I bother you to post a file with example of that method?
-
regards,
asdaf
openBrain
Posts: 1128
Joined: Fri Nov 09, 2018 5:38 pm

Re: Reference external construction geometry?

Postby openBrain » Sat Jun 15, 2019 6:24 pm

asdaf wrote:
Sat Jun 15, 2019 5:49 pm
Could I bother you to post a file with example of that method?
According its location jmaustpc is probably at bed now. :lol:

You can find examples in the file "HackCase-OB2.FCStd" I posted in this post.
Sketch003 & Sketch004 both demonstrate 2 basic ways of using expressions : one calling a part property, and one calling a labeled sketch constraint (jmaustpc was talking about this latter). You can find them where dimension constraints are orange colored. ;)
jmaustpc
Posts: 9305
Joined: Tue Jul 26, 2011 6:28 am
Location: Australia

Re: Reference external construction geometry?

Postby jmaustpc » Sun Jun 16, 2019 4:07 am

openBrain wrote:
Sat Jun 15, 2019 6:24 pm
According its location jmaustpc is probably at bed now.
Yes, I was. It's early Sunday afternoon here now, and it's winter. :) I had a nice sleep in, my children cooked me a fancy breakfast in bed, but then I had to go out in the cold, fix the goats' water supply which had decided to leak, feed the cows and feed the calves their milk bottles, get a bit more fire wood, split some up and then load the fire up, now my kids are complaining that the house it too hot! They opened the door to let out some heat, they are dancing, inventing a dance that is about 50% ballet to pop-music. Australian hard wood is a great fuel, when your farm grows far more than you could ever burn its cheap, plentiful, renewable and not polluting, and if you load the fire up and turn the air down, it will burn for 10 hours over night or more. Good quality dry Aussie hard wood burns with very little smoke, and since there are only 4 houses within a kilometre in any direction from my house, no one would ever notice or care even if there was some smoke. Anyway, now I am getting some FreeCAD time! :)
asdaf wrote:
Sat Jun 15, 2019 5:49 pm
Could I bother you to post a file with example of that method?


I can if you need it but I think OpenBrain has fixed that. Honestly an Expression id a quick easy way to do this, much more flexible and powerful than just linking to geometry, but of course with that power comes the possibility of complexity. So once you have used it for simple things, it can be fun to start looking at just how complex you can make it.

have a look at the wiki page, its full of useful information, Expressions especially for now this part of the page Expressions#Reference_To_CAD-Data and the section immediately below it about global constants/spreadsheets.

In practice you have to name a constraint first to reference it in an expression, other wise it is too difficult to determine which constraint you want and referencing them by their number as given to them on creation is not reliable because this is simply their order of creation, and a constraint's number will, or can, change if others created earlier are deleted etc.

Another tip on constraint numbers, in Python the first one is not 1, it is 0, hence this can be confusing as people often think they want for example the 8th constraint so they have to know to call constraint 7 not constraint 8 which is in fact the 9th constraint since counting started at 0 not 1.

Jim
asdaf
Posts: 15
Joined: Sun Oct 21, 2018 8:35 pm

Re: Reference external construction geometry?

Postby asdaf » Sun Jun 16, 2019 3:03 pm

Hello,

There is no need to post another file. The one from OpenBrain was enough to get me started. Thank you, OpenBrain for posting it.

However, thank you for explanation about constraint names issues. I stumbled on that problem and was wondering if I had done something wrong. Perhaps it would be good to add that information to "Known issues / remaining tasks" section on Expressions wiki page?

And of course, thank you for that little tidbit about properties of Australian hard wood. One can learn truly amazing stuff on FreeCad forum.
-
regards,
asdaf