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


Python ImportGui.export方法代码示例

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


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

示例1: export

# 需要导入模块: import ImportGui [as 别名]
# 或者: from ImportGui import export [as 别名]
def export(objs,filename):
    """exporting to file folder"""
    
    #sayz(filename)
    sayz("stpZ version "+___stpZversion___)
    ext = os.path.splitext(os.path.basename(filename))[1]
    fname=os.path.splitext(os.path.basename(filename))[0]
    basepath=os.path.split(filename)[0]
    tempdir = tempfile.gettempdir() # get the current temporary directory
    
    filepath = os.path.join(basepath,fname) + u'.stp'
    filepath_base  = os.path.join(basepath,fname)
        
    namefpath = os.path.join(basepath,fname)
        
    outfpath = os.path.join(basepath,fname)+u'.stpZ'
    outfpath_stp = os.path.join(basepath,fname)+u'.stp'
    outfpath_base = basepath
    #outfpath_str = mkz_string(os.path.join(basepath,fname))
    outfpath_str = os.path.join(basepath,fname)
    
        
    if os.path.exists(outfpath_stp):
        sayzw("File cannot be compressed because a file with the same name exists '"+ outfpath_stp +"'")
        QtGui.QApplication.restoreOverrideCursor()
        reply = QtGui.QMessageBox.information(None,"info", "File cannot be compressed because\na file with the same name exists\n'"+ outfpath_stp + "'")
    else:    
        ImportGui.export(objs,outfpath_stp)
        if 0: #os.path.exists(namefpath):
            sayzw("File cannot be compressed because a file with the same name exists '" + namefpath + "'")
            QtGui.QApplication.restoreOverrideCursor()
            reply = QtGui.QMessageBox.information(None,"info", "File cannot be compressed because\na file with the same name exists\n'"+ namefpath+ "'")
        else:
            with six.builtins.open(outfpath_stp, 'rb') as f_in:
                file_content = f_in.read()
                new_f_content = file_content
                f_in.close()
            with gz.open(outfpath_str, 'wb') as f_out:
                f_out.write(new_f_content)
                f_out.close()    
            if os.path.exists(outfpath):
                os.remove(outfpath)
                os.rename(outfpath_str, outfpath)  
                os.remove(outfpath_stp)
            else:
                os.rename(outfpath_str, outfpath)
                os.remove(outfpath_stp)                
开发者ID:tomate44,项目名称:FreeCAD,代码行数:49,代码来源:stepZ.py

示例2: exportSTEP

# 需要导入模块: import ImportGui [as 别名]
# 或者: from ImportGui import export [as 别名]
def exportSTEP(doc,modelName, dir):

	## Export to STEP
	## Get cwd

	## outdir=os.path.dirname(os.path.realpath(__file__))+dir
	outdir=dir
	FreeCAD.Console.PrintMessage('\r\n'+outdir)
	StepFileName=outdir+'/'+modelName+'.step'
	objs=[]
	objs=GetListOfObjects(FreeCAD, doc)
	import ImportGui
	FreeCAD.Console.PrintMessage('\r\n'+StepFileName)
	# FreeCAD.Console.PrintMessage(objs)
	FreeCAD.Console.PrintMessage('\r\n'+outdir)
	ImportGui.export(objs,StepFileName)

	return 0
开发者ID:microelly2,项目名称:kicad-3d-models-in-freecad,代码行数:20,代码来源:cq_cad_tools.py

示例3: exportSTEP

# 需要导入模块: import ImportGui [as 别名]
# 或者: from ImportGui import export [as 别名]
def exportSTEP(doc,modelName, dir, objectToExport=None):

    ## Export to STEP
    ## Get cwd

    ## outdir=os.path.dirname(os.path.realpath(__file__))+dir
    outdir=dir
    FreeCAD.Console.PrintMessage('\r\n'+outdir)
    StepFileName=outdir+os.sep+modelName+'.step'
    objs=[]
    if objectToExport is None:
        objs=GetListOfObjects(FreeCAD, doc)
    else:
        objs.append(objectToExport)
    import ImportGui
    FreeCAD.Console.PrintMessage('\r\n'+StepFileName)
    # FreeCAD.Console.PrintMessage(objs)
    FreeCAD.Console.PrintMessage('\r\n'+outdir)
    ImportGui.export(objs,StepFileName)

    return 0
