Manual:Parametric objects: Difference between revisions

From FreeCAD Documentation
(Manual:TOC)
No edit summary
Line 15: Line 15:


<!--T:2-->
<!--T:2-->
FreeCAD is designed for parametric modeling. This means that the geometry that you create, instead of being freely sculptable, is produced by rules and parameters. For example, a cylinder might be produced from a radius and a height. With these two parameters, the program has enough information to build the cylinder.
FreeCAD employs a parametric modeling approach, where the geometry of objects is governed by underlying rules and parameters rather than being freely sculpted. This means each component's dimensions and characteristics are defined by parameters, which instruct the program on how to generate the geometry. For instance, to create a cylinder, parameters like radius and height are specified. With these values, FreeCAD generates the precise geometrical shape.


<!--T:3-->
<!--T:3-->
In FreeCAD, parametric objects are essentially small, programmable scripts that execute when any parameter is altered. These parameters can vary widely, including integers and floating-point numbers, real-world dimensional values such as millimeters, meters, or feet, coordinates (expressed as x, y, z), text strings, or even references to other objects. Such versatility in parameters allows the creation of complex models through a series of chained operations where each new object derives its characteristics from a previous one, while also introducing additional attributes.
Parametric objects, in FreeCAD, are in reality small pieces of a program that run whenever one of the parameters has changed. Objects can have a lot of different kinds of parameters: numbers (integers like 1, 2, 3 or floating-point values like 3.1416), real-world sizes (1mm, 2.4m, 4.5ft), (x,y,z) coordinates, text strings ("hello!") or even another object.

<!--T:4-->
This last type allows to quickly build complex chains of operations, each new object being based on a previous one, and adding new features to it.


<!--T:5-->
<!--T:5-->
For example, consider creating a solid cubic object through parametric modeling. You start with a basic 2D rectangular shape labeled as 'plate.' of length l and width w. This sketch defines the base of your cubic object. Next, you define an 'Extrude' operation, or 'Pad,' specifying the distance to push or pull the sketch into a 3D object. This results in a solid cubic form based on the Sketch's shape and the extrusion distance specified.
In the example below, a solid, cubic object (Pad) is based on a rectangular 2D shape (Sketch) and has an extrusion distance. With these two properties, it produces a solid shape by extruding the base shape by the given distance. You can then use this object as a base for further operations, such as drawing a new 2D shape on one of its faces (Sketch001) and then making a subtraction (Pocket), until arriving at your final object.


<!--T:6-->
<!--T:6-->
[[Image:FreeCAD_022_ParametricDesignPlate.png]]
All the intermediary operations (2D shapes, pad, pocket, etc) are still there, and you can still change any of their parameters anytime. The whole chain will be rebuilt (recomputed) whenever needed.


<!--T:7-->
<!--T:7-->
On the top face of the plate you sketch a circle of a given diameter d. You then use this circle to create a pocket (remove material) from the original plate.
[[Image:Parametric_objects.jpg]]


<!--T:8-->
<!--T:8-->
[[Image:FreeCAD_022_ParametricDesignPocket.png]]
Two important things are necessary to know:


<!--T:9-->
<!--T:9-->
If you decide to change either of the dimensions of the plate, or of the circle, the final object would be also modified. Thanks to the use of a parametric design approach, there is no need to redo the object from the beginning.

<!--T:10-->
# Recomputation is not always automatic. Heavy operations, that might modify a big portion of your document, and therefore take some time, are not performed automatically. Instead, the object (and all the objects that depend on it) will be marked for recomputation (a small blue icon appears on them in the tree view). You must then press the recompute button (or {{MenuCommand|Edit->Refresh}}) to have all the marked objects recomputed.
# Recomputation is not always automatic. Heavy operations, that might modify a big portion of your document, and therefore take some time, are not performed automatically. Instead, the object (and all the objects that depend on it) will be marked for recomputation (a small blue icon appears on them in the tree view). You must then press the recompute button (or {{MenuCommand|Edit->Refresh}}) to have all the marked objects recomputed.
# The dependency tree must always flow in the same direction. Loops are forbidden. (See [[Glossary#Directed_Acyclic_Graph|DAG]], and [[DAG view|DAG view]]) You can have object A which depends on object B which depend on object C. But you cannot have object A which depends on object B which depends on object A. That would be a circular dependency. However, you can have many objects that depend on the same object, for example objects B and C both depend on A. Menu {{MenuCommand|Tools -> Dependency graph}} shows you a dependency diagram like on the image above. It can be useful to detect problems.
# The dependency tree must always flow in the same direction. Loops are forbidden. (See [[Glossary#Directed_Acyclic_Graph|DAG]], and [[DAG view|DAG view]]) You can have object A which depends on object B which depend on object C. But you cannot have object A which depends on object B which depends on object A. That would be a circular dependency. However, you can have many objects that depend on the same object, for example objects B and C both depend on A. Menu {{MenuCommand|Tools -> Dependency graph}} shows you a dependency diagram like on the image above. It can be useful to detect problems.


<!--T:10-->
<!--T:10-->
In FreeCAD's parametric modeling process, examining the dependency tree of an object provides a clear insight into the sequential build and relationships within a model. At the foundation of the structure in the above example is the 'Plate Sketch,' which serves as the base for the initial form of the model. An 'Pad' operation is then applied, which adds material to this foundational sketch, effectively creating a three-dimensional structure from the two-dimensional base.
Not all objects are parametric in FreeCAD. Often, the geometry that you import from other files won't contain any parameter, and will be simple, non-parametric objects. However, these can often be used as a base, or starting point for newly created parametric objects, depending, of course, on what the parametric object requires and the quality of the imported geometry.


