Macros recipes/en

This page contains macros to add functionality to your freecad installation

Object creation

 * [[Image:Macro_makeCube.png|16px]] Macro_makeCube : creates a cube from 4 points
 * Macro draw2DFunction: draws a function described by an equation z=F(x)
 * Macro drawParametric2Dfunction: Based on the above macro, but for parametric and optionally polar equations.
 * Macro_Solid Sweep: creates a solid by sweeping a 2D profile along a trajectory previously selected in the 3D view. The 2D elements can be created through the regular tools in FreeCAD's GUI.
 * Macro Rectellipse: creates a parametric rectellipse
 * [[Image:Macro_Draft_Circle_3_Points.png|16px]] Macro_Make_Circle_3_Points: creates a circle on 3 selected points, the points can be objects (this example brings together the two examples below, all parameters simply settle on a graphic window).
 * [[Image:Macro_Draft_Circle_3_Points.png|16px]] Macro_Draft_Circle_3_Points: creates a circle from 3 selected points 2D orthogonal
 * [[Image:Macro_Draft_Circle_3_Points.png|16px]] Macro_Draft_Circle_3_Points_3D: creates a circle from 3 selected points in the space 3D
 * Macro screw_maker1_2: This macro creates a screw with or without thread, according to ISO standards.
 * [[Image:Macro_BOLTS.png|16px]] Macro BOLTS: The aim of BOLTS is to build a free and open-source standard parts library for CAD applications.
 * Macro_Ellipse-Center+2Points Makes an ellipse by selecting three points (in this order): centre, major radius and minor radius

Object transformation

 * Macro ArrayCopy: copies the selected object several times, on an array grid
 * Macro FlattenWire: flattens draft wires that are not plane to their median Z coordinate
 * Macro MeshToPart: converts selected meshes to parts
 * Macro JointWire: allows to find and joint all non connected edge to the closest non connected one using a line
 * Macro Remove parametric history: removes all parametric associativity from an object, leaving it as a "dumb" shape
 * Macro SuperWire: Forces the creation of a Wire from lines and arcs that don't necessarily touch each other. Use this if normal wire operation fails
 * Macro HealArcs: Sometimes arcs are transformed into BSplines, for example when scale operations have been applied to them. This macro recreates valid arcs from them. Useful before exporting to dxf
 * Macro FaceToSketch: Converts the selected Face to a single Sketch without constraints.

3D View operations

 * Macro Rotate View This macro rotates the current view by 90° to the left. Only works if you are in Top view.
 * Macro View Rotation Provides a GUI to permit rotation of view by precise amounts in all three directions.
 * Macro Texture Objects This macro allows you to temporarily put a texture image on the selected objects.

Wizards

 * Macro Automatic drawing: allows the user to get the view of his object in a drawing with 4 different position(front,top,iso,right). Need some modification to be perfecly effective
 * Macro Corner shapes wizard: pops up a dialog asking for the dimensions of your corner piece, then creates the object in the document and creates a page view with top, front and lateral views of the piece
 * Macro CartoucheFC: This GUI macro to fill simply all fields of the cartridge of the plan implementation worksheet FreeCAD, the format of the date and the symbol of the projection mode adapt to the EU region or US selected.
 * Macro unrollRuledSurface: allows to unroll ruled surfaces and to draw them on a page.
 * Macro unfoldBox: allows to unfold the surfaces of a box of any shape and to draw them on a page.

Utility

 * Macro MessageBox: shows how to give information to the user through the GUI.
 * [[Image:FCInfo.png|16px]] Macro_FCInfo : Gives a series of information about the selected shape and can display a conversion of length, inclination (degrees, radian, grade) shape, surface, volume and the weight of the form in the density selected in various international and Anglo-Saxon units
 * Macro 3d Printer Slicer: Exports current design to slicer software or CAM software.
 * Macro Delta xyz : Gives the Delta values and the distance between 2 points

How to use?
The above macros can easily be plugged on any FreeCAD installation
 * Copy the macro python code from the corresponding macro page
 * In FreeCAD, Macro->Macros->Create new, and give it a name
 * Paste the python code you copied
 * Hit the Save button, and restart FreeCAD
 * Open the Macro manager, select your new macro and click "execute"

Additionally, you can also add your new macro to a custom toolbar
 * In FreeCAD, go to Tools -> Customize
 * In the Macros tab, add a new macro, and, if you like, define an icon and a keyboard shortcut
 * In the Toolbars tab, create a new toolbar, and add your macro, taking it from the "Macros" category.

Adding new macros to this repository

 * Create a new page, beginning its name with "Macro", for example "Macro_My_Excellent_Macro" (this can be done simply by editing this page, and adding a new link to your macro, like this: "Macro My Excellent Macro: My excellent macro" . A new page (red link) will be created.
 * In that page, paste the following text:

(With the default icon) (With the icon custom) (Another language with the default icon (example "/fr" "/de" "/it"....)) (Another language with the icon custom (example "/fr" "/de" "/it"....))
 * You can also Upload a custom format icon.png Note that the name of the icon must have the same name as the name of the macro.
 * example : " Macro_My_Excellent_Macro " without extension (the extension is given by the system), and, replace " Icon=Text-x-python " by " Icon=Macro_My_Excellent_Macro ")
 * Text-x-python [[Image:Text-x-python.png|32px]] is the default icon of the page dedicated to the Macro.


 * Paste your macro, and use the preformated text wiki tags to avoid adding spaces into your script. This will display the macro in a monospace font inside a light grey box like the example above.
 * If you like, upload a .png icon with the exact same name as your macro page (ex. Macro_My_Excellent_Macro.png)
 * Optionally you can add some more info on how to use your macro, tips, limitations and workaround.
 * Add it to the above categories, create a new category if needed.