开发者ID:SchrodingersGat,项目名称:kicad-3d-models-in-freecad,代码行数:23,代码来源:cq_cad_tools.py

示例4: gmshmesh

# 需要导入模块: import ImportGui [as 别名]
# 或者: from ImportGui import export [as 别名]
def gmshmesh(compound, NG2D, name=""):
    '''
    export, mesh compound at gmsh, reimport as .unv
    (3d to be implemented)
    '''
    if name =="": name="m_"+compound.Label
    #
    ImportGui.export([FreeCAD.activeDocument().getObject(compound.Name)], "/tmp/tmpNO2c.step")
    #
    command="/usr/bin/gmsh /tmp/tmpNO2c.step -2 -format unv -o /tmp/"+name+".unv -algo "+str(NG2D.gmshalgoname)+" -clmax " +str(NG2D.NGParamSetMaxSize)+" -clmin "+str(NG2D.NGParamSetMinSize)+" -string Geometry.OCCSewFaces=1;"
    #command="/usr/bin/gmsh /tmp/tmpNO2c.step -2 -format unv -o /tmp/Compound019_Mesh.unv -algo auto -string Geometry.OCCSewFaces=1;"

    #command="g"
    #
    #print command
    output = subprocess.check_output([command, '-1'], shell=True, stderr=subprocess.STDOUT,)
    FreeCAD.Console.PrintMessage(output)
    #
    Fem.insert("/tmp/"+name+".unv", FreeCAD.ActiveDocument.Name)
    #Fem.insert("/tmp/Compound019_Mesh.unv", FreeCAD.ActiveDocument.Name)
    femmesh=FreeCAD.ActiveDocument.Objects[len(FreeCAD.ActiveDocument.Objects)-1]
    FreeCADGui.ActiveDocument.getObject(femmesh.Name).DisplayMode = "Wireframe"
    return femmesh
开发者ID:teobo,项目名称:heatbridge,代码行数:25,代码来源:pointtopostbk.py

示例5:

# 需要导入模块: import ImportGui [as 别名]
# 或者: from ImportGui import export [as 别名]
    myEx=App.ActiveDocument.addObject("Part::Extrusion","Extrude")
    myEx.Base = sk1
    myEx.Dir = (0,0,50)
    myEx.Solid = (True)
    myEx.TaperAngle = (0)
    myEx.Label = data[0]

    FreeCADGui.getDocument(App.ActiveDocument.Name).getObject("Extrude").LineColor = (0.0,0.0,0.0)
    FreeCADGui.getDocument(App.ActiveDocument.Name).getObject("Extrude").ShapeColor = (0.96,0.93,0.76)

    Gui.getDocument(App.ActiveDocument.Name).getObject("Sketch").Visibility=False
    App.ActiveDocument.recompute()
    Gui.SendMsgToActiveView("ViewFit")

    App.ActiveDocument.saveAs(directory+data[0]+'.FCStd')
    __objs__=[]
    __objs__.append(FreeCAD.getDocument(App.ActiveDocument.Name).getObject("Extrude"))
    ImportGui.export(__objs__,directory+data[0]+'.step')
    Mesh.export(__objs__,directory+data[0]+'.stl')
    del __objs__
    App.closeDocument(App.ActiveDocument.Name)

print 'End'

 

 
 

开发者ID:Peta-T,项目名称:FreeCAD-PartMacros,代码行数:25,代码来源:EN10056+Unequal+Angle+Bars.py

示例6: export

