def addelement(self): scadstr = unicode(self.form.textEdit.toPlainText()) asmesh = self.form.checkboxmesh.checkState() import OpenSCADUtils, os extension = 'stl' if asmesh else 'csg' tmpfilename = OpenSCADUtils.callopenscadstring(scadstr, extension) if tmpfilename: doc = FreeCAD.activeDocument() or FreeCAD.newDocument() if asmesh: import Mesh Mesh.insert(tmpfilename, doc.Name) else: import importCSG importCSG.insert(tmpfilename, doc.Name) os.unlink(tmpfilename) else: FreeCAD.Console.PrintError('Running OpenSCAD failed\n')
def addelement(self): scadstr=unicode(self.form.textEdit.toPlainText()) asmesh=self.form.checkboxmesh.checkState() import OpenSCADUtils, os extension= 'stl' if asmesh else 'csg' tmpfilename=OpenSCADUtils.callopenscadstring(scadstr,extension) if tmpfilename: doc=FreeCAD.activeDocument() or FreeCAD.newDocument() if asmesh: import Mesh Mesh.insert(tmpfilename,doc.Name) else: import importCSG importCSG.insert(tmpfilename,doc.Name) os.unlink(tmpfilename) else: FreeCAD.Console.PrintError(unicode(translate('OpenSCAD','Running OpenSCAD failed'))+u'\n')
def addelement(self): scadstr=unicode(self.form.textEdit.toPlainText()).encode('utf8') asmesh=self.form.checkboxmesh.checkState() import OpenSCADUtils, os extension= 'stl' if asmesh else 'csg' try: tmpfilename=OpenSCADUtils.callopenscadstring(scadstr,extension) doc=FreeCAD.activeDocument() or FreeCAD.newDocument() if asmesh: import Mesh Mesh.insert(tmpfilename,doc.Name) else: import importCSG importCSG.insert(tmpfilename,doc.Name) try: os.unlink(tmpfilename) except OSError: pass except OpenSCADUtils.OpenSCADError, e: FreeCAD.Console.PrintError(e.value)
def addelement(self): scadstr = self.form.textEdit.toPlainText() asmesh = self.form.checkboxmesh.checkState() import OpenSCADUtils, os extension = 'stl' if asmesh else 'csg' try: tmpfilename = OpenSCADUtils.callopenscadstring(scadstr, extension) doc = FreeCAD.activeDocument() or FreeCAD.newDocument() if asmesh: import Mesh Mesh.insert(tmpfilename, doc.Name) else: import importCSG importCSG.insert(tmpfilename, doc.Name) try: os.unlink(tmpfilename) except OSError: pass except OpenSCADUtils.OpenSCADError as e: FreeCAD.Console.PrintError(e.value)
def openscadmesh(doc, scadstr, objname): import Part, Mesh, os, OpenSCADUtils tmpfilename = OpenSCADUtils.callopenscadstring(scadstr, 'stl') if tmpfilename: #mesh1 = doc.getObject(objname) #reuse imported object Mesh.insert(tmpfilename) os.unlink(tmpfilename) mesh1 = doc.getObject(objname) #blog mesh1.ViewObject.hide() sh = Part.Shape() sh.makeShapeFromMesh(mesh1.Mesh.Topology, 0.1) solid = Part.Solid(sh) obj = doc.addObject("Part::FeaturePython", objname) ImportObject(obj, mesh1) #This object is not mutable from the GUI ViewProviderTree(obj.ViewObject) solid = solid.removeSplitter() if solid.Volume < 0: solid.complement() obj.Shape = solid #.removeSplitter() return obj else: print scadstr
def openscadmesh(doc,scadstr,objname): import Part,Mesh,os,OpenSCADUtils tmpfilename=OpenSCADUtils.callopenscadstring(scadstr,'stl') if tmpfilename: #mesh1 = doc.getObject(objname) #reuse imported object Mesh.insert(tmpfilename) os.unlink(tmpfilename) mesh1=doc.getObject(objname) #blog mesh1.ViewObject.hide() sh=Part.Shape() sh.makeShapeFromMesh(mesh1.Mesh.Topology,0.1) solid = Part.Solid(sh) obj=doc.addObject("Part::FeaturePython",objname) ImportObject(obj,mesh1) #This object is not mutable from the GUI ViewProviderTree(obj.ViewObject) solid=solid.removeSplitter() if solid.Volume < 0: solid.complement() obj.Shape=solid#.removeSplitter() return obj else: print scadstr