Code: Select all
# Macro Begin: /home/mac/SharedData/FC_common/Mergesketches.FCMacro +++++++++++++++++++++++++++++++++++++++++++++++++
import FreeCAD
import Sketcher
# Gui.runCommand('Std_DlgMacroRecord',0)
# Gui.Selection.addSelection('Unnamed','Sketch')
# Gui.Selection.addSelection('Unnamed','Sketch001')
# Gui.Selection.addSelection('Unnamed','Sketch002')
# Gui.Selection.addSelection('Unnamed','Sketch003')
# Gui.Selection.addSelection('Unnamed','Sketch004')
# Gui.Selection.addSelection('Unnamed','Sketch005')
# Gui.Selection.addSelection('Unnamed','Sketch006')
# Gui.Selection.addSelection('Unnamed','Sketch007')
# Gui.Selection.addSelection('Unnamed','Sketch008')
# Gui.Selection.addSelection('Unnamed','Sketch009')
# Gui.Selection.addSelection('Unnamed','Sketch010')
# Gui.Selection.addSelection('Unnamed','Sketch011')
### Begin command Sketcher_MergeSketches
App.activeDocument().addObject('Sketcher::SketchObject', 'Sketch012')
App.activeDocument().ActiveObject.Placement = App.activeDocument().Sketch.Placement
App.activeDocument().recompute()
### End command Sketcher_MergeSketches
# Macro End: /home/mac/SharedData/FC_common/Mergesketches.FCMacro +++++++++++++++++++++++++++++++++++++++++++++++++
My goal is to merge a set of sketches to one sketch in Python.
Code: Select all
Act_Doc = FreeCAD.ActiveDocument
sketchlist = []
majorcount = 60
majorstep = 5
majordelta = 2.0
for p in range(0,majorcount,majorstep):
ss=Draft.makeShapeString(String=str(p),FontFile="/usr/share/fonts/truetype/freefont/FreeMono.ttf",Size=3.0,Tracking=0.0)
plm=FreeCAD.Placement()
plm.Base=FreeCAD.Vector(majordelta*p, 0.0, 0.0)
plm.Rotation.Q=(0.0, 0.0, 1.5308084989341915e-17, 1.0)
ss.Placement=plm
ss.Support=None
sketchlist.append(Draft.makeSketch(ss, autoconstraints=True))
Act_Doc.removeObject(ss.Label)
FreeCAD.ActiveDocument.recompute()
Basically I don't know how to translate the FCMacro merge to Python.
The ultimate goal is to create a sketch of the text of a scale (as in ruler or dial). I don't know if there is a way to add ShapeStrings directly to a sketch. But if there is a way that is easier that my feeble attempt, I'd love to hear about it.