# 需要导入模块: import ImportGui [as 别名]
# 或者: from ImportGui import export [as 别名]
def export(ftype, componentName, componentModel, filename, fuse=False, scale=None):
    """ Exports given ComponentModel object using FreeCAD.

    `ftype` : one of "STEP", "VRML", "FREECAD", "X3D"
    `componentModel` : a ComponentModel instance
    `filename` : name of the file, extension is important
    `fuse` : fuse objects together before export (preserves color)
    `scale` : scales the model with this factor before exporting

    X3D exporter doesn't support `fuse` parameter.
    """
    objects = componentModel.parts

    if len(objects) < 1:
        raise Exception("ComponentModel is empty!")

    if len(objects) == 1: # can't fuse if there is only 1 object
        fuse = False

    # export to X3D or Simple VRML, continue for other exporters (VRML, FREECAD, STEP)
    if ftype in ["X3D", "S_VRML"]:
        if fuse: print("%s exporter can't do fuse, ignoring." % ftype)

        from export_x3d import exportX3D, Mesh
        from export_vrml import exportVRML

        meshes = [shapeToMesh(o[0].toFreecad(), o[1], scale) for o in objects]

        if ftype == "X3D":
            exportX3D(meshes, filename)
        else: # S_VRML
            exportVRML(meshes, filename)

        return

    # init FreeCADGui
    try:
        import ImportGui
    except ImportError:
        FreeCADGui.showMainWindow()
        FreeCADGui.getMainWindow().hide() # prevent splash of main window
        import ImportGui # must be after `showMainWindow`

    # make sure RefineShape=False
    pg = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Part/Boolean")
    usersRSOption = pg.GetBool("RefineModel") # will be restored, we promise
    pg.SetBool("RefineModel", False)

    # create a FreeCAD document
    doc = FreeCAD.newDocument()

    # create objects
    fcobjects = [makeFCObject(doc, componentName+"_"+co[2], co[0], co[1])
                 for co in objects]

    if fuse:
        fuseobj = doc.addObject("Part::MultiFuse", componentName)
        fuseobj.Shapes = fcobjects
        doc.recompute()
        exportObjects = [fuseobj]
    else:
        exportObjects = fcobjects

    if scale:
        import Draft
        v = FreeCAD.Vector(scale, scale, scale)
        vc = FreeCAD.Vector(0,0,0)
        # legacy=False, sometimes fail if scale < 1.0
        exportObjects = [Draft.scale(obj, delta=v, center=vc, legacy=True) for obj in exportObjects]

    doc.recompute()

    if ftype == "STEP":
        # check filename
        if not os.path.splitext(filename)[1] in ['.stp', '.step']:
            raise Exception("Filename for STEP export must end with '.stp' or '.step'.")
        ImportGui.export(exportObjects, filename)

    elif ftype == "VRML":
        # check filename
        if not os.path.splitext(filename)[1] in ['.wrl', '.vrml']:
            raise Exception("Filename for VRML export must end with '.wrl' or '.vrml'.")

        # workaround for not exporting unselected objects (v0.16)
        # http://www.freecadweb.org/tracker/view.php?id=2221
        FreeCADGui.Selection.clearSelection()
        for o in exportObjects: FreeCADGui.Selection.addSelection(o)

        # deal with points and lines
        for o in exportObjects: o.ViewObject.DisplayMode = "Shaded"

        FreeCADGui.export(exportObjects, filename)

    elif ftype == "FREECAD":
        for obj in list(doc.Objects):
            if not (obj in exportObjects): doc.removeObject(obj.Name)
        doc.saveAs(filename)

    else:
        raise Exception("Unknown export file type!")
#.........这里部分代码省略.........
开发者ID:hyOzd,项目名称:ecad-3d-model-generator,代码行数:103,代码来源:export.py

示例7: CreateTantalumCapacitor

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

