The link to the video https://youtu.be/DsRkUlEwouY
The Macro
Code: Select all
import Part
import Draft
import Sketcher
doc = App.newDocument("Unnamed")
#Create our table bed Sketch
App.activeDocument().addObject('Sketcher::SketchObject', 'Sketch')
App.activeDocument().Sketch.Placement = App.Placement(App.Vector(0.000000, 0.000000, 0.000000), App.Rotation(0.000000, 0.000000, 0.000000, 1.000000))
App.activeDocument().Sketch.MapMode = "Deactivated"
geoList = []
geoList.append(Part.LineSegment(App.Vector(0.000000,0.000000,0),App.Vector(19,0.000000,0)))
geoList.append(Part.LineSegment(App.Vector(19,0.000000,0),App.Vector(19,30,0)))
geoList.append(Part.LineSegment(App.Vector(19,30,0),App.Vector(0.000000,30,0)))
geoList.append(Part.LineSegment(App.Vector(0.000000,30,0),App.Vector(0.000000,0.000000,0)))
App.getDocument('Unnamed').getObject('Sketch').addGeometry(geoList,False)
conList = []
conList.append(Sketcher.Constraint('Coincident',0,2,1,1))
conList.append(Sketcher.Constraint('Coincident',1,2,2,1))
conList.append(Sketcher.Constraint('Coincident',2,2,3,1))
conList.append(Sketcher.Constraint('Coincident',3,2,0,1))
conList.append(Sketcher.Constraint('Horizontal',0))
conList.append(Sketcher.Constraint('Horizontal',2))
conList.append(Sketcher.Constraint('Vertical',1))
conList.append(Sketcher.Constraint('Vertical',3))
App.getDocument('Unnamed').getObject('Sketch').addConstraint(conList)
del geoList, conList
App.getDocument('Unnamed').getObject('Sketch').addConstraint(Sketcher.Constraint('Coincident',0,1,-1,1))
App.getDocument('Unnamed').getObject('Sketch').addConstraint(Sketcher.Constraint('DistanceX',2,2,2,1,19))
App.getDocument('Unnamed').getObject('Sketch').setDatum(9,App.Units.Quantity('19 in'))
App.getDocument('Unnamed').getObject('Sketch').addConstraint(Sketcher.Constraint('DistanceY',3,2,3,1,30))
App.getDocument('Unnamed').getObject('Sketch').setDatum(10,App.Units.Quantity('30 in'))
App.ActiveDocument.recompute()
#End of Table Bed Sketch
#Create Text and move it
ourstring = "Go Get The $"
#for windows operating systems use
#FontFile="C:/Windows/Fonts/ANTQUAB.TTF"
#in the next line of code replacing /usr/share
ss=Draft.make_shapestring(String=ourstring , FontFile="/usr/share/fonts/truetype/padauk/Padauk-Regular.ttf", Size=38.099999999999994, Tracking=0.0)
plm=FreeCAD.Placement()
plm.Base=FreeCAD.Vector(0.0, 0.0, 0.0)
plm.Rotation.Q=(0.0, 0.0, 0.0, 1.0)
ss.Placement=plm
ss.Support=None
Draft.autogroup(ss)
App.activeDocument().recompute(None,True,True)
FreeCAD.getDocument('Unnamed').getObject('ShapeString').Placement = App.Placement(App.Vector(127.0000,50.8000,0.0000),App.Rotation(App.Vector(0.0000,0.0000,1.0000),90.0000))
#End of Create Text
#Make 2D wire from the ShapeString
sv0 = Draft.make_shape2dview(FreeCAD.ActiveDocument.ShapeString, FreeCAD.Vector(-0.0, -0.0, 1.0))
App.ActiveDocument.recompute()
#now create the path
import PathCommands
FreeCAD.activeDocument().addObject('Path::FeatureShape','PathShape')
FreeCAD.activeDocument().PathShape.Sources = [ FreeCAD.activeDocument().Shape2DView, ]
App.ActiveDocument.recompute()
#inspect the Path Gcode just created
import PathScripts.PathInspect
PathScripts.PathInspect.show(FreeCAD.ActiveDocument.PathShape)
Code: Select all
import PathScripts.PathUtils
PathScripts.PathUtils.addToJob(App.ActiveDocument.PathShape)