Macros recipes

From FreeCAD Documentation
Revision as of 14:31, 22 April 2018 by DeepSOIC (talk | contribs) (add macro unbind numpad shortcuts)
Jump to navigation Jump to search
Base ExampleCommandModel.png Tutorial
Time to complete
FreeCAD version
Example files

This page contains macros to add functionality to your freecad installation


Part CheckGeometry.svg 3D View operations

  • Text-x-python.svg Macro Rotate View: This macro rotates the current view by 90° to the left. Only works if you are in Top view.
  • Text-x-python.svg Macro View Rotation: Provides a GUI to permit rotation of view by precise amounts in all three directions.
  • Text-x-python.svg Macro Texture Objects: This macro allows you to temporarily put a texture image on the selected objects.
  • Text-x-python.svg Macro Mouse Cross: This small macro turns the arrow of the mouse in a precision cross.
  • Text-x-python.svg Macro Align View to Face: This macro aligns the current view to a selected face.
  • Text-x-python.svg Macro Align Object to View: This macro align the selected object to the current View and set the coordinates Placement of the camera.
  • Text-x-python.svg Macro Align Camera to Working Plane: This macro aligns the camera to the current Draft Working Plane
  • Text-x-python.svg Macro Align Working Plane to Camera: This macro moves the current Draft Working Plane to the center of the current view
  • Text-x-python.svg 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).
  • Text-x-python.svg Macro Toggle Panels Visibility: This macro toggles the visibility of various supporting panels in FreeCAD, allowing the main window to be viewed with all available screen space.
  • Text-x-python.svg 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 ...
  • Text-x-python.svg Macro_Toggle_Visibility: Set of three macro, macro 1: hidden the objects not selected, macro 2: displayed alls objects, macro 3: hidden alls objects.
  • Text-x-python.svg Macro_Toggle_Visibility2: Set of two macro, macro 1: hidden the objects not selected, macro 2: displayed alls objects, macro with the original visibility.
  • Text-x-python.svg Macro SelectVisible: All visible objects in the tree will be selected.
  • Text-x-python.svg Macro Manage Navigational Style: This pair of macros allow you to alter the Navigation Style while in the Sketcher.
  • Text-x-python.svg Macro Duplicate Selection: This macro testing if one selection are duplicate , select the object IN THE 3D VIEW the "ForbiddenCursor" stay if the or one selection is duplicate, the macro stay resident.
  • Text-x-python.svg Macro Copy3DViewToClipboard: Copy contents of 3DView resized 640, 480 px to clipboard .
  • Text-x-python.svg Macro Perpendicular To Wire: This macro positioned your object perpendicularly to wire selected.
  • Text-x-python.svg Macro Rotate To Point: Macro for rotate on object on itself with the axis of rotation the boundbox center, center of mass or last point clicked
  • Text-x-python.svg Macro FCTreeView: Macro for list all objects in the project in one list without hierarchy, options sort by name, label, visibility, group, by length option search by name, label .... without case sensitive or with case sensitive and select all objects displayed in the macro window.
  • Text-x-python.svg Macro Select Hovering: this macro select a choice Face, Edge, Vertex hovering by the mouse.

Draft FlipDimension.svg Animation

Applications-python.svg Code and Scripting

  • Text-x-python.svg Macro MessageBox: shows how to give information to the user through the GUI.
  • Text-x-python.svg 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.
  • Text-x-python.svg Macro Build Utility: This macro provides a utility to assemble a project from sub-project files using the Merge Project facility.
  • Text-x-python.svg Macro Global Variable Watcher: This macro facilitates the user selecting global variables and monitoring their values.

Arch MeshToShape.svg Conversion

Drawing-orthoviews.svg Drawing Workbench

  • Text-x-python.svg 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
  • Text-x-python.svg 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.
  • Text-x-python.svg Macro CartoucheFC Full: This GUI macro to fill simply all fields of the cartridge templates_Full 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.
  • Text-x-python.svg Macro CartoucheFC 2: This GUI macro to fill simply all fields of the cartridge model 2 of the plan implementation worksheet FreeCAD.
  • Text-x-python.svg Macro Normal Vector: Get the normal vector of a preselected face for creating a drawing view normal to that face

Draft BSpline.svg Dxf 2D Draft

Fem ResultDisplacement.svg Fem

  • Text-x-python.svg Macro GMSH: Create FEM Meshes by GMSH Mesh Generator