#.........这里部分代码省略.........
    App.ActiveDocument.addObject("Part::Box",pin1MarkName)
    App.ActiveDocument.recompute()
    Gui.SendMsgToActiveView("ViewFit")
    FreeCAD.getDocument(newModelName).getObject(pin1MarkName).Length = Lamb
    FreeCAD.getDocument(newModelName).getObject(pin1MarkName).Width = W-(2*x)
    FreeCAD.getDocument(newModelName).getObject(pin1MarkName).Height = Hamb
    FreeCAD.getDocument(newModelName).getObject(pin1MarkName).Placement = App.Placement(App.Vector((-1*(Lb/2))+x+B,((-1*(W/2))+x),H),App.Rotation(0,0,0,1))



    ###################################################################
    # Wrap things up
    ###################################################################

    # Kill off various no-longer-needed objects
    App.getDocument(newModelName).removeObject("Pin1")
    App.getDocument(newModelName).removeObject("Pin2")
    App.getDocument(newModelName).removeObject("Cut")
    App.getDocument(newModelName).removeObject("Cut001")
    App.getDocument(newModelName).removeObject("Cut002")
    App.getDocument(newModelName).removeObject("Cut003")
    App.getDocument(newModelName).removeObject("Cut004")
    App.getDocument(newModelName).removeObject("Cut005")
    App.getDocument(newModelName).removeObject("Cut006")
    App.getDocument(newModelName).removeObject("Cut007")
    App.getDocument(newModelName).removeObject("Cut008")
    App.getDocument(newModelName).removeObject("Cut009")
    App.getDocument(newModelName).removeObject("Cut011")
    App.getDocument(newModelName).removeObject("Fusion")
    App.getDocument(newModelName).removeObject("Fusion001")
    App.getDocument(newModelName).removeObject("Box")
    App.getDocument(newModelName).removeObject("Box001")
    App.getDocument(newModelName).removeObject("Box002")
    App.getDocument(newModelName).removeObject("Box003")
    App.getDocument(newModelName).removeObject("Box004")
    App.getDocument(newModelName).removeObject("Box005")
    App.getDocument(newModelName).removeObject("Box006")
    App.getDocument(newModelName).removeObject("Box007")
    App.getDocument(newModelName).removeObject("Box008")
    App.getDocument(newModelName).removeObject("Box009")
    App.getDocument(newModelName).removeObject("Box010")
    App.getDocument(newModelName).removeObject("Box011")
    App.getDocument(newModelName).removeObject("Box012")
    App.getDocument(newModelName).removeObject("Box013")
    App.getDocument(newModelName).removeObject("Fillet")

    # If P parameter wasn't 0, clean up objects that were created
    if (P != 0) :

        App.getDocument(newModelName).removeObject("Box014")
        App.getDocument(newModelName).removeObject("Cut010")
        

    # Set view and zoom in
    Gui.activeDocument().activeView().viewFront()
    Gui.SendMsgToActiveView("ViewFit")
    #Gui.activateWorkbench("DraftWorkbench")

    # Color body yellow
    FreeCADGui.getDocument(newModelName).getObject(bodyName).ShapeColor = (0.89,0.96,0.33)

    # Color pins bright tin
    FreeCADGui.getDocument(newModelName).getObject(pinsName).ShapeColor = (0.80,0.80,0.75)

    # Color anode marker rust orange
    FreeCADGui.getDocument(newModelName).getObject(pin1MarkName).ShapeColor = (0.67,0.42,0.22)

    # Save to disk in native format
    App.ActiveDocument=None
    Gui.ActiveDocument=None
    App.setActiveDocument(newModelName)
    App.ActiveDocument=App.getDocument(newModelName)
    Gui.ActiveDocument=Gui.getDocument(newModelName)
    App.getDocument(newModelName).FileName = newModelPathNameExt
    App.getDocument(newModelName).Label = newModelName
    Gui.SendMsgToActiveView("Save")
    App.getDocument(newModelName).save()

    # Export to STEP
    App.ActiveDocument=None
    Gui.ActiveDocument=None
    App.setActiveDocument(newModelName)
    App.ActiveDocument=App.getDocument(newModelName)
    Gui.ActiveDocument=Gui.getDocument(newModelName)
    App.getDocument(newModelName).save()
    __objs__=[]
    __objs__.append(FreeCAD.getDocument(newModelName).getObject(bodyName))
    __objs__.append(FreeCAD.getDocument(newModelName).getObject(pinsName))
    __objs__.append(FreeCAD.getDocument(newModelName).getObject(pin1MarkName))
    import ImportGui
    ImportGui.export(__objs__,newStepPathNameExt)
    del __objs__

