There are several ways to use Python in FreeCAD:
Modify the 3D representation of those objects.From the Python console, or from custom scripts, you can control FreeCAD and make it perform very complex operations.įor example, from a Python script, you can: But its most widespread use is as a scripting language embedded in other applications.
It is open-source and multi-platform, and can be used for many purposes: from simple shell scripts to very complex programs. 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.Īll 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.įinally, it is worth noting that custom parametric objects are easy to program in python.Python is a programming language that it relatively easy to learn and understand. Often, the geometry that you import from other files won't contain any parameter, and will be simple, non-parametric objects. Not all objects are parametric in FreeCAD. Menu Tools -> Dependency graph shows you a dependency diagram like on the image above. However, you can have many objects that depend on the same object, for example objects B and C both depend on A. But you cannot have object A which depends on object B which depends on object A. (See DAG, and DAG view) You can have object A which depends on object B which depend on object C. The dependency tree must always flow in the same direction.You must then press the recompute button (or Edit->Refresh) to have all the marked objects recomputed. 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). Heavy operations, that might modify a big portion of your document, and therefore take some time, are not performed automatically. Recomputation is not always automatic.Two important things are necessary to know: The whole chain will be rebuilt (recomputed) whenever needed. 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.Īll the intermediary operations (2D shapes, pad, pocket, etc) are still there, and you can still change any of their parameters anytime. With these two properties, it produces a solid shape by extruding the base shape by the given distance. In the example below, a solid, cubic object (Pad) is based on a rectangular 2D shape (Sketch) and has an extrusion distance. 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. 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. Parametric objects, in FreeCAD, are in reality small pieces of a program that run whenever one of the parameters has changed.
With these two parameters, the program has enough information to build the cylinder. For example, a cylinder might be produced from a radius and a height. This means that the geometry that you create, instead of being freely sculptable, is produced by rules and parameters. FreeCAD is designed for parametric modeling.