def process2D_ObjectsViaOpenSCADShape(ObjList, Operation, doc): import FreeCAD, importDXF import os, tempfile dir1 = tempfile.gettempdir() filenames = [] for item in ObjList: outputfilename = os.path.join(dir1, "%s.dxf" % tempfilenamegen.next()) importDXF.export([item], outputfilename, True, True) filenames.append(outputfilename) dxfimports = " ".join( 'import(file = "%s");' % # filename \ os.path.split(filename)[1] for filename in filenames ) tmpfilename = callopenscadstring("%s(){%s}" % (Operation, dxfimports), "dxf") from OpenSCAD2Dgeom import importDXFface # TBD: assure the given doc is active face = importDXFface(tmpfilename, None, None) # clean up filenames.append(tmpfilename) # delete the ouptut file as well try: os.unlink(tmpfilename) except OSError: pass return face
def process2D_ObjectsViaOpenSCADShape(ObjList,Operation,doc): import FreeCAD,importDXF import os,tempfile # Mantis 3419 params = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/OpenSCAD") fn = params.GetInt('fnForImport',32) fnStr = ",$fn=" + str(fn) # dir1=tempfile.gettempdir() filenames = [] for item in ObjList : outputfilename=os.path.join(dir1,'%s.dxf' % tempfilenamegen.next()) importDXF.export([item],outputfilename,True,True) filenames.append(outputfilename) # Mantis 3419 dxfimports = ' '.join("import(file = \"%s\" %s);" % \ #filename \ (os.path.split(filename)[1], fnStr) for filename in filenames) # tmpfilename = callopenscadstring('%s(){%s}' % (Operation,dxfimports),'dxf') from OpenSCAD2Dgeom import importDXFface # TBD: assure the given doc is active face = importDXFface(tmpfilename,None,None) #clean up filenames.append(tmpfilename) #delete the output file as well try: os.unlink(tmpfilename) except OSError: pass return face
def process2D_ObjectsViaOpenSCADShape(ObjList, Operation, doc): import FreeCAD, importDXF import os, tempfile # https://www.freecadweb.org/tracker/view.php?id=3419 params = FreeCAD.ParamGet( "User parameter:BaseApp/Preferences/Mod/OpenSCAD") fn = params.GetInt('fnForImport', 32) fnStr = ",$fn=" + str(fn) # dir1 = tempfile.gettempdir() filenames = [] for item in ObjList: outputfilename = os.path.join(dir1, '%s.dxf' % next(tempfilenamegen)) importDXF.export([item], outputfilename, True, True) filenames.append(outputfilename) # https://www.freecadweb.org/tracker/view.php?id=3419 dxfimports = ' '.join("import(file = \"%s\" %s);" % \ #filename \ (os.path.split(filename)[1], fnStr) for filename in filenames) # tmpfilename = callopenscadstring('%s(){%s}' % (Operation, dxfimports), 'dxf') from OpenSCAD2Dgeom import importDXFface # TBD: assure the given doc is active face = importDXFface(tmpfilename, None, None) #clean up filenames.append(tmpfilename) #delete the output file as well try: os.unlink(tmpfilename) except OSError: pass return face
def export(objectslist, filename): """Export the DWG file with a given list of objects. The objects are exported with importDXF.export(). Then the result is converted to DWG. Parameters ---------- exportList : list List of document objects to export. filename : str Path to the new file. Returns ------- str The same `filename` input. """ import importDXF, os, tempfile outdir = tempfile.mkdtemp() _basename = os.path.splitext(os.path.basename(filename))[0] dxf = outdir + os.sep + _basename + ".dxf" importDXF.export(objectslist, dxf) convertToDwg(dxf, filename) return filename
def export(objectslist,filename): "called when freecad exports a file" import importDXF,os,tempfile outdir = tempfile.mkdtemp() dxf = outdir + os.sep + os.path.splitext(os.path.basename(filename))[0] + ".dxf" importDXF.export(objectslist,dxf) convertToDwg(dxf,filename) return filename
def save2DXF (things, outputFilename): """sends a projection of an object's edges onto the z=0 plane to a dxf file (in a layer named "0") """ if type(things) is not list: things = [things] outList = [] tmpParts = [] for thing in things: tmpPart = mydoc.addObject("Part::Feature") tmpParts.append(tmpPart) tmpParts[-1].Shape = thing importDXF.export(tmpParts, outputFilename) for obj in mydoc.Objects: mydoc.removeObject(obj.Name) return
def export(self, p, result, label, data_hash, config): # export the plate to different file formats log.info("Exporting %s layer for %s" % (label, data_hash)) # draw the part so we can export it Part.show(p.val().wrapped) doc = FreeCAD.ActiveDocument # export the drawing into different formats pwd_len = len(config['app']['pwd']) # the absolute part of the working directory (aka - outside the web space) result['exports'][label] = [] if 'js' in result['formats']: with open("%s/%s_%s.js" % (config['app']['export'], label, data_hash), "w") as f: cadquery.exporters.exportShape(p, 'TJS', f) result['exports'][label].append({'name':'js', 'url':'%s/%s_%s.js' % (config['app']['export'][pwd_len:], label, data_hash)}) log.info("Exported 'JS'") if 'brp' in result['formats']: Part.export(doc.Objects, "%s/%s_%s.brp" % (config['app']['export'], label, data_hash)) result['exports'][label].append({'name':'brp', 'url':'%s/%s_%s.brp' % (config['app']['export'][pwd_len:], label, data_hash)}) log.info("Exported 'BRP'") if 'stp' in result['formats']: Part.export(doc.Objects, "%s/%s_%s.stp" % (config['app']['export'], label, data_hash)) result['exports'][label].append({'name':'stp', 'url':'%s/%s_%s.stp' % (config['app']['export'][pwd_len:], label, data_hash)}) log.info("Exported 'STP'") if 'stl' in result['formats']: Mesh.export(doc.Objects, "%s/%s_%s.stl" % (config['app']['export'], label, data_hash)) result['exports'][label].append({'name':'stl', 'url':'%s/%s_%s.stl' % (config['app']['export'][pwd_len:], label, data_hash)}) log.info("Exported 'STL'") if 'dxf' in result['formats']: importDXF.export(doc.Objects, "%s/%s_%s.dxf" % (config['app']['export'], label, data_hash)) result['exports'][label].append({'name':'dxf', 'url':'%s/%s_%s.dxf' % (config['app']['export'][pwd_len:], label, data_hash)}) log.info("Exported 'DXF'") if 'svg' in result['formats']: importSVG.export(doc.Objects, "%s/%s_%s.svg" % (config['app']['export'], label, data_hash)) result['exports'][label].append({'name':'svg', 'url':'%s/%s_%s.svg' % (config['app']['export'][pwd_len:], label, data_hash)}) log.info("Exported 'SVG'") if 'json' in result['formats'] and label == SWITCH_LAYER: with open("%s/%s_%s.json" % (config['app']['export'], label, data_hash), 'w') as json_file: json_file.write(repr(self)) result['exports'][label].append({'name':'json', 'url':'%s/%s_%s.json' % (config['app']['export'][pwd_len:], label, data_hash)}) log.info("Exported 'JSON'") # remove all the documents from the view before we move on for o in doc.Objects: doc.removeObject(o.Label)
def export_to_dxf_abandoned(ai_solid, ai_vector, ai_depth, ai_output_file): # it works only the FreeCAD Gui """ [Obsolete] create a DXF of a slice of FreeCAD Part Object """ l_slices = ai_solid.slice(ai_vector, ai_depth) l_doc = App.newDocument("tmp_doc") i=0 for l_shape in l_slices: i += 1 l_obj = l_doc.addObject("Part::Feature","MyShape{:02d}".format(i)) #l_doc.MyShape.Shape = l_shape #App.ActiveDocument.MyShape.Shape = l_shape l_obj.Shape = l_shape #l_doc.recompute() l_objects = App.ActiveDocument.Objects #l_objects = FreeCAD.ActiveDocument.Objects # this work with the gui but not in pure python script # Suspect root cause: # /usr/lib/freecad/Mod/Draft/importDXF.py line:49 # it seems it doesn't detect the gui is off importDXF.export(l_objects, ai_output_file) return(1)
def process2D_ObjectsViaOpenSCAD(ObjList, Operation, doc=None): import FreeCAD, importDXF import os, tempfile #print "process2D" doc = doc or FreeCAD.activeDocument() dir1 = tempfile.gettempdir() filenames = [] #print "Export DXF" for item in ObjList: outputfilename = os.path.join(dir1, '%s.dxf' % tempfilenamegen.next()) #print "Call Export : "+outputfilename importDXF.export([item], outputfilename, True, True) #print "File Exported" filenames.append(outputfilename) dxfimports = ' '.join("import(file = \"%s\");" % \ #filename \ os.path.split(filename)[1] for filename in filenames) #print "Call OpenSCAD : "+dxfimports tmpfilename = callopenscadstring('%s(){%s}' % (Operation, dxfimports), 'dxf') #from importCSG import processDXF #import the result #obj = processDXF(tmpfilename,None) from OpenSCAD2Dgeom import importDXFface #print "Import DXF" face = importDXFface(tmpfilename, None, None) #print "Add Hull" obj = doc.addObject('Part::Feature', Operation) obj.Shape = face # Hide Children if FreeCAD.GuiUp: for index in ObjList: index.ViewObject.hide() #clean up filenames.append(tmpfilename) #delete the ouptut file as well try: os.unlink(tmpfilename) except OSError: pass return (obj)
def export_to_dxf_abandoned(ai_solid, ai_vector, ai_depth, ai_output_file): # it works only the FreeCAD Gui """ [Obsolete] create a DXF of a slice of FreeCAD Part Object """ l_slices = ai_solid.slice(ai_vector, ai_depth) l_doc = App.newDocument("tmp_doc") i = 0 for l_shape in l_slices: i += 1 l_obj = l_doc.addObject("Part::Feature", "MyShape{:02d}".format(i)) #l_doc.MyShape.Shape = l_shape #App.ActiveDocument.MyShape.Shape = l_shape l_obj.Shape = l_shape #l_doc.recompute() l_objects = App.ActiveDocument.Objects #l_objects = FreeCAD.ActiveDocument.Objects # this work with the gui but not in pure python script # Suspect root cause: # /usr/lib/freecad/Mod/Draft/importDXF.py line:49 # it seems it doesn't detect the gui is off importDXF.export(l_objects, ai_output_file) return (1)
def process2D_ObjectsViaOpenSCAD(ObjList,Operation,doc=None): import FreeCAD,importDXF import os,tempfile #print "process2D" doc = doc or FreeCAD.activeDocument() dir1=tempfile.gettempdir() filenames = [] #print "Export DXF" for item in ObjList : outputfilename=os.path.join(dir1,'%s.dxf' % tempfilenamegen.next()) #print "Call Export : "+outputfilename importDXF.export([item],outputfilename,True,True) #print "File Exported" filenames.append(outputfilename) dxfimports = ' '.join("import(file = \"%s\");" % \ #filename \ os.path.split(filename)[1] for filename in filenames) #print "Call OpenSCAD : "+dxfimports tmpfilename = callopenscadstring('%s(){%s}' % (Operation,dxfimports),'dxf') #from importCSG import processDXF #import the result #obj = processDXF(tmpfilename,None) from OpenSCAD2Dgeom import importDXFface #print "Import DXF" face = importDXFface(tmpfilename,None,None) #print "Add Hull" obj=doc.addObject('Part::Feature',Operation) obj.Shape=face # Hide Children if FreeCAD.GuiUp: for index in ObjList : index.ViewObject.hide() #clean up filenames.append(tmpfilename) #delete the ouptut file as well try: os.unlink(tmpfilename) except OSError: pass return(obj)
def process2D_ObjectsViaOpenSCADShape(ObjList,Operation,doc): import FreeCAD,importDXF import os,tempfile dir1=tempfile.gettempdir() filenames = [] for item in ObjList : outputfilename=os.path.join(dir1,'%s.dxf' % tempfilenamegen.next()) importDXF.export([item],outputfilename,True,True) filenames.append(outputfilename) dxfimports = ' '.join("import(file = \"%s\");" % \ #filename \ os.path.split(filename)[1] for filename in filenames) tmpfilename = callopenscadstring('%s(){%s}' % (Operation,dxfimports),'dxf') from OpenSCAD2Dgeom import importDXFface # TBD: assure the given doc is active face = importDXFface(tmpfilename,None,None) #clean up filenames.append(tmpfilename) #delete the ouptut file as well try: os.unlink(tmpfilename) except OSError: pass return face
def export_dxf_as_zip(export_set: Set[object], svg: str) -> bytes: dxf_directory = Path(gettempdir()).joinpath(str(uuid1())) dxf_directory.mkdir() for object in export_set: export_to = str(dxf_directory.joinpath( f'{object.Label}.dxf')) two_dimensional_projection = get_2d_projection(object) importDXF.export([two_dimensional_projection], export_to) dxf_files = [] for dxf in dxf_directory.glob('*.dxf'): with open(dxf) as f: dxf_files.append((dxf, f.read())) archive_destination = dxf_directory.joinpath('DXF.zip') with zipfile.ZipFile(archive_destination, 'w') as zip: for (filepath, contents) in dxf_files: path = Path(filepath) zip.writestr(path.name, contents) zip.writestr('overview.svg', svg) with open(archive_destination, 'rb') as zip: bytes_content = zip.read() # Delete the directory the archive was created from. shutil.rmtree(dxf_directory) return bytes_content
def export(self, p, result, label, data_hash, config): # export the plate to different file formats log.info("Exporting %s layer for %s" % (label, data_hash)) # draw the part so we can export it Part.show(p.val().wrapped) doc = FreeCAD.ActiveDocument # export the drawing into different formats # the absolute part of the working directory (aka - outside the web # space) pwd_len = len(config['app']['pwd']) result['exports'][label] = [] if 'js' in result['formats']: with open( "%s/%s_%s.js" % (config['app']['export'], label, data_hash), "w") as f: cadquery.exporters.exportShape(p, 'TJS', f) result['exports'][label].append({ 'name': 'js', 'url': '%s/%s_%s.js' % (config['app']['export'][pwd_len:], label, data_hash) }) log.info("Exported 'JS'") if 'brp' in result['formats']: Part.export( doc.Objects, "%s/%s_%s.brp" % (config['app']['export'], label, data_hash)) result['exports'][label].append({ 'name': 'brp', 'url': '%s/%s_%s.brp' % (config['app']['export'][pwd_len:], label, data_hash) }) log.info("Exported 'BRP'") if 'stp' in result['formats']: Part.export( doc.Objects, "%s/%s_%s.stp" % (config['app']['export'], label, data_hash)) result['exports'][label].append({ 'name': 'stp', 'url': '%s/%s_%s.stp' % (config['app']['export'][pwd_len:], label, data_hash) }) log.info("Exported 'STP'") if 'stl' in result['formats']: Mesh.export( doc.Objects, "%s/%s_%s.stl" % (config['app']['export'], label, data_hash)) result['exports'][label].append({ 'name': 'stl', 'url': '%s/%s_%s.stl' % (config['app']['export'][pwd_len:], label, data_hash) }) log.info("Exported 'STL'") if 'dxf' in result['formats']: importDXF.export( doc.Objects, "%s/%s_%s.dxf" % (config['app']['export'], label, data_hash)) result['exports'][label].append({ 'name': 'dxf', 'url': '%s/%s_%s.dxf' % (config['app']['export'][pwd_len:], label, data_hash) }) log.info("Exported 'DXF'") if 'svg' in result['formats']: importSVG.export( doc.Objects, "%s/%s_%s.svg" % (config['app']['export'], label, data_hash)) result['exports'][label].append({ 'name': 'svg', 'url': '%s/%s_%s.svg' % (config['app']['export'][pwd_len:], label, data_hash) }) log.info("Exported 'SVG'") if 'json' in result['formats'] and label == SWITCH_LAYER: with open( "%s/%s_%s.json" % (config['app']['export'], label, data_hash), 'w') as json_file: json_file.write(repr(self)) result['exports'][label].append({ 'name': 'json', 'url': '%s/%s_%s.json' % (config['app']['export'][pwd_len:], label, data_hash) }) log.info("Exported 'JSON'") # remove all the documents from the view before we move on for o in doc.Objects: doc.removeObject(o.Label)
def export(variant, fuse=False, overwrite=False, saveFCStd=False, exportDXF=False): partPrefix = variant[:-4] partPostfix = variant[5:] pinCount = int(variant[5:7]) srcName = srcDir+variant+'.stp' if not os.path.isfile(srcName): FreeCAD.Console.PrintMessage('missing ' + variant + '.stp\n') return if not os.path.exists(dstDir): os.makedirs(dstDir) bodyCutName = 'body-' + partPrefix + '#' bodyCut = None try: tmpl = App.getDocument(libName) except: tmpl = App.openDocument(tmplDir+libName+'.FCStd') for obj in tmpl.Objects: if obj.Label.startswith(bodyCutName): bodyCut = obj break if bodyCut == None: FreeCAD.Console.PrintMessage('missing template for ' + partPrefix + '\n') return FreeCAD.Console.PrintMessage('cehcking ' + variant + '\n') names = [x for x in obj.Label.split('#')] pitch = float(names[2]) dstName = dstDir+names[3]\ .replace('%e',partPrefix)\ .replace('%o',partPostfix)\ .replace('%c','%02d'%pinCount)\ .replace('%p','%.2f'%pitch) settings = { 'align':'' } if len(names) > 4: for i in range(4,len(names)): if names[i] == '': continue option = [x for x in names[i].split(':')] if not option[0] in settings: FreeCAD.Console.PrintWarning('unknown setting : ' + option[0] + '\n') else: settings[option[0]] = option[1] if os.path.isfile(dstName+'.stp'): if not overwrite: FreeCAD.Console.PrintMessage(dstName + ' already exists, skip!\n') return FreeCAD.Console.PrintMessage('exporting ' + dstName + '\n') newDoc = App.newDocument(variant+'_'+str(random.randrange(10000,99999))) guiDoc = Gui.getDocument(newDoc.Name) bodyCut = newDoc.copyObject(bodyCut,True) FreeCAD.Console.PrintMessage(bodyCut.Name + '\n') guiDoc.getObject(bodyCut.Name).Visibility = False; ImportGui.insert(srcName,newDoc.Name) objs = newDoc.getObjectsByLabel(bodyName) if not objs: FreeCAD.Console.PrintMessage('missing body for ' + partPrefix + '\n') return part = objs[0] guiDoc.getObject(part.Name).Visibility = False; objs = newDoc.getObjectsByLabel(fpName) if not objs: FreeCAD.Console.PrintMessage('missing footprint for ' + partPrefix + '\n') return footprint = objs[0] # NOTE!!! If we don't use Placement.copy here, we will be getting a surprise # from FreeCAD. Even if we reset the bodyCut.Placement below, whenever we change # the non-copied placement, bodyCut.Placement will get an update, too! Spooky!! # There seems to be some dangling internal reference bug here. placement = bodyCut.Placement.copy() bodyCut.Placement = App.Placement() offset = (pinCount-2)*pitch/2 if settings['align'] == 'pin': placement.Base.x += offset footprint.Placement = placement.copy() for obj in bodyCut.Shapes: # any better way to id array object? if 'ArrayType' in obj.PropertiesList: # TODO, we assum interval x sets the pitch, add more check later obj.IntervalX.x = pitch obj.NumberX = pinCount obj.Placement.Base.x -= offset else: for sobj in obj.Shapes: if sobj.TypeId == 'Part::Mirroring': sobj.Source.Placement.Base.x -= offset newDoc.recompute() colors = [] objs = [] shapes = [] def make_part(obj,isCut): names = [x for x in obj.Label.split('#')] newObj = newDoc.addObject("Part::Feature", names[0]) if isCut: newObj.Shape = part.Shape.cut(obj.Shape).removeSplitter() else: newObj.Shape = part.Shape.common(obj.Shape).removeSplitter() color = names[1] if not color in shaderColors.named_colors: FreeCAD.Console.PrintWarning('unknown color : ' + color + '\n') color = None else: newObj.ViewObject.ShapeColor = shaderColors.named_colors[color].getDiffuseFloat() if not color in colors: colors.append(color) newObj.Placement = placement.copy() shapes.append(newObj) objs.append(expVRML.exportObject(freecad_object = newObj, shape_color=color, face_colors=None)) make_part(bodyCut,True) for obj in bodyCut.Shapes: make_part(obj,False) if fuse: newObj = newDoc.addObject("Part::MultiFuse", 'part') newObj.Shapes = shapes shapes = [newObj] newDoc.recompute() ImportGui.export(shapes,dstName+'.stp') if exportDXF: shapes = [] shapes.append(footprint) importDXF.export(shapes,dstName+'.dxf') scale=1/2.54 colored_meshes = expVRML.getColoredMesh(Gui, objs , scale) expVRML.writeVRMLFile(colored_meshes, dstName+'.wrl', colors) if saveFCStd: newDoc.saveAs(dstName+'.FCStd') App.closeDocument(newDoc.Name)
def dxfWrite(objlist, filename): importDXF.export(objlist, filename)
part_support = part_support.cut(cylinder_1) # holes for fixing the stator degre = 180 for i in range(int(360 / degre)): radius = maximal_diameter / 2 - 5 - 2.5 alpha = (i * degre * math.pi) / 180 hole_vector = FreeCAD.Vector(radius * math.cos(alpha), radius * math.sin(alpha), 0) hole = Part.makeCylinder(2.5, 1) hole.translate(hole_vector) part_support = part_support.cut(hole) Part.show(part_support) DOC.recompute() __objs__ = [] __objs__.append(FreeCAD.getDocument("part_support").getObject("Shape")) stl_file = u"part_support.stl" Mesh.export(__objs__, stl_file) dxf_file = u"part_support.dxf" importDXF.export(__objs__, dxf_file) setview()
def save2DXF (thing,outputFilename): tmpPart = mydoc.addObject("Part::Feature") tmpPart.Shape = thing importDXF.export([tmpPart], outputFilename) mydoc.removeObject(tmpPart.Name) return
def export(variant, overwrite=False, saveFCStd=False, exportDXF=False): partPrefix = variant[:-4] partPostfix = variant[5:] pinCount = int(variant[5:7]) srcName = srcDir+variant+'.stp' if not os.path.isfile(srcName): FreeCAD.Console.PrintMessage('missing ' + variant + '.stp\n') return if not os.path.exists(dstDir): os.makedirs(dstDir) bodyCutName = 'body-' + partPrefix + '#' bodyCut = None try: tmpl = App.getDocument(tmplName) except: tmpl = App.openDocument(tmplName+'.FCStd') for obj in tmpl.Objects: if obj.Label.startswith(bodyCutName): bodyCut = obj break if bodyCut == None: FreeCAD.Console.PrintMessage('missing template for ' + partPrefix + '\n') return FreeCAD.Console.PrintMessage('cehcking ' + variant + '\n') names = [x for x in obj.Label.split('#')] pitch = float(names[2]) dstName = dstDir+names[3]\ .replace('%e',partPrefix)\ .replace('%o',partPostfix)\ .replace('%c','%02d'%pinCount)\ .replace('%p','%.2f'%pitch) if os.path.isfile(dstName+'.stp'): if not overwrite: FreeCAD.Console.PrintMessage(dstName + ' already exists, skip!\n') return FreeCAD.Console.PrintMessage('exporting ' + dstName + '\n') newDoc = App.newDocument(variant+'_'+str(random.randrange(10000,99999))) guiDoc = Gui.getDocument(newDoc.Name) bodyCut = newDoc.copyObject(bodyCut,True) guiDoc.getObject(bodyCut.Name).Visibility = False; ImportGui.insert(srcName,newDoc.Name) objs = newDoc.getObjectsByLabel(bodyName) if not objs: FreeCAD.Console.PrintMessage('missing body for ' + partPrefix + '\n') return part = objs[0] guiDoc.getObject(part.Name).Visibility = False; objs = newDoc.getObjectsByLabel(fpName) if not objs: FreeCAD.Console.PrintMessage('missing footprint for ' + partPrefix + '\n') return footprint = objs[0] placement = bodyCut.Placement bodyCut.Placement = App.Placement() for obj in bodyCut.Shapes: # any better way to id array object? if 'ArrayType' in obj.PropertiesList: # TODO, we assum interval x sets the pitch, add more check later obj.IntervalX.x = pitch obj.NumberX = pinCount obj.Placement.Base.x -= (pinCount-2)*pitch/2 else: for sobj in obj.Shapes: if sobj.TypeId == 'Part::Mirroring': sobj.Source.Placement.Base.x -= (pinCount-2)*pitch/2 newDoc.recompute() colors = [] objs = [] shapes = [] def make_part(obj,isCut): names = [x for x in obj.Label.split('#')] newObj = newDoc.addObject("Part::Feature", names[0]) if isCut: newObj.Shape = part.Shape.cut(obj.Shape).removeSplitter() else: newObj.Shape = part.Shape.common(obj.Shape).removeSplitter() color = names[1] if not color in shaderColors.named_colors: FreeCAD.Console.PrintWarning('unknown color : ' + color + '\n') color = None else: newObj.ViewObject.ShapeColor = shaderColors.named_colors[color].getDiffuseFloat() if not color in colors: colors.append(color) newObj.Placement = placement shapes.append(newObj) objs.append(expVRML.exportObject(freecad_object = newObj, shape_color=color, face_colors=None)) make_part(bodyCut,True) for obj in bodyCut.Shapes: make_part(obj,False) newDoc.recompute() ImportGui.export(shapes,dstName+'.stp') if exportDXF: shapes = [] shapes.append(footprint) importDXF.export(shapes,dstName+'.dxf') scale=1/2.54 colored_meshes = expVRML.getColoredMesh(Gui, objs , scale) expVRML.writeVRMLFile(colored_meshes, dstName+'.wrl', colors) if saveFCStd: newDoc.saveAs(dstName+'.FCStd') App.closeDocument(newDoc.Name)