##    # Close all documents
###    App.closeDocument(newModelName)
###    App.setActiveDocument("")
###    App.ActiveDocument=None
###    Gui.ActiveDocument=None

    return 0
开发者ID:JimAshby,项目名称:scripts-libraries,代码行数:104,代码来源:tantalum_cap.py

示例8:

# 需要导入模块: import ImportGui [as 别名]
# 或者: from ImportGui import export [as 别名]
    App.ActiveDocument.recompute()
    sk2.addConstraint(Sketcher.Constraint("DistanceY", 4, 2, 0, 2, 1.750603))
    sk2.setDatum(18, App.Units.Quantity(str(data[10]) + " mm"))
    App.ActiveDocument.recompute()
    sk2.addConstraint(Sketcher.Constraint("Coincident", 6, 3, -1, 1))
    App.ActiveDocument.recompute()

    poc = App.activeDocument().addObject("PartDesign::Pocket", "Pocket")
    poc.Sketch = sk2
    poc.Length = data[10]
    poc.Label = name

    FreeCADGui.getDocument(App.ActiveDocument.Name).getObject("Pocket").LineColor = (0.0, 0.0, 0.0)
    FreeCADGui.getDocument(App.ActiveDocument.Name).getObject("Pocket").ShapeColor = (0.31, 0.73, 0.76)

    Gui.getDocument(App.ActiveDocument.Name).getObject("Sketch").Visibility = False
    Gui.getDocument(App.ActiveDocument.Name).getObject("Sketch001").Visibility = False
    Gui.getDocument(App.ActiveDocument.Name).getObject("Revolve").Visibility = False
    App.ActiveDocument.recompute()
    Gui.SendMsgToActiveView("ViewFit")

    App.ActiveDocument.saveAs(directory + name + ".FCStd")
    __objs__ = []
    __objs__.append(FreeCAD.getDocument(App.ActiveDocument.Name).getObject("Pocket"))
    ImportGui.export(__objs__, directory + name + ".step")
    Mesh.export(__objs__, directory + name + ".stl")
    del __objs__
    App.closeDocument(App.ActiveDocument.Name)

print "End"
开发者ID:Peta-T,项目名称:FreeCAD-PartMacros,代码行数:32,代码来源:ISO4762+Hexagon+socket+head+cap+screws.py

示例9: exportStep

# 需要导入模块: import ImportGui [as 别名]
# 或者: from ImportGui import export [as 别名]
def exportStep(objs, filename):
    ImportGui.export(objs,filename)
开发者ID:SchrodingersGat,项目名称:freecad-scripts,代码行数:4,代码来源:stepup.py

示例10: export

