本文整理匯總了Python中OpenSCADUtils.callopenscadstring方法的典型用法代碼示例。如果您正苦於以下問題:Python OpenSCADUtils.callopenscadstring方法的具體用法?Python OpenSCADUtils.callopenscadstring怎麽用?Python OpenSCADUtils.callopenscadstring使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類OpenSCADUtils
的用法示例。
在下文中一共展示了OpenSCADUtils.callopenscadstring方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: addelement
# 需要導入模塊: import OpenSCADUtils [as 別名]
# 或者: from OpenSCADUtils import callopenscadstring [as 別名]
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')
示例2: addelement
# 需要導入模塊: import OpenSCADUtils [as 別名]
# 或者: from OpenSCADUtils import callopenscadstring [as 別名]
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)
示例3: openscadmesh
# 需要導入模塊: import OpenSCADUtils [as 別名]
# 或者: from OpenSCADUtils import callopenscadstring [as 別名]
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