Part Measure Clear All.svg Info and measures

  • Text-x-python.svg 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
  • Text-x-python.svg Macro FCInfo Alternate Linux: same as above, but for Linux
  • Text-x-python.svg Macro FCInfoGlass: Gives a series of information about the selected shape and displayed in screen 3D
  • Text-x-python.svg Macro FCInfoToMouse: Provide informations coordinates, length and angles in real time on the mouse in a bubble annotation displayed in the 3D screen
  • Text-x-python.svg Macro Delta xyz: Gives the Delta values and the distance between 2 points
  • Text-x-python.svg Macro ObjectInfo: User-friendly "Info" module created by a FreeCAD user
  • Text-x-python.svg 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.
  • Text-x-python.svg Macro MeasureCircle: Compute the radius of a circle by 3 points or a circular edge.

Draft VisGroup.svg Libraries

Bound-expression.svg Mathematical functions


IFC.svg Multifunctional

  • Text-x-python.svg 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.

Workbench Image.svg Object creation

  • Text-x-python.svg Macro Make Cube: creates a rectangular cuboid from 4 points
  • Text-x-python.svg 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.
  • Text-x-python.svg Macro Geodesic Dome: This macro creates a geodesic dome shell
  • Text-x-python.svg Macro Line Length: Create a line giving coordinate XYZ length and angle to plane X Y
  • Text-x-python.svg Macro cutLine: Cut a line and create x points, giving the number of points, create line or not, create points or not, create bicolor or not on choice.
  • Text-x-python.svg Macro circle: Create a circle or arc giving radius, diameter, circumference, area, startangle, endangle, arc, anglecenter, cord, arrow, center (point) on choice.
  • Text-x-python.svg Macro cutCircle: Cut a circle or arc and create x arcs, giving the number of cut.
  • Text-x-python.svg Macro triangleAH: This macro create one triangle creates a triangle by giving the head angle and the height of the triangle (the triangle of the head is positioned to the xyz coordinates 0.0)
  • Text-x-python.svg Macro FCTexture: Create a project from a bmp image to create a texture easily
  • Text-x-python.svg Macro FCCreaLoft: Create a loft with a list of wire (specially created for Macro Texture see above)
  • Text-x-python.svg Macro FCCircularText: This macro create a text around a cylinder
  • Text-x-python.svg Macro WireXYZ: This macro creates a Wire with the coordinates extracted from a file. The coordinates X Y Z are separated by a space.
  • Text-x-python.svg Macro ReproWire: This macro reproduce all element selected subobject wire or face.
  • Text-x-python.svg Macro Apothem Based Prism GUI: A GUI dialog that creates an Apothem, (inradius) Based Prism from user input.
  • Text-x-python.svg Macro FCSpring Helix Variable: This macro create one spring truncate, the troncature is adjustable on the all coil to choice.
  • Text-x-python.svg Macro Guitar fretboard: Guitar Fretboard Maker

Workbench PartDesign.svg Object transformation

  • Text-x-python.svg Macro ArrayCopy: copies the selected object several times, on an array grid
  • Text-x-python.svg Macro FlattenWire: flattens draft wires that are not planar to their median Z coordinate
  • Text-x-python.svg Macro FlattenWire3Points: flattens draft wires that are not planar to a plane defined by 3 points
  • Text-x-python.svg Macro JointWire: allows to find and joint all non connected edge to the closest non connected one using a line
  • Text-x-python.svg Macro Remove parametric history: removes all parametric associativity from an object, leaving it as a "dumb" shape
  • Text-x-python.svg 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
  • Text-x-python.svg 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
  • Text-x-python.svg 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)
  • Text-x-python.svg Macro Image Scaling: Macro for easy scaling drawings, graphics, diagram, blueprint and similar 2D images in Image workbench.
  • Text-x-python.svg Macro MatrixTransform: apply linear space transformations to distort shapes. E.g., non-uniform scaling, shearing, mirroring, axes swapping.
  • Text-x-python.svg Macro Connect And Sweep: This macro easily creates a connection between two objects, an object and a point or between two points (the center of the objects are the starting and ending points of the sweep) can be selected form a configurable ellipse polygon circle
  • Text-x-python.svg Macro Section: (parametric): alternative implementation of Part Section tool, more suitable for making sweep paths.
  • Text-x-python.svg Macro Overlap: (parametric): Boolean operation. Similar to Part Common, but with custom overlap count threshold.

View.svg Printer 3D

Preferences-raytracing.svg Raytracing

