FreeCAD Tutorial - Sketcher Macro Custom Tool @mathcodeprint
FreeCAD Tutorial - Sketcher Macro Custom Tool  @mathcodeprint
Uploaded December 2017 | Updated November 2026, 3 hours ago
This FreeCAD video tutorial demonstrates how to create record a simple macro for the sketch toolbar

In this tutorial I create a Box in the sketcher workbench that is centered on the origin and has distance constraints. I also create a custom icon for the macro.

The Macro isn't perfect and will need some tweaking, but it demonstrates the idea well.

UPDATE: I made the MACRO a tiny bit more robust, not sure if it is the best way but it works. Here is the code, take note of 8 lines and also wherever it was hard coded App.ActiveDocument.Sketch

objects =App.ActiveDocument.Objects
for obj in objects:
if obj.Module == 'Sketcher':
checksketch = obj
viewer = checksketch.ViewObject
if viewer.isEditing():
sketch = obj
print "Currently editing: " + sketch.Name

geoList = []
geoList.append(Part.LineSegment(App.Vector(-9.371968,8.025581,0),App.Vector(7.199169,8.025581,0)))
geoList.append(Part.LineSegment(App.Vector(7.199169,8.025581,0),App.Vector(7.199169,-7.641287,0)))
geoList.append(Part.LineSegment(App.Vector(7.199169,-7.641287,0),App.Vector(-9.371968,-7.641287,0)))
geoList.append(Part.LineSegment(App.Vector(-9.371968,-7.641287,0),App.Vector(-9.371968,8.025581,0)))

(l1,l2,l3,l4) = sketch.addGeometry(geoList)

conList = []

sketch.addConstraint(conList)

conList.append(Sketcher.Constraint('Coincident',l1,2,l2,1))
conList.append(Sketcher.Constraint('Coincident',l2,2,l3,1))
conList.append(Sketcher.Constraint('Coincident',l3,2,l4,1))
conList.append(Sketcher.Constraint('Coincident',l4,2,l1,1))

conList.append(Sketcher.Constraint('Horizontal',l1))
conList.append(Sketcher.Constraint('Horizontal',l3))
conList.append(Sketcher.Constraint('Vertical',l2))
conList.append(Sketcher.Constraint('Vertical',l4))

conList.append(Sketcher.Constraint('Symmetric',l1,1,l1,2,-2))
conList.append(Sketcher.Constraint('Symmetric',l1,2,l2,2,-1))
conList.append(Sketcher.Constraint('DistanceX',l1,1,l1,2,10))
conList.append(Sketcher.Constraint('DistanceY',l2,2,l2,1,10))

sketch.addConstraint(conList)

App.ActiveDocument.recompute()
FreeCAD Tutorial - Sketcher Macro Custom ToolMini-Kossel - Assembly Animation - Motor VertexKicad Beginner Tutorial- A Traffic Light for Arduino ( RE-UPLOADED, Twice )FreeCAD Tutorial - Framing Series FloorMini-Kossel - Assembly Animation - Rod/Carriage/EffectorFreeCAD - Auto Disc Brake ( For Fun )FreeCAD - Move a Sketch with Draft-Move ( Secret Trick Enclosed )FreeCAD Tutorial - Design a Fidget SpinnerFreeCAD - Measure your Arduino ( or other boards ) VIRTUALLY !FreeCAD - Sweep ( 3 ways to use the Sweep tool )OpenSCAD vs. FreeCAD - Using FreeCAD to Export a printable STL of an OpenSCAD Model.FreeCAD Simple Pipe Tutorial - Using Additive/Subtractive Primitives
mathcodeprint |

FreeCAD Tutorial - Sketcher Macro Custom Tool

SHARE TO X SHARE TO REDDIT SHARE TO FACEBOOK WALLPAPER