本文整理汇总了Python中Mesh.export方法的典型用法代码示例。如果您正苦于以下问题:Python Mesh.export方法的具体用法?Python Mesh.export怎么用?Python Mesh.export使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mesh
的用法示例。
在下文中一共展示了Mesh.export方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: import Mesh [as 别名]
# 或者: from Mesh import export [as 别名]
def main():
shape = Part.Shape()
#shape_formats = ['.brp', '.igs', '.stp']
if in_ext in mesh_formats:
print("Opening mesh file: ", in_f)
Mesh.open(in_f)
o = FreeCAD.getDocument("Unnamed").findObjects()[0]
#print("dir: ", dir(o))
if out_ext in mesh_formats:
print("Exporting to mesh file: ", out_f)
Mesh.export([o], out_f)
else:
# TODO This is not optimizing the resulting amount of faces!
# see http://www.freecadweb.org/wiki/index.php?title=Mesh_to_Part
shape.makeShapeFromMesh(o.Mesh.Topology, 0.05) # tolerance for sewing
exportParametric(shape, out_f, out_ext)
elif out_ext in mesh_formats:
print("Opening parametric file: ", in_f)
Part.open(in_f)
o = FreeCAD.getDocument("Unnamed").findObjects()[0]
print("Exporting to mesh file: ", out_f)
Mesh.export([o], out_f)
else:
# Parametric -> Parametric
print("Opening parametric file: ", in_f)
shape.read(in_f)
exportParametric(shape, out_f, out_ext)
示例2: machinebuilder
# 需要导入模块: import Mesh [as 别名]
# 或者: from Mesh import export [as 别名]
def machinebuilder(text, size, height):
'''
[doc]
-title-
Text Generator
-description-
Create text in 3D
[inputs]
str(text)
int(size)
int(height)
'''
#-- Generate text
doc = FreeCAD.newDocument("TextGenerator")
ss=Draft.makeShapeString(String=text,FontFile="/usr/share/fonts/truetype/droid/DroidSans.ttf",Size=size,Tracking=0)
#ss=Draft.extrude(ss,FreeCAD.Base.Vector(0,0,10))
obj = doc.addObject("Part::Extrusion","TextGenerator")
obj.Base = ss
obj.Dir = (0,0,height)
doc.recompute()
#-- Export the file
name = text+"-"+str(size)+".stl"
Mesh.export([obj], './%s' % name)
return name
示例3: machinebuilder
# 需要导入模块: import Mesh [as 别名]
# 或者: from Mesh import export [as 别名]
def machinebuilder(diameter, height, file_path):
#-- Get the freecad document
document = os.path.abspath("cylinder.fcstd")
doc = FreeCAD.openDocument(document)
#-- Get the Cylinder object from the document
cyl = doc.getObjectsByLabel("mycylinder")[0]
#-- Set the cylinder's parameters
if cyl:
cyl.Radius = diameter / 2.0
cyl.Height = height
doc.recompute()
#-- Export the file
Mesh.export([cyl], file_path)
示例4: saveAndClose
# 需要导入模块: import Mesh [as 别名]
# 或者: from Mesh import export [as 别名]
def saveAndClose(self, name, saveSTL):
# Save the FCStd file
if os.path.isfile(self.partsDir + name + ".FCStd"):
os.remove(self.partsDir + name + ".FCStd")
App.getDocument(name).saveAs(self.partsDir + name + ".FCStd")
if saveSTL:
# Export an STL
if os.path.isfile(self.stlDir + name + ".stl"):
os.remove(self.stlDir + name + ".stl")
__objs__ = []
__objs__.append(App.getDocument(name).Objects[-1])
Mesh.export(__objs__, self.stlDir + name + ".stl")
del __objs__
# close document
App.closeDocument(name)
示例5: saveAndClose
# 需要导入模块: import Mesh [as 别名]
# 或者: from Mesh import export [as 别名]
def saveAndClose(name, saveSTL):
# Make dateString and add it to the directory string
date = datetime.date.today().strftime("%m_%d_%Y")
# make the printer's directory if it doesn't exist
printerDir = gv.printerDir + "Printer_" + date + "/"
if not os.path.exists(printerDir):
try:
os.makedirs(printerDir)
except OSError as e:
import traceback
critical("Failure to save files, check your configuration file.",
'Error making "printerDir" in saveAndClose: ' + str(e) + '\n' + traceback.format_exc(limit=1),
gv.level, os.path.basename(__file__))
raise StandardError
# make the Parts directory if it doesn't exist
partsDir = printerDir + "Parts/"
if not os.path.exists(partsDir):
os.makedirs(partsDir)
# Save the FCStd file
if os.path.isfile(partsDir + name + ".FCStd"):
os.remove(partsDir + name + ".FCStd")
App.getDocument(name).saveAs(partsDir + name + ".FCStd")
if saveSTL:
# make the STLs directory if it doesn't exist
stlDir = printerDir + "STL_Files/"
if not os.path.exists(stlDir):
os.makedirs(stlDir)
# Export an STL
if os.path.isfile(stlDir + name + ".stl"):
os.remove(stlDir + name + ".stl")
__objs__ = []
__objs__.append(App.getDocument(name).Objects[-1])
import Mesh
Mesh.export(__objs__, stlDir + name + ".stl")
del __objs__
# close document
App.closeDocument(name)
示例6: export
# 需要导入模块: import Mesh [as 别名]
# 或者: from Mesh import export [as 别名]
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)
示例7: exportSTL
# 需要导入模块: import Mesh [as 别名]
# 或者: from Mesh import export [as 别名]
def exportSTL(self, filename, split_colors=True):
__objs_dict__ = collections.defaultdict(lambda:[])
__objs__ = []
for obj in self.doc.Objects:
red, green, blue, j1 = obj.ViewObject.ShapeColor
red = round(red, 6)
green = round(green, 6)
blue = round(blue, 6)
color = '%6f:%6f:%6f' % (red, green, blue)
for key, value in SimpleSolidPy.primitives.colors.items():
print (key, (red, green, blue), value)
if (red, green, blue) == value:
print('setting color')
color = key
print(color)
__objs_dict__[color].append(obj)
__objs__.append(obj)
if split_colors:
for key, value in __objs_dict__.items():
Mesh.export(value, filename.replace('stl','').strip('.')+'_'+key+'.stl')
else:
Mesh.export(__objs__, filename)
示例8: accept
# 需要导入模块: import Mesh [as 别名]
# 或者: from Mesh import export [as 别名]
def accept(self):
# Verify the active document
actDoc = FreeCAD.ActiveDocument
if not actDoc:
self.errorBox("No Open Document\n")
return False
Console.PrintMessage("Accepted" + '\n')
docName = actDoc.Label
docDir = FreeCAD.ActiveDocument.FileName.replace(docName + ".fcstd", "")
partList = FreeCADGui.Selection.getSelection()
# Verify at least one part is selected
if not partList:
self.errorBox("Select at Least One Part Object")
return False
stlParts = docDir + docName + ".stl"
Mesh.export(partList, stlParts)
self.pos = self.GetXYZPos(partList)
#Console.PrintMessage(str(self.pos) + '\n')
retVal = self.sliceParts(self.Vars.readMisc("CuraPath"), stlParts)
if retVal is True:
self.errorBox("Slice Failed!\n Check log file\n" + logFile)
return False
else:
return True
示例9: saveAndClose
# 需要导入模块: import Mesh [as 别名]
# 或者: from Mesh import export [as 别名]
def saveAndClose(name,saveSTL):
#Make dateString and add it to the directory string
date = datetime.date.today().strftime("%m_%d_%Y")
#make the printer's directory if it doesn't exist
printerDir = gv.printerDir+"Printer_"+date+"/"
if not os.path.exists(printerDir):
os.makedirs(printerDir)
#make the Parts directory if it doesn't exist
partsDir = printerDir+"Parts/"
if not os.path.exists(partsDir):
os.makedirs(partsDir)
#Save the FCStd file
if os.path.isfile(partsDir+name+".FCStd"):
os.remove(partsDir+name+".FCStd")
App.getDocument(name).saveAs(partsDir+name+".FCStd")
if saveSTL:
#make the STLs directory if it doesn't exist
stlDir = printerDir+"STL_Files/"
if not os.path.exists(stlDir):
os.makedirs(stlDir)
#Export an STL
if os.path.isfile(stlDir+name+".stl"):
os.remove(stlDir+name+".stl")
__objs__=[]
__objs__.append(App.getDocument(name).Objects[-1])
import Mesh
Mesh.export(__objs__,stlDir+name+".stl")
del __objs__
#close document
App.closeDocument(name)
示例10:
# 需要导入模块: import Mesh [as 别名]
# 或者: from Mesh import export [as 别名]
FREECADPATH='/usr/lib/freecad/lib/'
import sys
sys.path.append(FREECADPATH)
import FreeCAD
import Part
import Mesh
import sys
in_fn, out_fn = sys.argv[1], sys.argv[2]
Part.open(in_fn)
o = [ FreeCAD.getDocument("Unnamed").findObjects()[0] ]
Mesh.export(o, out_fn)
示例11: explodeOBJS
# 需要导入模块: import Mesh [as 别名]
# 或者: from Mesh import export [as 别名]
def explodeOBJS():
if not inputFile or not outputFile:
sys.exit(2);
Part.open(inputFile);
Mesh.export(FreeCAD.ActiveDocument.Objects,outputFile);
示例12: str
# 需要导入模块: import Mesh [as 别名]
# 或者: from Mesh import export [as 别名]
# Macro Begin: C:\Users\Windows\AppData\Roaming\FreeCAD\Export.FCMacro +++++++++++++++++++++++++++++++++++++++++++++++++
import FreeCAD
import Mesh
import getpass
user = getpass.getuser()
counter = 1
for obj in FreeCAD.ActiveDocument.Objects:
objs =[]
objName = obj.Name
objs.append(FreeCAD.getDocument("Unnamed").getObject(objName))
Mesh.export(objs,"C:/Users/" + user + "/Desktop/" + str(counter) + ".obj")
del objs
counter = counter + 1
FreeCAD.ActiveDocument.recompute()
示例13: export
# 需要导入模块: import Mesh [as 别名]
# 或者: from Mesh import export [as 别名]
def export(thing, detail, stl):
doc = App.activeDocument()
mesh = doc.addObject("Mesh::Feature")
mesh.Mesh = Mesh.Mesh(thing.Shape.tessellate(detail))
Mesh.export([mesh], stl)
示例14: saveSTL
# 需要导入模块: import Mesh [as 别名]
# 或者: from Mesh import export [as 别名]
def saveSTL(self):
"""Export the modified part as a STL file."""
# Export an STL of the part
objs = []
objs.append(self.doc.getObject(self.stl_object))
Mesh.export(objs, self.outname + '.stl')
示例15: export_STL
# 需要导入模块: import Mesh [as 别名]
# 或者: from Mesh import export [as 别名]
def export_STL(self, filename="unnamed.stl"):
"""Export the object to STL file"""
objs = [self.obj]
import Mesh
Mesh.export(objs, filename)