Face relative sketcher 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!
csetera
Posts: 55
Joined: Mon Nov 23, 2020 1:19 pm

Face relative sketcher constraints?

Post by csetera »

I'm probably not using the right search criteria, so I decided to try here.

If I'm applying a sketch to a face in a PartDesign, is there a way to refer to the underlying face for constraints? For example, is there a way to say "as wide as the underlying face" or "a vertical distance from the bottom edge of the face"? If these things are not possible, what is the best practice for setting up sketches relative to an underlying face?

Thanks,
Craig
freedman
Veteran
Posts: 3441
Joined: Thu Mar 22, 2018 3:02 am
Location: Washington State, USA

Re: Face relative sketcher constraints?

Post by freedman »

Search for "External geometry" and "Shapebinder".
TheMarkster
Veteran
Posts: 5505
Joined: Thu Apr 05, 2018 1:53 am

Re: Face relative sketcher constraints?

Post by TheMarkster »

You don't want to attach directly to a face due to the topological naming problem. The Face names are prone to change upon later revisions to your model, in which case the attached sketch tags along with the new name. For example, Face7 might become Face5. It is better to attach to a plane, such as xy plane, and offset with the attachment offset property to position the sketch. If the face is the top face of a Pad, then you can press = key in the z box and enter Pad.Length in the dialog that pops up. This way if you later change the Pad length the sketch will move with the new dimension.

You can also use expressions. For example, if the sketch used to make the first pad is a rectangle, then you could have a named constraint in it called width and maybe another called length. Then when positioning the next sketch you could refer to the contraints as the x,y, or z offset, such as = (popup dialog) Sketch.Constraints.width or maybe width/2 if you've centered the rectangle. Then if you later change that in the sketch the other sketch also moves with it. Name blue reference constraints can also be used in this manner if your sketch is fully constrained and there is no constraint to meet your needs already in it. It would be much simpler if we could just attach to faces, but due to a bug in the system this is not advisable at this time.

If you find a situation where you feel you must attach to a face, then at least try to see if there is a sketch edge to attach to instead. This will be more robust, although not fully robust. At least that way you are protected from changes to other sketches or to the generated geometry.
chrisb
Veteran
Posts: 53945
Joined: Tue Mar 17, 2015 9:14 am

Re: Face relative sketcher constraints?

Post by chrisb »

See topological naming problem and how to create stable models for more information on the named issues.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
csetera
Posts: 55
Joined: Mon Nov 23, 2020 1:19 pm

Re: Face relative sketcher constraints?

Post by csetera »

Thanks for the responses. It does help me better understand the underlying problems. Is there a way to name a line in a sketch that I could then refer to from another sketch? I tried it, but if it is possible I wasn't doing it right. (as in, I couldn't change the name of the line)
TheMarkster
Veteran
Posts: 5505
Joined: Thu Apr 05, 2018 1:53 am

Re: Face relative sketcher constraints?

Post by TheMarkster »

csetera wrote: Thu Oct 28, 2021 9:08 pm Thanks for the responses. It does help me better understand the underlying problems. Is there a way to name a line in a sketch that I could then refer to from another sketch? I tried it, but if it is possible I wasn't doing it right. (as in, I couldn't change the name of the line)
The line itself, no, not that I am aware of. You can toggle the constraint type to reference mode (constraints will be blue), give the reference constraint a name, and then reference that name from another sketch. You could, for example, measure the distance of a line from the origin using a reference constraint and then position the offset of your sketch based on that reference constraint. If the sketch is named Sketch002 and the reference constraint's name is line_width, then the reference to it would be:

Sketch002.Constraints.line_width
chrisb
Veteran
Posts: 53945
Joined: Tue Mar 17, 2015 9:14 am

Re: Face relative sketcher constraints?

Post by chrisb »

TheMarkster wrote: Fri Oct 29, 2021 1:08 am You can toggle the constraint type to reference mode (constraints will be blue), give the reference constraint a name, and then reference that name from another sketch. You could, for example, measure the distance of a line from the origin using a reference constraint and then position the offset of your sketch based on that reference constraint.
To add to this: if you check Preferences->Sketcher->Display->Show dimensional constraint namewith format %N=%V you will see the name in 3D view too.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
User avatar
Shalmeneser
Veteran
Posts: 9475
Joined: Wed Dec 23, 2020 12:04 am
Location: Fr

Re: Face relative sketcher constraints?

Post by Shalmeneser »

chrisb wrote: Fri Oct 29, 2021 6:32 am To add to this: if you check Preferences->Sketcher->Display->Show dimensional constraint namewith format %N=%V you will see the name in 3D view too.
In 0.20 !
chrisb
Veteran
Posts: 53945
Joined: Tue Mar 17, 2015 9:14 am

Re: Face relative sketcher constraints?

Post by chrisb »

Shalmeneser wrote: Fri Oct 29, 2021 7:52 am In 0.20 !
Oh yes, I forgot. Thanks for mentioning.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
steve123
Posts: 149
Joined: Fri Sep 04, 2015 8:58 pm

Re: Face relative sketcher constraints?

Post by steve123 »

TheMarkster wrote: Fri Oct 29, 2021 1:08 am The line itself, no, not that I am aware of. You can toggle the constraint type to reference mode (constraints will be blue), give the reference constraint a name, and then reference that name from another sketch. You could, for example, measure the distance of a line from the origin using a reference constraint and then position the offset of your sketch based on that reference constraint. If the sketch is named Sketch002 and the reference constraint's name is line_width, then the reference to it would be:

Sketch002.Constraints.line_width
Unfortunately, if you create a reference constraint you cannot use that constraint within the same sketch which seems to be an odd behaviour to me. I would expect to be able to use the reference within the same sketch? It would be useful if this issue could be fixed.
Attachments
Screen Shot 2022-05-23 at 8.05.04 AM.png
Screen Shot 2022-05-23 at 8.05.04 AM.png (47.78 KiB) Viewed 1004 times
Post Reply