# 需要导入模块: import ImportGui [as 别名]
# 或者: from ImportGui import export [as 别名]
def export(variant, overwrite=False, saveFCStd=False, exportDXF=False):
    partPrefix = variant[:-4]
    partPostfix = variant[5:]
    pinCount = int(variant[5:7])

    srcName = srcDir+variant+'.stp'
    if not os.path.isfile(srcName):
        FreeCAD.Console.PrintMessage('missing ' + variant + '.stp\n')
        return

    if not os.path.exists(dstDir):
        os.makedirs(dstDir)

    bodyCutName = 'body-' + partPrefix + '#'

    bodyCut = None
    try:
        tmpl = App.getDocument(tmplName)
    except:
        tmpl = App.openDocument(tmplName+'.FCStd')
    for obj in tmpl.Objects:
        if obj.Label.startswith(bodyCutName):
            bodyCut = obj
            break

    if bodyCut == None:
        FreeCAD.Console.PrintMessage('missing template for ' + partPrefix + '\n')
        return

    FreeCAD.Console.PrintMessage('cehcking  ' + variant + '\n')

    names = [x for x in obj.Label.split('#')]
    pitch = float(names[2])
    dstName = dstDir+names[3]\
            .replace('%e',partPrefix)\
            .replace('%o',partPostfix)\
            .replace('%c','%02d'%pinCount)\
            .replace('%p','%.2f'%pitch)


    if os.path.isfile(dstName+'.stp'):
        if not overwrite:
            FreeCAD.Console.PrintMessage(dstName + ' already exists, skip!\n')
            return

    FreeCAD.Console.PrintMessage('exporting ' + dstName + '\n')

    newDoc = App.newDocument(variant+'_'+str(random.randrange(10000,99999)))
    guiDoc = Gui.getDocument(newDoc.Name)

    bodyCut = newDoc.copyObject(bodyCut,True)
    guiDoc.getObject(bodyCut.Name).Visibility = False;

    ImportGui.insert(srcName,newDoc.Name)

    objs = newDoc.getObjectsByLabel(bodyName)
    if not objs:
        FreeCAD.Console.PrintMessage('missing body for ' + partPrefix + '\n')
        return
    part = objs[0]
    guiDoc.getObject(part.Name).Visibility = False;

    objs = newDoc.getObjectsByLabel(fpName)
    if not objs:
        FreeCAD.Console.PrintMessage('missing footprint for ' + partPrefix + '\n')
        return
    footprint = objs[0]

    placement = bodyCut.Placement
    bodyCut.Placement = App.Placement()

    for obj in bodyCut.Shapes:
        # any better way to id array object?
        if 'ArrayType' in obj.PropertiesList:
            # TODO, we assum interval x sets the pitch, add more check later
            obj.IntervalX.x = pitch
            obj.NumberX = pinCount
            obj.Placement.Base.x -= (pinCount-2)*pitch/2
        else:
            for sobj in obj.Shapes:
                if sobj.TypeId == 'Part::Mirroring':
                    sobj.Source.Placement.Base.x -= (pinCount-2)*pitch/2

    newDoc.recompute()

    colors = []
    objs = []
    shapes = []

    def make_part(obj,isCut):
        names = [x for x in obj.Label.split('#')]
        newObj = newDoc.addObject("Part::Feature", names[0])
        if isCut:
            newObj.Shape = part.Shape.cut(obj.Shape).removeSplitter()
        else:
            newObj.Shape = part.Shape.common(obj.Shape).removeSplitter()
        color = names[1]
        if not color in shaderColors.named_colors:
            FreeCAD.Console.PrintWarning('unknown color : ' + color + '\n')
            color = None
#.........这里部分代码省略.........
开发者ID:realthunder,项目名称:molexGen,代码行数:103,代码来源:molexGen.py

示例11: export

