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


Python Mesh.insert方法代码示例

本文整理汇总了Python中Mesh.insert方法的典型用法代码示例。如果您正苦于以下问题:Python Mesh.insert方法的具体用法?Python Mesh.insert怎么用?Python Mesh.insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mesh的用法示例。


在下文中一共展示了Mesh.insert方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: process_mesh_file

# 需要导入模块: import Mesh [as 别名]
# 或者: from Mesh import insert [as 别名]
def process_mesh_file(fname,ext):
    import Mesh,Part
    fullname = fname+'.'+ext
    filename = os.path.join(pathName,fullname)
    objname = os.path.split(fname)[1]
    mesh1 = doc.getObject(objname) #reuse imported object
    if not mesh1:
        Mesh.insert(filename)
        mesh1=doc.getObject(objname)
    if mesh1 is not None:
        if gui:
            mesh1.ViewObject.hide()
        sh=Part.Shape()
        sh.makeShapeFromMesh(mesh1.Mesh.Topology,0.1)
        solid = Part.Solid(sh)
        obj=doc.addObject('Part::Feature',"Mesh")
        #ImportObject(obj,mesh1) #This object is not mutable from the GUI
        #ViewProviderTree(obj.ViewObject)
        solid=solid.removeSplitter()
        if solid.Volume < 0:
            #sh.reverse()
            #sh = sh.copy()
            solid.complement()
        obj.Shape=solid#.removeSplitter()
    else: #mesh1 is None
        FreeCAD.Console.PrintError('Mesh not imported %s.%s %s\n' % \
                (objname,ext,filename))
        import Part
        obj=doc.addObject('Part::Feature',"FailedMeshImport")
        obj.Shape=Part.Compound([])
    return(obj)
开发者ID:itain,项目名称:FreeCAD,代码行数:33,代码来源:importCSG.py

示例2: addelement

# 需要导入模块: import Mesh [as 别名]
# 或者: from Mesh import insert [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')
开发者ID:Daedalus12,项目名称:FreeCAD_sf_master,代码行数:19,代码来源:OpenSCADCommands.py

示例3: addelement

# 需要导入模块: import Mesh [as 别名]
# 或者: from Mesh import insert [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)
开发者ID:andrewjrobinson,项目名称:FreeCAD_sf_master,代码行数:23,代码来源:OpenSCADCommands.py

示例4: openscadmesh

# 需要导入模块: import Mesh [as 别名]
# 或者: from Mesh import insert [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
开发者ID:MarcusWolschon,项目名称:FreeCAD_sf_master,代码行数:24,代码来源:prototype.py

示例5: process_mesh_file

# 需要导入模块: import Mesh [as 别名]
# 或者: from Mesh import insert [as 别名]
def process_mesh_file(fname,ext):
    import Mesh
    fullname = fname+'.'+ext
    filename = os.path.join(pathName,fullname)
    mesh1 = doc.getObject(fname) #reuse imported object
    if not mesh1:
        Mesh.insert(filename)
        mesh1=doc.getObject(fname)
    mesh1.ViewObject.hide()
    sh=Part.Shape()
    sh.makeShapeFromMesh(mesh1.Mesh.Topology,0.1)
    solid = Part.Solid(sh)
    obj=doc.addObject('Part::Feature',"Mesh")
    #ImportObject(obj,mesh1) #This object is not mutable from the GUI
    #ViewProviderTree(obj.ViewObject)
    solid=solid.removeSplitter()
    if solid.Volume < 0:
        #sh.reverse()
        #sh = sh.copy()
        solid.complement()
    obj.Shape=solid#.removeSplitter()
    return(obj)
开发者ID:diljot,项目名称:FreeCAD-1,代码行数:24,代码来源:importCSG.py

示例6: addtofreecad

# 需要导入模块: import Mesh [as 别名]
# 或者: from Mesh import insert [as 别名]

#.........这里部分代码省略.........
                    plane=doc.addObject("Part::Plane",planename)
                    plane.Length=Node.planedim*2
                    plane.Width=Node.planedim*2
                    plane.Placement = FreeCAD.Placement(FreeCAD.Vector(\
                    -Node.planedim,-Node.planedim,0),FreeCAD.Rotation(0,0,0,1))
                #plane.ViewObject.hide()
                subobjs = [child.addtofreecad(doc,obj) for child in self.children]
                subobjs.append(plane)
                obj.Shapes = subobjs
                for subobj in subobjs:
                    subobj.ViewObject.hide()
            else:
                #Do a proper projection
                raise(NotImplementedError)
        elif namel == 'import':
            filename = self.arguments.get('file')
            scale = self.arguments.get('scale')
            origin = self.arguments.get('origin')
            if filename:
                import os
                docname=os.path.split(filename)[1]
                objname,extension = docname.split('.',1)
                if not os.path.isabs(filename):
                    try:
                        global lastimportpath
                        filename=os.path.join(lastimportpath,filename)
                    except:
                        raise #no path given
                # Check for a mesh fileformat support by the Mesh mddule
                if extension.lower() in reverseimporttypes()['Mesh']:
                    import Mesh
                    mesh1 = doc.getObject(objname) #reuse imported object
                    if not mesh1:
                        Mesh.insert(filename)
                        mesh1=doc.getObject(objname)
                    mesh1.ViewObject.hide()
                    sh=Part.Shape()
                    sh.makeShapeFromMesh(mesh1.Mesh.Topology,0.1)
                    solid = Part.Solid(sh)
                    obj=doc.addObject("Part::FeaturePython",'import_%s_%s'%(extension,objname))
                    #obj=doc.addObject('Part::Feature',)
                    ImportObject(obj,mesh1) #This object is not mutable from the GUI
                    ViewProviderTree(obj.ViewObject)
                    solid=solid.removeSplitter()
                    if solid.Volume < 0:
                        #sh.reverse()
                        #sh = sh.copy()
                        solid.complement()
                    obj.Shape=solid#.removeSplitter()
                elif extension in ['dxf']:
                    layera = self.arguments.get('layer')
                    featname='import_dxf_%s_%s'%(objname,layera)
                    # reusing an allready imported object does not work if the
                    #shape in not yet calculated
                    import importDXF
                    global dxfcache
                    layers=dxfcache.get(id(doc),[])
                    if layers:
                        try:
                            groupobj=[go for go in layers if (not layera) or go.Label == layera]
                        except:
                            groupobj= None
                    else:
                        groupobj= None
                    if not groupobj:
                        groupname=objname
开发者ID:MarcusWolschon,项目名称:FreeCAD_sf_master,代码行数:70,代码来源:prototype.py

示例7: proceed

# 需要导入模块: import Mesh [as 别名]
# 或者: from Mesh import insert [as 别名]
	def proceed(self):
		temp_file = tempfile.mkstemp(suffix='.step')[1]
		selection = FreeCADGui.Selection.getSelection()
		if not selection:
			QtGui.QMessageBox.critical(None, "GMSHMesh macro", "An object has to be selected to run gmsh!")
			return
		# Export a part in step format
		ImportGui.export(selection, temp_file)
		selection_name = selection[0].Name
		# Mesh temporaly file
		file_format = self.cmb_format.currentText()
		temp_mesh_file = os.path.join(tempfile.tempdir, selection_name + '_Mesh.' + file_format)
		# OPTIONS GMSH:
		clmax = self.sb_max_element_size.text()
		clmin = self.sb_min_element_size.text()
		cmd_line_opt = self.le_cmd_line_opt.text()
		algo = self.cmb_algorithm.currentText()
		mesh_order = self.sb_mesh_order.text()

		if self.cb_optimized.isChecked():
			cmd_optimize = ' -optimize'
		else:
			cmd_optimize = ''

		if self.rb_3D.isChecked():
			dim = ' -3 '
		if self.rb_2D.isChecked():
			dim = ' -2 '
		if self.rb_1D.isChecked():
			dim = ' -1 '
		if self.cb_max_elme_size.isChecked():
			max_size = ' -clmax ' + clmax
		else:
			max_size = ''
		if self.cb_min_elme_size.isChecked():
			min_size = ' -clmin ' + clmin
		else:
			min_size = ''
		if self.cb_mesh_order.isChecked():
			order = ' -order ' + mesh_order
		else:
			order = ''

		options = ' -algo ' + algo + max_size + min_size + cmd_optimize + order + cmd_line_opt
		# RUN GMSH
		command = gmsh_bin + ' ' + temp_file + dim + '-format ' + file_format + ' -o ' + temp_mesh_file  + '' + options
		FreeCAD.Console.PrintMessage("Running: \"{}\"\n".format(command))
		try:
			output = subprocess.check_output([command, '-1'], shell=True, stderr=subprocess.STDOUT,)
			for line in output.split('\n'):
				if "Error" in line:
					FreeCAD.Console.PrintError("{}\n".format(line))
				elif "Warning" in line:
					FreeCAD.Console.PrintWarning("{}\n".format(line))
			#FreeCAD.Console.PrintMessage("Output: \"{}\"\n".format(output))
			if file_format in ('unv', 'med'):
				Fem.insert(temp_mesh_file, FreeCAD.ActiveDocument.Name)
			if file_format == 'stl':
				Mesh.insert(temp_mesh_file, FreeCAD.ActiveDocument.Name)
			if file_format == 'msh':
				out_mesh_file = os.path.join(os.path.dirname(os.path.abspath(__file__)), "geometry.msh")
				shutil.move(temp_mesh_file, out_mesh_file)
				FreeCAD.Console.PrintMessage("Output file written to: {}\n".format(out_mesh_file))
			if self.cb_mec_anal.isChecked():
				FMesh = App.activeDocument().ActiveObject
				MechanicalAnalysis.makeMechanicalAnalysis('MechanicalAnalysis')
				FemGui.setActiveAnalysis(App.activeDocument().ActiveObject)
				App.activeDocument().ActiveObject.Member = App.activeDocument().ActiveObject.Member + [FMesh]
			if self.rb_1D.isChecked():
				FMeshG = Gui.ActiveDocument.ActiveObject
				FMeshG.DisplayMode = "Elements & Nodes"
		except:
			FreeCAD.Console.PrintError("Unexpected error in GMSHMesh macro: {} {}\n".format(sys.exc_info()[0], sys.exc_info()[1]))
		finally:
			try: del temp_file
			except: pass
			try: del temp_mesh_file
			except: pass
开发者ID:rwestenberger,项目名称:MicroMegas-Simulation,代码行数:80,代码来源:gmsh.py

示例8: import_mesh

# 需要导入模块: import Mesh [as 别名]
# 或者: from Mesh import insert [as 别名]
def import_mesh():
	doc = FreeCAD.newDocument()
	meshobj = doc.addObject("Mesh::Feature","New Mesh")
	mesh = Mesh.insert("/Users/jinyeom/2015-FRI-Summer-Research/t.stl")
	meshobj.Mesh = mesh
开发者ID:jinseokYeom,项目名称:2015-FRI-Summer-Research,代码行数:7,代码来源:3D_Decomposition.py


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