Macros recipes/sv

This page contains macros to add functionality to your freecad installation

Object creation

 * [[Image:Macro_makeCube.png|24px]] : creates a rectangular cuboid from 4 points
 * [[Image:Text-x-python.png|24px]] : 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.
 * [[Image:Text-x-python.png|24px]] : creates a parametric rectellipse
 * [[Image:Macro_Draft_Circle_3_Points.png|24px]] : 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|24px]] : creates a circle from 3 selected points 2D orthogonal
 * [[Image:Macro_Draft_Circle_3_Points.png|24px]] : creates a circle from 3 selected points in the space 3D
 * [[Image:Macro Make Arc 3 Points.png|24px]] : creates a arc from 3 selected points
 * [[Image:Text-x-python.png|24px]] : This macro creates a screw with or without thread, according to ISO standards (screw_maker1_6.py.zip with Pyside support). (Screw Maker 2.0 - new version!)
 * [[Image:Text-x-python.png|24px]] : This macro creates a geodesic dome shell
 * [[Image:Macro_BOLTS.png|24px]] : The aim of BOLTS is to build a free and open-source standard parts library for CAD applications.
 * [[Image:Text-x-python.png|24px]] Makes an ellipse by selecting three points (in this order): centre, major radius and minor radius
 * [[Image:Text-x-python.png|24px]] : Imports and scales a .dat airfoil to desired chord length.
 * [[Image:Text-x-python.png|24px]] : Create a line giving coordinate XYZ length and angle to plane X Y
 * [[Image:Text-x-python.png|24px]] : 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.
 * [[Image:Text-x-python.png|24px]] : Create a circle or arc giving radius, diameter, circumference, area, startangle, endangle, arc, anglecenter, cord, arrow, center (point) on choice.
 * [[Image:Text-x-python.png|24px]] : Cut a circle or arc and create x arcs, giving the number of cut.
 * [[Image:Macro_FCConvertLines.png|24px]] : this macro convert the object line, wire in line Dash, DashDot, DashDotDot,ZigZag and Hand with the dimensions given.
 * [[Image:Text-x-python.png|24px]] : 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)
 * [[Image:FCTexture.png|24px]] : Create a project from a bmp image to create a texture easily
 * [[Image:FCCreaLoft.png|24px]] : Create a loft with a list of wire (specially created for Macro Texture see above)
 * [[Image:FreeCAD Doc.png|24px]] : Starts the Parts library browser
 * [[Image:BoundBoxTracing.png|24px]] : This macro red trace (editable) around the BoundingBox with 6 rectangles
 * FCCircularTextButtom.png : This macro create a text around a cylinder
 * [[Image:GW_Dim.png|24px]] : Allows the user to create a Geneva wheel mechanism from scratch. Must edit values within the Macro to alter the size of the object.
 * [[Image:GW_Dim.png|24px]] : A GUI front end that allows the user to create a Geneva wheel mechanism from scratch.
 * [[Image:Text-x-python.png|24px]] : This macro creates a Wire with the coordinates extracted from a file. The coordinates X Y Z are separated by a space.
 * FCSpring_Helix_Variable.png : This macro create one spring truncate, the troncature is adjustable on the all coil to choice.
 * [[Image:Text-x-python.png|24px]] : This macro help you to create an Arch Axis System along a line with a set of parameters.
 * [[Image:Cabinets32.png|24px]] : creates side and top/bottom walls for a cabinet with drilled holes for connection parts of manufacturer Hettich.
 * [[Image:Text-x-python.png|24px]] : Creates a half turn (left/right) stair from a Data-file.
 * Macro_Half_Hull_Model.png : This macro generates both three dimensional half-hull and full-hull models from a series of 2D line drawings.
 * [[Image:Text-x-python.png|24px]] : Create stair helix, create your stair nosing select and run the macro.
 * [[Image:Macro_ReproWire.png|24px]] : This macro reproduce all element selected subobject wire or face.
 * [[Image:Gearworkbech.png|24px]] : Additional Workbench to create different types of gears, involute gear, involute rack, cycloide gear, bevel gear.

