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,42 +146,48 @@ 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'):
f = str(ob.Base.FacesNumber) ptype=ob.Base.Proxy.Type
r = str(ob.Base.Radius) if ptype == "Polygon" :
h = str(ob.Dir[2]) f = str(ob.Base.FacesNumber)
print "Faces : " + f r = str(ob.Base.Radius)
print "Radius : " + r h = str(ob.Dir[2])
print "Height : " + h print "Faces : " + f
mm = check_multmatrix(csg,ob,0,0,-float(h)/2) print "Radius : " + r
csg.write("cylinder($fn = "+f+", "+fafs+", h = "+h+", r1 = "+r+\ print "Height : " + h
", r2 = "+r+", center = "+center(mm)+");\n") mm = check_multmatrix(csg,ob,0,0,-float(h)/2)
if mm == 1: csg.write("}\n") csg.write("cylinder($fn = "+f+", "+fafs+", h = "+h+", r1 = "+r+\
", r2 = "+r+", center = "+center(mm)+");\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
print "Height : " + h print "Height : " + h
mm = check_multmatrix(csg,ob,0,0,-float(h)/2) mm = check_multmatrix(csg,ob,0,0,-float(h)/2)
csg.write("cylinder($fn = 0, "+fafs+", h = "+h+", r1 = "+r+\ csg.write("cylinder($fn = 0, "+fafs+", h = "+h+", r1 = "+r+\
", 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)
csg.write("linear_extrude(height = "+str(ob.Dir[2])+", center = "+center(mm)+", "+convexity+", twist = 0, slices = 2, $fn = 0, "+fafs+")\n{\n") csg.write("linear_extrude(height = "+str(ob.Dir[2])+", center = "+center(mm)+", "+convexity+", twist = 0, slices = 2, $fn = 0, "+fafs+")\n{\n")
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"