Spreadsheet.svg Spreadsheet Workbench

  • Text-x-python.svg Macro Alias Manager: helps managing aliases inside FreeCAD Spreadsheet workbench. It is able to create, delete, move aliases and create a 'part family' group of files.
  • Text-x-python.svg Macro SpreadsheetTools: This macro helps managing cells inside FreeCAD Spreadsheet workbench.

Arch Survey.svg Utility

Bulb.svg Wizards

  • Text-x-python.svg Macro Sheet Metal Unfolder: Creates an unfolded part from a sheet-metal-part.
  • Text-x-python.svg Macro Unroll Ruled Surface: allows to unroll ruled surfaces and to draw them on a page.
  • Text-x-python.svg Macro Unfold Box: allows to unfold the surfaces of a box of any shape and to draw them on a page.
  • Text-x-python.svg Macro Airfoil Import & Scale: Imports and scales a .dat airfoil to desired chord length.
  • Text-x-python.svg Macro Geneva Wheel: Allows the user to create a Geneva wheel mechanism from scratch. Must edit values within the Macro to alter the size of the object.
  • Text-x-python.svg Macro Geneva Wheel GUI: A GUI front end that allows the user to create a Geneva wheel mechanism from scratch.
  • Text-x-python.svg Macro Cabinets32: creates side and top/bottom walls for a cabinet with drilled holes for connection parts of manufacturer Hettich.
  • Text-x-python.svg Macro Half_turn_stairs: Creates a half turn (left/right) stair from a Data-file.
  • Text-x-python.svg Macro Half-Hull Model: This macro generates both three dimensional half-hull and full-hull models from a series of 2D line drawings.
  • Text-x-python.svg Macro Stairs: Create stair helix, create your stair nosing select and run the macro.
  • Text-x-python.svg Macro FCGear: Additional Workbench to create different types of gears, involute gear, involute rack, cycloide gear, bevel gear.
  • Text-x-python.svg 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
  • Text-x-python.svg Macro PropertyMemo: This little macro create one Property additional (memo or other text) for you object (only Draft)

Std FreeCADWebsite.png Other interesting macros create by FreeCAD users and deposit in extra wiki.

  • 2364.png By microelly2 : freeCAD_macro, geodata, Animation, freecad-nurbs, PieMenu, ..... other
  • Text-x-python.png By hamish2014: FreeCAD_assembly2, FreeCAD_drawing_dimensioning, ...
  • Text-x-python.png By triplus: IconThemes, ShortCuts, NavigationIndicator, TabBar, Launcher, PersistentToolbars, PieMenu, ....
  • 681.jpg By rockn: FreeCAD-Timber, FreeCAD-addons, FreeCAD-library, FreeCAD-StructuresBois, .... other
  • Text-x-python.png By oddtopus: flamingo (workbench for metal structures)
  • Text-x-python.png By dprojects: getDimensions FreeCAD macro to get chipboards dimensions to cut (woodworking)
  • Text-x-python.png By Siardeni: workbench for create metal profiles, square tubing, z profile, palette, rotation, drawing ...

How to use?

Macro how to install

The above macros can easily be plugged on any FreeCAD installation

  • Starting from FreeCAD v 0.17, a new Tools -> Addons Manager allows you to easily install any macro from this page. The instructions below must still be followed if your version of FreeCAD doesn't have the Addons Manager yet.
  • 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 How to install macros

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 Toolbars

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:
    • example :
* {{MacroLink|Text-x-python|Macro My Excellent Macro|Macro My Excellent Macro title}} : My excellent macro description.
  • Text-x-python : icon by default (replace with your name icon with the exact same name as your macro page if there is. The format always .png only)
  • Macro My Excellent Macro : macro name
  • Macro My Excellent Macro title : macro name or title

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|Version=1.0|Date=YYYY-MM-DD}

(With the icon custom)

{{Macro|Icon=Macro_My_Excellent_Macro|Name=Macro_My_Excellent_Macro|Description=What my excellent macro does|Author=your username|Version=1.0|Date=YYYY-MM-DD}}

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

 What my excellent macro does|Author=your username|Version=1.0|Date=YYYY-MM-DD}

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

 What my excellent macro does|Author=your username|Version=1.0|Date=YYYY-MM-DD}}
  • 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. Also available addons_installer.FCMacro


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

__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:
Deutsch • ‎English • ‎español • ‎français • ‎hrvatski • ‎italiano • ‎română • ‎svenska • ‎čeština • ‎русский