Macros recipes

From FreeCAD Documentation
Revision as of 14:56, 25 February 2016 by Piffpoof (talk | contribs)
Jump to: navigation, search
Base ExampleCommandModel.png Tutorial
Time to complete
FreeCAD version
Example files

This page contains macros to add functionality to your freecad installation


Object creation

Object transformation

  • Macro ArrayCopy: copies the selected object several times, on an array grid
  • Macro FlattenWire: flattens draft wires that are not planar to their median Z coordinate
  • Macro FlattenWire3Points: flattens draft wires that are not planar to a plane defined by 3 points
  • Macro MeshToPart: converts selected meshes to parts
  • PartToVRML.png Macro PartToVRML: Converts selected parts to VRML meshes for small size and faster loading (VRML models Kicad and Blender compatible)
  • 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.
  • Macro EdgesToArc: Converts the selected Edges to a circular Arc if possible. Useful for restoring discretized arcs.
  • Macro CloneConvert.png Macro CloneConvert: Creates a clone of the object and the converted in the chosen position and size (inch, mm, m, µm...). The base object is recognized in mm (FreeCAd base)
  • Macro Creating faces from a DXF file: This macro create face from a DXF file, the "Layer" are recognized separate and trained in groups.
  • Macro Image Scaling: Macro for easy scaling drawings, graphics, diagram, blueprint and similar 2D images in Image workbench.

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.
  • Macro Mouse Cross This small macro turns the arrow of the mouse in a precision cross.
  • Macro Align ViewToFace This macro aligns the current view to a selected face.
  • Macro Align Object to View This macro align the selected object to the current View and set the coordinates Placement of the camera.
  • Macro Align Face Object to View This macro align the face of the selected object to the current View (in case face hole the hole is placed to the view).



  • Macro MessageBox: shows how to give information to the user through the GUI.
  • FCInfo.png 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
  • FCInfo.png Macro FCInfo Alternate Linux : same as above, but for Linux
  • Macro FCInfoGlass.png Macro FCInfoGlass : Gives a series of information about the selected shape and displayed in screen 3D
  • FCInfoToMouse.png Macro FCInfoToMouse : Provide informations coordinates, length and angles in real time on the mouse in a bubble annotation displayed in the 3D screen
  • 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
  • CenterFace.png Macro CenterFace : This macro red trace (editable) the center face (mass) with 1 point and print the coordinates
  • Macro ObjectInfo: User-friendly "Info" module created by a FreeCAD user
  • MacroMenu: Add the macros found in the macros folder to the Macros menu of FreeCAD
  • Force Recompute.png Macro ForceRecompute : Forces manual recompute of model
  • Macro Shake Sketch: Shake a sketch in order to discover its unconstrained parts.
  • Replace Part.png Macro Replace Part in Assembly: Replaces a part (simple copy) in an "Assembly" with another Part (simple copy).
  • WF wf.png Macro WorkFeatures: Tool utility to create plans of the axes, planes from 3 points, axes on a form, information on the coordinates of the shape and many other useful features to facilitate the creation of your project. This utility is up next in the combo view.
  • Macro Dump Objects.png Macro Dump Objects: This macro generates a listing of all objects in the current document - the list can be in a window or on the Report view.
  • Macro Manage Navigational Style: This pair of macros allow you to alter the Navigation Style while in the Sketcher.
  • Macro Toggle Drawstyle.png Macro Toggle Drawstyle: This macro toggles the Drawstyle of the selected object
  • Macro Toggle Views Visibility.png Macro Toggle Views Visibility: This macro toggles the visibility of various supporting views in FreeCAD, allowing the main window to be viewed with all available screen space.
  • Macro Python Assistant Window.png Macro Python Assistant Window: This macro provides a cut/copy/paste workspace for Python code, it is segmented so different sections can be selected and it is persistent between FreeCAD sessions.
  • Macro Build Utility.png Macro Build Utility: This macro provides a utility to assemble a project from sub-project files using the Merge Project facility.
  • FCCamera 00.png Macro_FCCamera: This macro can rotate the screen in a defined angle and the defined axis and creates a plan to face the screen to create a form in the specified plan positions the selected face facing the screen, to detect the position of the camera ...
  • Macro Global Variable Watcher.png Macro Global Variable Watcher: This macro facilitates the user selecting global variables and monitoring their values.
  • Macro HighlightCommon: Highlight common parts.
  • HighlightDifference.png Macro HighlightDifference: Compute the difference between two shapes.
  • PropertyMemo.png Macro PropertyMemo: This little macro create one Property additional (memo or other text) for you object (only Draft)
  • Macro SelectVisible.png Macro_ToggleSelectedObjectVisibility: Set of three macro, macro 1: hidden the objects not selected, macro 2: displayed alls objects, macro 3: hidden alls objects
  • Macro Cross_section: displays an interactively slidable cross-section.

