From 7a7fd336728a8322f0b11b2480330db160c55427 Mon Sep 17 00:00:00 2001 From: Sebastian Hoogen Date: Tue, 18 Feb 2014 10:53:12 +0100 Subject: [PATCH] OpenSCAD: import surfaces --- src/Mod/OpenSCAD/OpenSCADFeatures.py | 2 +- src/Mod/OpenSCAD/importCSG.py | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/Mod/OpenSCAD/OpenSCADFeatures.py b/src/Mod/OpenSCAD/OpenSCADFeatures.py index 19e9ad0ac..c286d42c7 100644 --- a/src/Mod/OpenSCAD/OpenSCADFeatures.py +++ b/src/Mod/OpenSCAD/OpenSCADFeatures.py @@ -502,4 +502,4 @@ def makeSurfaceVolume(filename): f4=Part.Face(Part.Wire([plane.Edges[3],l2.Edges[0],s.uIso(1).toShape(),l4.Edges[0]])) f5=s.toShape().Faces[0] solid=Part.Solid(Part.Shell([f0,f1,f2,f3,f4,f5])) - return solid,(len(coords[0])-1)/2.0,(len(choords)-1)/2.0 + return solid,(len(coords[0])-1)/2.0,(len(coords)-1)/2.0 diff --git a/src/Mod/OpenSCAD/importCSG.py b/src/Mod/OpenSCAD/importCSG.py index 73af7b02d..610cf75ad 100644 --- a/src/Mod/OpenSCAD/importCSG.py +++ b/src/Mod/OpenSCAD/importCSG.py @@ -335,6 +335,7 @@ def p_operation(p): | linear_extrude_with_twist | rotate_extrude_file | import_file1 + | surface_action | projection_action | hull_action | minkowski_action @@ -629,6 +630,16 @@ def p_import_file1(p): p[0] = [process_import_file(filen,ext,p[3]['layer'])] if printverbose: print "End Import File" +def p_surface_action(p): + 'surface_action : surface LPAREN keywordargument_list RPAREN SEMICOL' + if printverbose: print "Surface" + obj = doc.addObject("Part::Feature",'surface') + obj.Shape,xoff,yoff=makeSurfaceVolume(p[3]['file']) + if p[3]['center']=='true' : + center(obj,xoff,yoff,0.0) + p[0] = [obj] + if printverbose: print "End surface" + def process_import_file(fname,ext,layer): if printverbose: print "Importing : "+fname+"."+ext+" Layer : "+layer if ext.lower() in reverseimporttypes()['Mesh']: