Master Sketch Best Practice

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!
fusan
Posts: 28
Joined: Wed Nov 30, 2016 9:03 pm

Master Sketch Best Practice

Postby fusan » Thu May 31, 2018 11:24 pm

Hi all

I have searched for Master Sketch on the forum, but didn't find any great info about it.
What I imagine is that a Master Sketch is used as a base-sketch and the new sketches that have the same curves/form/dimensions, are somehow
linked/referenced to it. So you don't have to create the new sketches from scratch every time. I could be totaly wrong in my assumption, so what I
to know is how does it work? Are the new sketches linked/referenced to the Master Sketch? If so, how are they linked/referenced.
chrisb
Posts: 19589
Joined: Tue Mar 17, 2015 9:14 am

Re: Master Sketch Best Practice

Postby chrisb » Thu May 31, 2018 11:29 pm

fusan wrote:
Thu May 31, 2018 11:24 pm
Are the new sketches linked/referenced to the Master Sketch? If so, how are they linked/referenced.
You are right with your assumptions about the idea of a master sketch. Referencing them works like other references in Sketcher with Sketcher External.

You should work through some tutorials covering Sketcher to learn about the basic editing funtions.
User avatar
ppemawm
Posts: 558
Joined: Fri May 17, 2013 3:54 pm
Location: Manhattan New York

Re: Master Sketch Best Practice

Postby ppemawm » Fri Jun 01, 2018 12:45 am

fusan wrote:
Thu May 31, 2018 11:24 pm
I have searched for Master Sketch on the forum, but didn't find any great info about it.
Examples:
https://forum.freecadweb.org/viewtopic. ... 00#p227968
https://forum.freecadweb.org/viewtopic. ... 91#p232277
https://forum.freecadweb.org/viewtopic. ... 04#p217871

A master sketch(es) should be as simple as possible in order to capture the key design intent. Once you reference a master sketch using External Reference in another sketch or link to it via a Shapebinder in another body by sketch Attachment properties, you usually cannot make any significant changes (add or subtract vertices or edges) to the master or it may break the model. Using master sketches requires that you think through how you will create the model before you start.
"It is a poor workman who blames his tools..." ;)
fusan
Posts: 28
Joined: Wed Nov 30, 2016 9:03 pm

Re: Master Sketch Best Practice

Postby fusan » Fri Jun 01, 2018 7:43 pm

ppemawm wrote:
Fri Jun 01, 2018 12:45 am
fusan wrote:
Thu May 31, 2018 11:24 pm
I have searched for Master Sketch on the forum, but didn't find any great info about it.
Examples:
https://forum.freecadweb.org/viewtopic. ... 00#p227968
https://forum.freecadweb.org/viewtopic. ... 91#p232277
https://forum.freecadweb.org/viewtopic. ... 04#p217871

A master sketch(es) should be as simple as possible in order to capture the key design intent. Once you reference a master sketch using External Reference in another sketch or link to it via a Shapebinder in another body by sketch Attachment properties, you usually cannot make any significant changes (add or subtract vertices or edges) to the master or it may break the model. Using master sketches requires that you think through how you will create the model before you start.
First, Thanks for the answer. The first link was very informative.
Since the idea with a master sketch is to reference other sketches to it to make them easier to create, I don't get why it is so inflexible.
To me it would be a great to only change the master sketch and all sketches referenced to it would update to.
Maybe I'm missing something here.
dbecad
Posts: 80
Joined: Fri Mar 16, 2018 11:10 pm

Re: Master Sketch Best Practice

Postby dbecad » Fri Jun 01, 2018 8:51 pm

Fusan,
fusan wrote:
Fri Jun 01, 2018 7:43 pm
Since the idea with a master sketch is to reference other sketches to it to make them easier to create, I don't get why it is so inflexible.
To me it would be a great to only change the master sketch and all sketches referenced to it would update to.
Maybe I'm missing something here.
The restrictions are usually the result of the tree relationship between the different objects. And I don't pretend to understand the bowels of FC in details anyway. That said looking at the external tool restrictions:
Only edges and vertices from objects from same coordinate system are allowed.
That is, the sketch and the object must be in same Body, or in same Part, or both outside of any Parts and Bodies.
I wondered if I could "clone" an external sketch and put the sketch inside multiple bodies to use it with external and it works :)

Process:
- Created master sketch (master)
- Then a partDesign body
- Clone the sketch (masterClone) with the "sheep tool"
- Drag the clone in the body, it creates a BaseFeature
- Then I can use external tool to "copy" the BaseFeature geometry
The result dependency tree seems to be clean, and modifying the master sketch shape changes of all the linked clone/baseFeatures 8-)

The only thing I don't understand is what is a "basefeature", and why we cannot just put the clone of the sketch in the body directly. Or alternatively can we just create a basefeature out of the master sketch without the clone?

So, If some of the power users could chime to comment on that solution (pro/cons) i'd really appreciate. Thanks!

This solution seems interesting because the baseFeature is linked to the body coordinate system and does not care about the original position of the master sketch/clone so you should have a fine granularity to choose the best location of your base features.

Cheers
masterSketch.png
masterSketch.png (63.87 KiB) Viewed 1821 times
Attachments
masterSketch.FCStd
(26.69 KiB) Downloaded 19 times
chrisb
Posts: 19589
Joined: Tue Mar 17, 2015 9:14 am

Re: Master Sketch Best Practice

Postby chrisb » Fri Jun 01, 2018 9:24 pm

dbecad wrote:
Fri Jun 01, 2018 8:51 pm
I wondered if I could "clone" an external sketch and put the sketch inside multiple bodies to use it with external and it works :)
You don't use the clone, you use a ShapeBinder instead. It is kind of a proxy for the original element.
User avatar
ppemawm
Posts: 558
Joined: Fri May 17, 2013 3:54 pm
Location: Manhattan New York

