From 97f3fd54ce2efb5ffc74df05a9a08ea503b18563 Mon Sep 17 00:00:00 2001 From: Sebastian Hoogen Date: Sat, 15 Jun 2013 16:37:29 +0200 Subject: [PATCH] use TypeId instead of Type of Part::Feature in exportCSG.py --- src/Mod/OpenSCAD/exportCSG.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/Mod/OpenSCAD/exportCSG.py b/src/Mod/OpenSCAD/exportCSG.py index d7568c4ec..aa3ad720b 100644 --- a/src/Mod/OpenSCAD/exportCSG.py +++ b/src/Mod/OpenSCAD/exportCSG.py @@ -104,32 +104,32 @@ def process_object(csg,ob): print "axis : "+str(ob.Placement.Rotation.Axis) print "angle : "+str(ob.Placement.Rotation.Angle) - if ob.Type == "Part::Sphere" : + if ob.TypeId == "Part::Sphere" : print "Sphere Radius : "+str(ob.Radius) check_multmatrix(csg,ob,0,0,0) csg.write("sphere($fn = 0, "+fafs+", r = "+str(ob.Radius)+");\n") - elif ob.Type == "Part::Box" : + elif ob.TypeId == "Part::Box" : print "cube : ("+ str(ob.Length)+","+str(ob.Width)+","+str(ob.Height)+")" mm = check_multmatrix(csg,ob,-ob.Length/2,-ob.Width/2,-ob.Height/2) csg.write("cube (size = ["+str(ob.Length)+", "+str(ob.Width)+", "+str(ob.Height)+"], center = "+center(mm)+");\n") if mm == 1 : csg.write("}\n") - elif ob.Type == "Part::Cylinder" : + elif ob.TypeId == "Part::Cylinder" : print "cylinder : Height "+str(ob.Height)+ " Radius "+str(ob.Radius) mm = check_multmatrix(csg,ob,0,0,-ob.Height/2) csg.write("cylinder($fn = 0, "+fafs+", h = "+str(ob.Height)+ ", r1 = "+str(ob.Radius)+\ ", r2 = " + str(ob.Radius) + ", center = "+center(mm)+");\n") if mm == 1 : csg.write("}\n") - elif ob.Type == "Part::Cone" : + elif ob.TypeId == "Part::Cone" : print "cone : Height "+str(ob.Height)+ " Radius1 "+str(ob.Radius1)+" Radius2 "+str(ob.Radius2) mm = check_multmatrix(csg,ob,0,0,-ob.Height/2) csg.write("cylinder($fn = 0, "+fafs+", h = "+str(ob.Height)+ ", r1 = "+str(ob.Radius1)+\ ", r2 = "+str(ob.Radius2)+", center = "+center(mm)+");\n") if mm == 1 : csg.write("}\n") - elif ob.Type == "Part::Torus" : + elif ob.TypeId == "Part::Torus" : print "Torus" print ob.Radius1 print ob.Radius2 @@ -142,13 +142,13 @@ def process_object(csg,ob): else : # Cannot convert to rotate extrude so best effort is polyhedron csg.write('%s\n' % shape2polyhedron(ob.Shape)) - elif ob.Type == "Part::Extrusion" : + elif ob.TypeId == "Part::Extrusion" : print "Extrusion" print ob.Base print ob.Base.Name if ob.Base.isDerivedFrom('Part::Part2DObjectPython') and \ - hasattr(ob.Base,'Proxy') and hasattr(ob.Base.Proxy,'Type'): - ptype=ob.Base.Proxy.Type + hasattr(ob.Base,'Proxy') and hasattr(ob.Base.Proxy,'TypeId'): + ptype=ob.Base.Proxy.TypeId if ptype == "Polygon" : f = str(ob.Base.FacesNumber) r = str(ob.Base.Radius) @@ -189,35 +189,35 @@ def process_object(csg,ob): else: pass #There should be a fallback solution - elif ob.Type == "Part::Cut" : + elif ob.TypeId == "Part::Cut" : print "Cut" csg.write("difference() {\n") process_object(csg,ob.Base) process_object(csg,ob.Tool) csg.write("}\n") - elif ob.Type == "Part::Fuse" : + elif ob.TypeId == "Part::Fuse" : print "union" csg.write("union() {\n") process_object(csg,ob.Base) process_object(csg,ob.Tool) csg.write("}\n") - elif ob.Type == "Part::Common" : + elif ob.TypeId == "Part::Common" : print "intersection" csg.write("intersection() {\n") process_object(csg,ob.Base) process_object(csg,ob.Tool) csg.write("}\n") - elif ob.Type == "Part::MultiFuse" : + elif ob.TypeId == "Part::MultiFuse" : print "Multi Fuse / union" csg.write("union() {\n") for subobj in ob.Shapes: process_object(csg,subobj) csg.write("}\n") - elif ob.Type == "Part::Common" : + elif ob.TypeId == "Part::Common" : print "Multi Common / intersection" csg.write("intersection() {\n") for subobj in ob.Shapes: @@ -247,7 +247,7 @@ def export(exportList,filename): for ob in exportList: print ob print "Name : "+ob.Name - print "Type : "+ob.Type + print "Type : "+ob.TypeId print "Shape : " print ob.Shape process_object(csg,ob)