本文整理汇总了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