Like the others have commented, it's a shiny little script.
As to your question:
cblt2l wrote:2) Delete the shapestring features after the extrusion is made.
You can always use -
App.getDocument("Unnamed").removeObject("ShapeString") ~
App.getDocument("Unnamed").removeObject("ShapeString011") - but that seems to be a very sloppy and amateurish way to go about it. It should be something like -
for obj in FreeCADGui.Selection.getSelection(): - then the "remove ShapeString" but that's one of the parts about FreeCAD/Python that flat out confounds me. How in the world do you get Python to loop through each one of the ShapeStrings and remove them?
Anyway, here's your script with something that works, though it's total crap and a grand display of my lack of Python skills. But it does remove the ShapeStrings.
Code: Select all
import Draft
from math import cos, sin, radians
# Default Values
radius = 35
size = 10.0
angle = 30
thickness = 2
shapes = []
# Create the numbers
for x in xrange(1, 13):
pos = angle * x - 90
x_val = radius * cos(-radians(pos))
y_val = radius * sin(-radians(pos))
print(x_val)
print(y_val)
ss=Draft.makeShapeString(String=str(x),FontFile="/usr/share/fonts/truetype/liberation/LiberationSans-Bold.ttf",Size=size,Tracking=0)
centroid = ss.Shape.BoundBox.Center
plm=FreeCAD.Placement()
plm.Base=FreeCAD.Vector(x_val - centroid[0],y_val - centroid[1],0)
# plm.Rotation.Q=(0.0,-0.0,-0.0,1.0)
ss.Placement=plm
# ss.Support=None
shapes.append(ss.Shape)
# Create the Solid
comp = Part.makeCompound(shapes)
extrude = comp.extrude(App.Base.Vector(0,0,thickness))
Part.show(extrude)
#for obj in FreeCADGui.Selection.getSelection():#This should be the start of only a line or two,
#App.getDocument("Unnamed").removeObject("ShapeString")#but below is all I can get to work.
App.getDocument("Unnamed").removeObject("ShapeString")
App.getDocument("Unnamed").removeObject("ShapeString001")
App.getDocument("Unnamed").removeObject("ShapeString002")
App.getDocument("Unnamed").removeObject("ShapeString003")
App.getDocument("Unnamed").removeObject("ShapeString004")
App.getDocument("Unnamed").removeObject("ShapeString005")
App.getDocument("Unnamed").removeObject("ShapeString006")
App.getDocument("Unnamed").removeObject("ShapeString007")
App.getDocument("Unnamed").removeObject("ShapeString008")
App.getDocument("Unnamed").removeObject("ShapeString009")
App.getDocument("Unnamed").removeObject("ShapeString010")
App.getDocument("Unnamed").removeObject("ShapeString011")