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()