Re: Master Sketch Best Practice

Postby ppemawm » Fri Jun 01, 2018 9:50 pm

fusan wrote:
Fri Jun 01, 2018 7:43 pm
I don't get why it is so inflexible.
To me it would be a great to only change the master sketch and all sketches referenced to it would update to.
It is quite flexible and any sketch linked to it will update changes. But, you generally cannot change the number of elements in the master sketch once it is linked or it may break the model. You can change dimensions and constraints, however, and the linked sketches will update.
dbecad wrote:
Fri Jun 01, 2018 8:51 pm
- Clone the sketch (masterClone) with the "sheep tool"
- Drag the clone in the body, it creates a BaseFeature
I use a Shapebinder rather than a Clone. A BaseFeature is intended to be used with solids from other workbenches for the beginning feature of a PartDesign>Body.

For example, you can make a master sketch of all the key vertices of the moving parts in an engine. Then, as you begin modelling each moving body, create a Shapebinder of the master sketch for reference in each body. Attach sketches to the Shapebinder at the appropriate location using the MapMode to create the Body. You can use external geometry links in the sketch if needed. Once the body is completed you can go back to the master sketch and change the main variable, such as the crankshaft angle, and all of the bodies will move to their new location. This is useful for animating and checking clearances or interferences in the engine as the crankshaft rotates.

I can post an example file if there is any further interest in this approach.
"It is a poor workman who blames his tools..." ;)
chrisb
Posts: 19589
Joined: Tue Mar 17, 2015 9:14 am

Re: Master Sketch Best Practice

Postby chrisb » Fri Jun 01, 2018 10:23 pm

ppemawm wrote:
Fri Jun 01, 2018 9:50 pm
It is quite flexible and any sketch linked to it will update changes. But, you generally cannot change the number of elements in the master sketch once it is linked or it may break the model. You can change dimensions and constraints, however, and the linked sketches will update.
And even if the model breaks, because you had to add something to the structure, it seems to be easier to repair than a model attached to faces and referencing edges and vertices; probably because it stays 2D and the references or attachment faces don't hide in the smalles corners of a 3D object.
dbecad
Posts: 80
Joined: Fri Mar 16, 2018 11:10 pm

Re: Master Sketch Best Practice

Postby dbecad » Sat Jun 02, 2018 12:23 am

ppemawm wrote:
Fri Jun 01, 2018 9:50 pm
For example, you can make a master sketch of all the key vertices of the moving parts in an engine. Then, as you begin modelling each moving body, create a Shapebinder of the master sketch for reference in each body. Attach sketches to the Shapebinder at the appropriate location using the MapMode to create the Body. You can use external geometry links in the sketch if needed. Once the body is completed you can go back to the master sketch and change the main variable, such as the crankshaft angle, and all of the bodies will move to their new location. This is useful for animating and checking clearances or interferences in the engine as the crankshaft rotates.
Thanks ppemawm for the clear explanations, looking at your screen captures on your amazing models was not obvious how the shape-binders would be used. I've redone the same example using shape-binders (joined).

However, I see 2 usages for the master-sketch concept:
- positioning (like your shaft mechanical movement)
- shared geometry between bodies

Right now if I use a single master sketch, for both usages then that means, the body geometries are going to be recomputed at each step of the crank which seems sub-obtimal.

I assume it would be better to somehow split both aspects:
1/ Use "geometry master sketch" that can be used in different bodies/parts through shape-binders
2/ Have a "skeleton master sketch" that defines position/angle of parts, so that changing the crank angle only changes the placements of parts and does not trigger a geometry recompute
I'm not sure what is the best way to achieve that, unless I'm completely on the wrong track :roll:

My current quest is to design a simple mechanical watch movement and I'm not completely satisfied with my current way of modeling gear trains, where the distance between shafts and positions of said shaft should be parametric. Also animating it after would be a nice plus...

On a side note (trying not to hijack thread), do you have a link on how to check interference?
Is it mostly visual, or you use some kind of animation script to move the crank in small increment and do some kind of boolean operation to make sure the intersection is void? I assume this could be automatized somehow.

Cheers
Attachments
masterSketch2.FCStd
(25.92 KiB) Downloaded 22 times
User avatar
ppemawm
Posts: 558
Joined: Fri May 17, 2013 3:54 pm
Location: Manhattan New York

Re: Master Sketch Best Practice

Postby ppemawm » Sat Jun 02, 2018 1:31 am

dbecad wrote:
Sat Jun 02, 2018 12:23 am
Right now if I use a single master sketch, for both usages then that means, the body geometries are going to be recomputed at each step of the crank which seems sub-obtimal.
I use a skeleton sketch as the master for location only. The body sketches are attached to a shapebinder of the master to create the detail geometry. If that is suboptimal and means a second or two greater compute time that's OK with me. I am bit old school greybeard that promotes keeping it simple.
dbecad wrote:
Sat Jun 02, 2018 12:23 am
do you have a link on how to check interference?
Is it mostly visual, or you use some kind of animation script to move the crank in small increment
No, yes, yes. I have a simple macro to move the master sketch variable angle 0-360 deg to check the robustness of the constraints and for interference checks or I simply change the angle constraint manually in the Property panel for a quick check.
dbecad wrote:
Sat Jun 02, 2018 12:23 am
My current quest is to design a simple mechanical watch movement and I'm not completely satisfied with my current way of modeling gear trains, where the distance between shafts and positions of said shaft should be parametric. Also animating it after would be a nice plus...
I have a file of a simple planetary gear set in PartDesign using an articulating master sketch which may give you some ideas. It is too large for the Forum but can be put on Dropbox if you are interested.
"It is a poor workman who blames his tools..." ;)