当前位置: 首页>>代码示例>>Python>>正文


Python Mesh.export方法代码示例

本文整理汇总了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)
开发者ID:faerietree,项目名称:freecad_convert,代码行数:29,代码来源:freecad_convert.py

示例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
开发者ID:MachineHub,项目名称:machines,代码行数:32,代码来源:text-generator.py

示例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)
开发者ID:Obijuan,项目名称:3D-parts,代码行数:19,代码来源:cylinder.py

示例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)
开发者ID:IceForgTW,项目名称:retr3d,代码行数:20,代码来源:utilities.py

示例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)
开发者ID:Dietmar-Franken,项目名称:Retr3d,代码行数:45,代码来源:utilityFunctions.py

示例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)
开发者ID:AdamYoung1234,项目名称:kb_builder,代码行数:44,代码来源:builder.py

示例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)
开发者ID:dwighthubbard,项目名称:SimpleSolidPy,代码行数:24,代码来源:container.py

示例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
开发者ID:yorikvanhavre,项目名称:FreeCAD-CuraEngine-Plugin,代码行数:26,代码来源:SlicerPanel.py

示例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)
开发者ID:ncsaba,项目名称:ewaste3Dprinter,代码行数:38,代码来源:utilityFunctions.py

示例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)
开发者ID:dirkholz,项目名称:pcl_mesh_tools,代码行数:16,代码来源:cad_to_stl.py

示例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);
开发者ID:JiangLongLiu,项目名称:docdoku-plm,代码行数:8,代码来源:convert_step_obj.py

示例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()

开发者ID:codeapps,项目名称:Pythonista,代码行数:19,代码来源:FreeCAD.py

示例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)
开发者ID:altermarkive,项目名称:Ring-Design-with-FreeCAD-and-Python,代码行数:7,代码来源:ring.freecad.py

示例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')
开发者ID:valpo-sats,项目名称:vuwebclient,代码行数:8,代码来源:changer.py

示例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)
开发者ID:Gafeju,项目名称:friki,代码行数:7,代码来源:pyooml.py


注:本文中的Mesh.export方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。