<!--T:11-->
<!--T:11-->
Following this, a 'Circle Sketch' is drafted on the newly formed surface. This circle forms the basis for the subsequent 'Pocket' operation. The pocket operation strategically removes material from the structure, essentially carving out a portion based on the circle sketch. This process of adding and then subtracting material allows for complex geometries and features to be integrated into the basic model seamlessly.

<!--T:12-->
Through this sequence of operations—starting from the base sketch, adding volume with a pad, and creating detailed features with additional sketches and pockets—the final object takes shape. Each step in this chain depends on its predecessor, illustrating the interconnected nature of parametric design in FreeCAD.

<!--T:8-->
[[Image:FreeCAD_022_ParametricDesignDependGraph.png]]

<!--T:14-->
Not all objects are parametric in FreeCAD. Often, the geometry that you import from other files won't contain any parameter, and will be simple, non-parametric objects. However, these can often be used as a base, or starting point for newly created parametric objects, depending, of course, on what the parametric object requires and the quality of the imported geometry.

<!--T:15-->
All objects, however, parametric or not, will have a couple of basic parameters, such as a Name, which is unique in the document and cannot be edited, a Label, which is a user-defined name that can be edited, and a [[placement]], which holds its position in the 3D space.
All objects, however, parametric or not, will have a couple of basic parameters, such as a Name, which is unique in the document and cannot be edited, a Label, which is a user-defined name that can be edited, and a [[placement]], which holds its position in the 3D space.



Revision as of 00:11, 15 June 2024

FreeCAD employs a parametric modeling approach, where the geometry of objects is governed by underlying rules and parameters rather than being freely sculpted. This means each component's dimensions and characteristics are defined by parameters, which instruct the program on how to generate the geometry. For instance, to create a cylinder, parameters like radius and height are specified. With these values, FreeCAD generates the precise geometrical shape.

In FreeCAD, parametric objects are essentially small, programmable scripts that execute when any parameter is altered. These parameters can vary widely, including integers and floating-point numbers, real-world dimensional values such as millimeters, meters, or feet, coordinates (expressed as x, y, z), text strings, or even references to other objects. Such versatility in parameters allows the creation of complex models through a series of chained operations where each new object derives its characteristics from a previous one, while also introducing additional attributes.

For example, consider creating a solid cubic object through parametric modeling. You start with a basic 2D rectangular shape labeled as 'plate.' of length l and width w. This sketch defines the base of your cubic object. Next, you define an 'Extrude' operation, or 'Pad,' specifying the distance to push or pull the sketch into a 3D object. This results in a solid cubic form based on the Sketch's shape and the extrusion distance specified.

File:FreeCAD 022 ParametricDesignPlate.png

On the top face of the plate you sketch a circle of a given diameter d. You then use this circle to create a pocket (remove material) from the original plate.

If you decide to change either of the dimensions of the plate, or of the circle, the final object would be also modified. Thanks to the use of a parametric design approach, there is no need to redo the object from the beginning.

  1. Recomputation is not always automatic. Heavy operations, that might modify a big portion of your document, and therefore take some time, are not performed automatically. Instead, the object (and all the objects that depend on it) will be marked for recomputation (a small blue icon appears on them in the tree view). You must then press the recompute button (or Edit->Refresh) to have all the marked objects recomputed.
  2. The dependency tree must always flow in the same direction. Loops are forbidden. (See DAG, and DAG view) You can have object A which depends on object B which depend on object C. But you cannot have object A which depends on object B which depends on object A. That would be a circular dependency. However, you can have many objects that depend on the same object, for example objects B and C both depend on A. Menu Tools -> Dependency graph shows you a dependency diagram like on the image above. It can be useful to detect problems.

In FreeCAD's parametric modeling process, examining the dependency tree of an object provides a clear insight into the sequential build and relationships within a model. At the foundation of the structure in the above example is the 'Plate Sketch,' which serves as the base for the initial form of the model. An 'Pad' operation is then applied, which adds material to this foundational sketch, effectively creating a three-dimensional structure from the two-dimensional base.

Following this, a 'Circle Sketch' is drafted on the newly formed surface. This circle forms the basis for the subsequent 'Pocket' operation. The pocket operation strategically removes material from the structure, essentially carving out a portion based on the circle sketch. This process of adding and then subtracting material allows for complex geometries and features to be integrated into the basic model seamlessly.

Through this sequence of operations—starting from the base sketch, adding volume with a pad, and creating detailed features with additional sketches and pockets—the final object takes shape. Each step in this chain depends on its predecessor, illustrating the interconnected nature of parametric design in FreeCAD.

Not all objects are parametric in FreeCAD. Often, the geometry that you import from other files won't contain any parameter, and will be simple, non-parametric objects. However, these can often be used as a base, or starting point for newly created parametric objects, depending, of course, on what the parametric object requires and the quality of the imported geometry.

All objects, however, parametric or not, will have a couple of basic parameters, such as a Name, which is unique in the document and cannot be edited, a Label, which is a user-defined name that can be edited, and a placement, which holds its position in the 3D space.

Finally, it is worth noting that custom parametric objects are easy to program in python.

Read more