# 需要导入模块: import ImportGui [as 别名]
# 或者: from ImportGui import export [as 别名]
def export(variant, fuse=False, overwrite=False, saveFCStd=False, exportDXF=False):
    partPrefix = variant[:-4]
    partPostfix = variant[5:]
    pinCount = int(variant[5:7])

    srcName = srcDir+variant+'.stp'
    if not os.path.isfile(srcName):
        FreeCAD.Console.PrintMessage('missing ' + variant + '.stp\n')
        return

    if not os.path.exists(dstDir):
        os.makedirs(dstDir)

    bodyCutName = 'body-' + partPrefix + '#'

    bodyCut = None
    try:
        tmpl = App.getDocument(libName)
    except:
        tmpl = App.openDocument(tmplDir+libName+'.FCStd')
    for obj in tmpl.Objects:
        if obj.Label.startswith(bodyCutName):
            bodyCut = obj
            break

    if bodyCut == None:
        FreeCAD.Console.PrintMessage('missing template for ' + partPrefix + '\n')
        return

    FreeCAD.Console.PrintMessage('cehcking  ' + variant + '\n')

    names = [x for x in obj.Label.split('#')]
    pitch = float(names[2])
    dstName = dstDir+names[3]\
            .replace('%e',partPrefix)\
            .replace('%o',partPostfix)\
            .replace('%c','%02d'%pinCount)\
            .replace('%p','%.2f'%pitch)

    settings = { 'align':'' }

    if len(names) > 4:
        for i in range(4,len(names)):
            if names[i] == '': continue
            option = [x for x in names[i].split(':')]
            if not option[0] in settings:
                FreeCAD.Console.PrintWarning('unknown setting : ' + option[0] + '\n')
            else:
                settings[option[0]] = option[1]

    if os.path.isfile(dstName+'.stp'):
        if not overwrite:
            FreeCAD.Console.PrintMessage(dstName + ' already exists, skip!\n')
            return

    FreeCAD.Console.PrintMessage('exporting ' + dstName + '\n')

    newDoc = App.newDocument(variant+'_'+str(random.randrange(10000,99999)))
    guiDoc = Gui.getDocument(newDoc.Name)

    bodyCut = newDoc.copyObject(bodyCut,True)
    FreeCAD.Console.PrintMessage(bodyCut.Name +  '\n')
    guiDoc.getObject(bodyCut.Name).Visibility = False;

    ImportGui.insert(srcName,newDoc.Name)

    objs = newDoc.getObjectsByLabel(bodyName)
    if not objs:
        FreeCAD.Console.PrintMessage('missing body for ' + partPrefix + '\n')
        return
    part = objs[0]
    guiDoc.getObject(part.Name).Visibility = False;

    objs = newDoc.getObjectsByLabel(fpName)
    if not objs:
        FreeCAD.Console.PrintMessage('missing footprint for ' + partPrefix + '\n')
        return
    footprint = objs[0]

    # NOTE!!! If we don't use Placement.copy here, we will be getting a surprise
    # from FreeCAD. Even if we reset the bodyCut.Placement below, whenever we change
    # the non-copied placement, bodyCut.Placement will get an update, too! Spooky!!
    # There seems to be some dangling internal reference bug here.
    placement = bodyCut.Placement.copy()
    bodyCut.Placement = App.Placement()

    offset = (pinCount-2)*pitch/2

    if settings['align'] == 'pin':
        placement.Base.x += offset

    footprint.Placement = placement.copy()

    for obj in bodyCut.Shapes:
        # any better way to id array object?
        if 'ArrayType' in obj.PropertiesList:
            # TODO, we assum interval x sets the pitch, add more check later
            obj.IntervalX.x = pitch
            obj.NumberX = pinCount
            obj.Placement.Base.x -= offset
#.........这里部分代码省略.........
开发者ID:realthunder,项目名称:kicad_3dgen,代码行数:103,代码来源:molex.py

示例12: proceed

# 需要导入模块: import ImportGui [as 别名]
# 或者: from ImportGui import export [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

示例13:

# 需要导入模块: import ImportGui [as 别名]
# 或者: from ImportGui import export [as 别名]
exp_objects = []
for obj in FreeCAD.ActiveDocument.Objects:
  # select all but indivudial Spheres and Sketch
  if (obj.Name.find("Pin") == -1) and (obj.Name.find("Sketch") == -1):
    Gui.Selection.addSelection(obj)
    exp_objects.append(obj)
  else:
    FreeCAD.ActiveDocument.removeObject(obj.Name)

App.activeDocument().addObject("Part::MultiFuse","Fusion2")
App.activeDocument().Fusion2.Shapes = exp_objects
App.ActiveDocument.recompute()
for obj in exp_objects:
    FreeCAD.ActiveDocument.removeObject(obj.Name) 
exp_objects= []

exp_objects.append(FreeCAD.ActiveDocument.getObject("Fusion2"))
ImportGui.export(exp_objects,os.path.join(directory, name + '.step'))
del exp_objects
# Scale to mil before export to VRML for KiCAD use
Draft.scale(FreeCAD.ActiveDocument.ActiveObject,
    FreeCAD.Vector(MMTOMIL, MMTOMIL, MMTOMIL))
FreeCAD.ActiveDocument.removeObject("Fusion2") 

### Export as a VRML model
exp_objects = []
exp_objects.append(FreeCAD.ActiveDocument.getObject("Scale"))
FreeCADGui.export(exp_objects,os.path.join(directory, name + '.wrl'))
del exp_objects
exit(1)
开发者ID:cybercircuits,项目名称:osrf_hw,代码行数:32,代码来源:freecad_gen_QFP_QFN.py


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