proposal for exporter

This commit is contained in:
Sebastian Hoogen 2012-12-21 11:26:23 +01:00
parent bebd37a39a
commit c6c68f77b2

View File

@ -146,8 +146,10 @@ def process_object(csg,ob):
print "Extrusion" print "Extrusion"
print ob.Base print ob.Base
print ob.Base.Name print ob.Base.Name
#if ( ob.Base == "Part::FeaturePython" and ob.Base.Name == "Polygon") : if ob.Base.isDerivedFrom('Part::Part2DObjectPython') and \
if ob.Base.Name.startswith("Polygon") : hasattr(ob.Base,'Proxy') and hasattr(ob.Base.Proxy,'Type'):
ptype=ob.Base.Proxy.Type
if ptype == "Polygon" :
f = str(ob.Base.FacesNumber) f = str(ob.Base.FacesNumber)
r = str(ob.Base.Radius) r = str(ob.Base.Radius)
h = str(ob.Dir[2]) h = str(ob.Dir[2])
@ -159,7 +161,7 @@ def process_object(csg,ob):
", r2 = "+r+", center = "+center(mm)+");\n") ", r2 = "+r+", center = "+center(mm)+");\n")
if mm == 1: csg.write("}\n") if mm == 1: csg.write("}\n")
elif ob.Base.Name.startswith("circle") : elif ptype == "Circle" :
r = str(ob.Base.Radius) r = str(ob.Base.Radius)
h = str(ob.Dir[2]) h = str(ob.Dir[2])
print "Radius : " + r print "Radius : " + r
@ -169,7 +171,7 @@ def process_object(csg,ob):
", r2 = "+r+", center = "+center(mm)+");\n") ", r2 = "+r+", center = "+center(mm)+");\n")
if mm == 1: csg.write("}\n") if mm == 1: csg.write("}\n")
elif ob.Base.Name.startswith("Wire") : elif ptype == "Wire" :
print "Wire extrusion" print "Wire extrusion"
print ob.Base print ob.Base
mm = check_multmatrix(csg,ob,0,0,0) mm = check_multmatrix(csg,ob,0,0,0)
@ -177,11 +179,15 @@ def process_object(csg,ob):
csg.write(vertexs2polygon(ob.Base.Shape.Vertexes)) csg.write(vertexs2polygon(ob.Base.Shape.Vertexes))
if mm == 1: csg.write("}\n") if mm == 1: csg.write("}\n")
elif ob.Base.Name.startswith("square") : elif ob.Base.isDerivedFrom('Part::Plane'):
mm = check_multmatrix(csg,ob,0,0,0) mm = check_multmatrix(csg,ob,0,0,0)
csg.write("linear_extrude(height = "+str(ob.Dir[2])+", center = true, "+convexity+", twist = 0, slices = 2, $fn = 0, "+fafs+")\n{\n") csg.write("linear_extrude(height = "+str(ob.Dir[2])+", center = true, "+convexity+", twist = 0, slices = 2, $fn = 0, "+fafs+")\n{\n")
csg.write("square (size = ["+str(ob.Base.Length)+", "+str(ob.Base.Width)+"],center = "+center(mm)+";\n}\n") csg.write("square (size = ["+str(ob.Base.Length)+", "+str(ob.Base.Width)+"],center = "+center(mm)+";\n}\n")
if mm == 1: csg.write("}\n") if mm == 1: csg.write("}\n")
elif ob.Base.Name.startswith('this_is_a_bad_idea'):
pass
else:
pass #There should be a fallback solution
elif ob.Type == "Part::Cut" : elif ob.Type == "Part::Cut" :
print "Cut" print "Cut"