Object transformation

 * [[Image:Text-x-python.png|24px]] : copies the selected object several times, on an array grid
 * [[Image:Text-x-python.png|24px]] : flattens draft wires that are not planar to their median Z coordinate
 * [[Image:Text-x-python.png|24px]] : flattens draft wires that are not planar to a plane defined by 3 points
 * [[Image:Text-x-python.png|24px]] : converts selected meshes to parts
 * [[Image:PartToVRML.png ‎|24px]] : Converts selected parts to VRML meshes for small size and faster loading (VRML models Kicad and Blender compatible)
 * [[Image:Text-x-python.png|24px]] : allows to find and joint all non connected edge to the closest non connected one using a line
 * [[Image:Text-x-python.png|24px]] : removes all parametric associativity from an object, leaving it as a "dumb" shape
 * [[Image:Text-x-python.png|24px]] : Forces the creation of a Wire from lines and arcs that don't necessarily touch each other. Use this if normal wire operation fails
 * [[Image:Text-x-python.png|24px]] : 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
 * [[Image:Text-x-python.png|24px]] : Converts the selected Face to a single Sketch without constraints.
 * [[Image:Text-x-python.png|24px]] : Converts the selected Edges to a circular Arc if possible. Useful for restoring discretized arcs.
 * [[Image:Macro_CloneConvert.png ‎|24px]] : 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)
 * [[Image:Text-x-python.png|24px]] : This macro create face from a DXF file, the "Layer" are recognized separate and trained in groups.
 * [[Image:Macro_DXF_to_Face_and_Sketch.png ‎|24px]] : This macro converts selected elements of imported dxf to face and sketch.
 * [[Image:Text-x-python.png|24px]] : Macro for easy scaling drawings, graphics, diagram, blueprint and similar 2D images in Image workbench.
 * [[Image:Text-x-python.png|24px]] : apply linear space transformations to distort shapes. E.g., non-uniform scaling, shearing, mirroring, axes swapping.
 * [[Image:Macro_Connect_And_Sweep.png ‎|24px]] : 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
 * [[Image:Part_Section.png ‎|24px]] (parametric): alternative implementation of Part Section tool, more suitable for making sweep paths.
 * [[Image:Macro_Overlap.png ‎|24px]] (parametric): Boolean operation. Similar to Part Common, but with custom overlap count threshold.
 * [[Image:Macro FCWire To Volume.png ‎|24px]] : This macro create boolean operation with the objects selected just select the wires give the thickness and click "Create"

3D View operations

 * [[Image:Text-x-python.png|24px]] This macro rotates the current view by 90° to the left. Only works if you are in Top view.
 * [[Image:Text-x-python.png|24px]] Provides a GUI to permit rotation of view by precise amounts in all three directions.
 * [[Image:Text-x-python.png|24px]] This macro allows you to temporarily put a texture image on the selected objects.
 * [[Image:Text-x-python.png|24px]] This small macro turns the arrow of the mouse in a precision cross.
 * [[Image:Text-x-python.png|24px]] This macro aligns the current view to a selected face.
 * [[Image:Text-x-python.png|24px]] This macro align the selected object to the current View and set the coordinates Placement of the camera.
 * [[Image:Text-x-python.png|24px]] This macro align the face of the selected object to the current View (in case face hole the hole is placed to the view).
 * [[Image:Text-x-python.png|24px]]  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.

Wizards

 * [[Image:Text-x-python.png|24px]] : Creates an unfolded part from a sheet-metal-part.
 * [[Image:Text-x-python.png|24px]] : allows to unroll ruled surfaces and to draw them on a page.
 * [[Image:Text-x-python.png|24px]] : allows to unfold the surfaces of a box of any shape and to draw them on a page.
 * [[Image:Text-x-python.png|24px]] : A GUI front end that allows the user to create a Geneva wheel mechanism from scratch.
 * [[Image:Part_Prism_Apothem.png|24px]] A GUI dialog that creates an Apothem, (inradius) Based Prism from user input.