Mathematical functions




  • GMSHMacro : Create FEM Meshes by GMSH Mesh Generator

Drawing Workbench

  • Macro Automatic Drawing: allows the user to get the view of his object in a drawing with 4 different position(front,top,iso,right). Needs some modification to be perfectly 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 CartoucheFC Full: (Full field edition for this Templates) This GUI macro to fill simply all fields of the cartridge model 1 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 CartoucheFC 2: (Full field edition for this Templates) This GUI macro to fill simply all fields of the cartridge model 2 of the plan implementation worksheet FreeCAD.
  • Macro Get Normal Vector of Face: Get the normal vector of a preselected face for creating a drawing view normal to that face

How to use?

Macro how to install

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"
  • Tutorial Macro Install HowTo

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.
  • Tutorial Customize ToolsBar

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)

{{Macro|Icon=Text-x-python|Name=Macro_My_Excellent_Macro|Description=What my excellent macro does|Author=your username}}

(With the icon custom)

{{Macro|Icon=Macro_My_Excellent_Macro|Name=Macro_My_Excellent_Macro|Description=What my excellent macro does|Author=your username}}

(Another language with the default icon (example "/fr" "/de" "/it"....))

 What my excellent macro does|Author=your username}}

(Another language with the icon custom (example "/fr" "/de" "/it"....))

 What my excellent macro does|Author=your username}}
  • 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 Text-x-python.png is the default icon of the page dedicated to the Macro.
  • Paste your macro, and use the Code template 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)
  • Add an image: an image is useful to show what the macro does. Optionally you can create an animated gif that represents the object in context. The gif image should have a maximum size of 500x500px as the wiki does not resize animated gifs; if the gif is any bigger the animation won't work.
  • Optionally you can add some more info on how to use your macro, tips, limitations and workaround.
  • It is also interesting to include version information in your macro. This macro allows you to locate in time compared to the evolution of FreeCAD, do "Menu > Help > About FreeCAD and click to Copy to clipboard" and paste it your macro


#OS: Windows Vista
#Platform: 32-bit
#Version: 0.14.3389
#Python version: 2.6.2
#Qt version: 4.5.2
#Coin version: 3.1.0
#SoQt version: 1.4.1
#OCC version: 6.5.1

It is also advisable to create a macro in your header, this header can be used by the Plugin Loader program to install the macro and check versions


__Author__ = "User_Name"
__Version__ = "00.11"
__Date__    = "25/07/2015"

__Comment__ = "This is the comment of the macro"
__Web__ = ""
__Wiki__ = ""
__Icon__  = "/usr/lib/freecad/Mod/plugins/icons/Title_Of_macro"
__IconW__  = "C:/Documents and Settings/YourUserName/Application Data/FreeCAD"
__Help__ = "start the macro and follow the instructions"
__Status__ = "stable"
__Requires__ = "freecad 0.14.3706"
__Communication__ = ""
  • Add it to the above categories, create a new category if needed.
Other languages:
čeština • ‎Deutsch • ‎English • ‎español • ‎français • ‎hrvatski • ‎italiano • ‎română • ‎русский • ‎svenska