Utility

 * [[Image:Text-x-python.png|24px]] : shows how to give information to the user through the GUI.
 * [[Image:FCInfo.png|24px]] : 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
 * [[Image:FCInfo.png|24px]] : same as above, but for Linux
 * [[Image:Macro_FCInfoGlass.png|24px]] : Gives a series of information about the selected shape and displayed in screen 3D
 * [[Image:FCInfoToMouse.png|24px]] : Provide informations coordinates, length and angles in real time on the mouse in a bubble annotation displayed in the 3D screen
 * [[Image:Text-x-python.png|24px]] : Exports current design to slicer software or CAM software.
 * [[Image:Text-x-python.png|24px]] : Gives the Delta values and the distance between 2 points
 * CenterFace.png : This macro red trace (editable) the center face (mass) with 1 point and print the coordinates
 * [[Image:Text-x-python.png|24px]] : User-friendly "Info" module created by a FreeCAD user
 * [[Image:Text-x-python.png|24px]] : Add the macros found in the macros folder to the Macros menu of FreeCAD
 * [[Image:Force_Recompute.png|24px]] : Forces manual recompute of model
 * [[Image:Text-x-python.png|24px]] : Shake a sketch in order to discover its unconstrained parts.
 * [[Image:Replace_Part.png|24px]] : Replaces a part (simple copy) in an "Assembly" with another Part (simple copy).
 * WF_wf.png : 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 : This macro generates a listing of all objects in the current document - the list can be in a window or on the Report view.
 * [[Image:Text-x-python.png|24px]] : This pair of macros allow you to alter the Navigation Style while in the Sketcher.
 * Macro_Toggle_Drawstyle.png : This macro toggles the Drawstyle of the selected object
 * Macro_Toggle_Views_Visibility.png : This macro toggles the visibility of various supporting panels in FreeCAD, allowing the main window to be viewed with all available screen space.
 * Macro_Python_Assistant_Window.png : 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 : This macro provides a utility to assemble a project from sub-project files using the Merge Project facility.
 * FCCamera_00.png : 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 : This macro facilitates the user selecting global variables and monitoring their values.
 * [[Image:Text-x-python.png|24px]] : Highlight common parts.
 * [[Image:HighlightDifference.png|24px]] : Compute the difference between two shapes.
 * [[Image:PropertyMemo.png|24px]] : This little macro create one Property additional (memo or other text) for you object (only Draft)
 * [[Image:Macro SelectVisible.png|24px]] : Set of three macro, macro 1: hidden the objects not selected, macro 2: displayed alls objects, macro 3: hidden alls objects.
 * [[Image: SelectVisible.png|24px]] : All visible objects in the tree will be selected.
 * [[Image:Text-x-python.png|24px]] : displays an interactively slidable cross-section.
 * [[Image: Macro_MeasureCircle.png|24px]] : Compute the radius of a circle by 3 points or a circular edge.
 * [[Image:Macro_Copy3DViewToClipboard.png|24px]] : Copy contents of 3DView resized 640, 480 px to clipboard.

Mathematical functions

 * [[Image:Text-x-python.png|24px]] : Draw a function described by parametric equations x(t), y(t) and z(t).
 * [[Image:Text-x-python.png|24px]] : draws a function described by an equation z=F(x)
 * [[Image:Text-x-python.png|24px]] : Based on the above macro, but for parametric and optionally polar equations.

Animation

 * [[Image:Text-x-python.png|24px]] : Rotation rod and piston
 * [[Image:Text-x-python.png|24px]] : Simulation of one spring
 * [[Image:Text-x-python.png|24px]] : Open and close hinge
 * [[Image:Text-x-python.png|24px]] : Assembly animate
 * [[Image:Text-x-python.png|24px]] : Animate angle constrain in sketcher
 * [[Image:Text-x-python.png|24px]] : Simulation of movements of a 3D printer

Raytracing

 * [[Image:Text-x-python.png|24px]] : Export from FreeCAD to Kerkythea

FEM

 * [[Image:Text-x-python.png|24px]] : Create FEM Meshes by GMSH Mesh Generator

Drawing Workbench

 * [[Image:Text-x-python.png|24px]] : 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
 * [[Image:Text-x-python.png|24px]] : 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
 * [[Image:Text-x-python.png|24px]] : 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.png 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.
 * [[Image:Text-x-python.png|24px]] This GUI macro to fill simply all fields of the cartridge model 2 of the plan implementation worksheet FreeCAD.
 * [[Image:Text-x-python.png|24px]] : Get the normal vector of a preselected face for creating a drawing view normal to that face

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

 * [[Image:2364.png|24px]] By microelly2 : freeCAD_macro, geodata, Animation, freecad-nurbs, PieMenu, ..... other
 * [[Image:Text-x-python.png|24px]] By hamish2014: FreeCAD_assembly2, FreeCAD_drawing_dimensioning, ...
 * [[Image:Text-x-python.png|24px]] By triplus: IconThemes, ShortCuts, NavigationIndicator, TabBar, Launcher, PersistentToolbars, PieMenu, ....
 * 681.jpg By rockn: FreeCAD-Timber, FreeCAD-addons, FreeCAD-library, FreeCAD-StructuresBois, .... other
 * [[Image:Text-x-python.png|24px]] By oddtopus: flamingo (workbench for metal structures)

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"
 * 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 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:


 * example :
 * Text-x-python : icon by default (replace with your name icon with the exact same name as your macro page if there is)
 * Macro My Excellent Macro : macro name

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"....)) Note that the name of the icon must have the same name as the name of the macro.
 * You can also Upload a custom format icon.png
 * 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 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

Ex:

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

Ex:


 * Add it to the above categories, create a new category if needed.

Tutorials

 * How to install macros
 * Customize ToolsBar
 * How to install additional workbenches