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


Python ImportGui.open方法代码示例

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


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

示例1: open

# 需要导入模块: import ImportGui [as 别名]
# 或者: from ImportGui import open [as 别名]
def open(filename):

    sayz("stpZ version "+___stpZversion___)
    with gzip_utf8.open(filename, 'rb') as f:
        file_content = f.read()

    ext = os.path.splitext(os.path.basename(filename))[1]
    fname=os.path.splitext(os.path.basename(filename))[0]
    basepath=os.path.split(filename)[0]
    filepath = os.path.join(basepath,fname + u'.stp')

    tempdir = tempfile.gettempdir() # get the current temporary directory
    tempfilepath = os.path.join(tempdir,fname + u'.stp')

    with builtin.open(tempfilepath, 'w') as f: #py3
        f.write(file_content)
    #ImportGui.insert(filepath)
    ImportGui.open(tempfilepath)
    try:
        os.remove(tempfilepath)
    except OSError:
        sayzerr("error on removing "+tempfilepath+" file")
        pass
开发者ID:AjinkyaDahale,项目名称:FreeCAD,代码行数:25,代码来源:stepZ.py

示例2: exit

# 需要导入模块: import ImportGui [as 别名]
# 或者: from ImportGui import open [as 别名]
# Set the directory variable before running

import FreeCAD
import ImportGui
import FreeCADGui
import os

# directory = "/home/mikael/kicad_ws/osrf_hw/kicad_3dmodels/BGA"
directory = os.getcwd()
print directory
if not os.path.isdir(directory):
    print "ERROR directory " + directory + " doesn't exist"
    exit(1)
for root, subdirs, files in os.walk(directory):
    for filename in files:
        if filename.lower().endswith(".stp") or filename.lower().endswith(".step"):
            file_path = os.path.join(root, filename)
            ImportGui.open(file_path)
            wrlname = file_path[0 : file_path.rfind(file_path[file_path.rfind(".") :])] + ".wrl"
            Gui.export(App.ActiveDocument.findObjects("Part::Feature"), wrlname)
            App.closeDocument(App.ActiveDocument.Name)

exit(1)
开发者ID:osrf,项目名称:osrf_hw,代码行数:25,代码来源:freecadconvert.py

示例3: saveFCdoc

# 需要导入模块: import ImportGui [as 别名]
# 或者: from ImportGui import open [as 别名]
            Gui.SendMsgToActiveView("ViewFit")
            Gui.activeDocument().activeView().viewAxometric()

        # Save the doc in Native FC format
        saveFCdoc(App, Gui, doc, ModelName,out_dir, False)


        check_Model=False
        if save_memory == True or check_Model==True:
            doc=FreeCAD.ActiveDocument
            FreeCAD.closeDocument(doc.Name)

        step_path=os.path.join(out_dir,ModelName+u'.step')
        if check_Model==True:
            #ImportGui.insert(step_path,ModelName)
            ImportGui.open(step_path)
            docu = FreeCAD.ActiveDocument
            if cq_cad_tools.checkUnion(docu) == True:
                FreeCAD.Console.PrintMessage('step file is correctly Unioned\n')
            else:
                FreeCAD.Console.PrintError('step file is NOT Unioned\n')
                stop
            FC_majorV=int(FreeCAD.Version()[0])
            FC_minorV=int(FreeCAD.Version()[1])
            if FC_majorV == 0 and FC_minorV >= 17:
                for o in docu.Objects:
                    if hasattr(o,'Shape'):
                        chks=cq_cad_tools.checkBOP(o.Shape)
                        print 'chks ',chks
                        print cq_cad_tools.mk_string(o.Label)
                        if chks != True:
开发者ID:poeschlr,项目名称:kicad-3d-models-in-freecad,代码行数:33,代码来源:main_generator.py

示例4: runGeometryCheck

# 需要导入模块: import ImportGui [as 别名]
# 或者: from ImportGui import open [as 别名]
def runGeometryCheck(App, Gui, step_path, log,
        modelName, save_memory=True, stop_on_first_error = True):

    FC_majorV=int(FreeCAD.Version()[0])
    FC_minorV=int(FreeCAD.Version()[1])
    try:
        FC_subV=int(FreeCAD.Version()[2].split(" ")[0])
    except Exception:
        FC_subV = 0

    if FC_majorV == 0 and FC_minorV == 16 and FC_subV < 6712:
        raise FreeCADVersionError('0.16-6712', 'old 0.16 releases have a bug in the step exporter.')

    geometry_error_container = GeometryError()

    ImportGui.open(step_path)
    docu = FreeCAD.ActiveDocument
    docu.Label = modelName
    log.write('\n## Checking {:s}\n'.format(modelName))


    if checkUnion(docu):
        FreeCAD.Console.PrintMessage('step file is correctly Unioned\n')
        log.write('\t- Union check:    [    pass    ]\n')
    else:
        #FreeCAD.Console.PrintError('step file is NOT Unioned\n')
        log.write('\t- Union check:    [    FAIL    ]\n')
        geometry_error_container.append(NotUnionedError(modelName))
        #stop
    if FC_majorV == 0 and FC_minorV >= 17:
        if docu.Objects == 0:
            FreeCAD.Console.PrintError('Step import seems to fail. No objects to check\n')
        for o in docu.Objects:
            if hasattr(o,'Shape'):
                o.Shape.fixTolerance(1e-4)
                chks=checkBOP(o.Shape)
                #print 'chks ',chks
                if chks != True:
                    #msg='shape \''+o.Name+'\' \''+ mk_string(o.Label)+'\' is INVALID!\n'
                    msg = 'shape "{name:s}" "{label:s}" is INVALID\n'.format(name=o.Name, label=o.Label)
                    #FreeCAD.Console.PrintError(msg)
                    #FreeCAD.Console.PrintWarning(chks[0])
                    geometry_error_container.append(BOBError(modelName, o.Name, o.Label, chks[0]))
                    log.write('\t- Geometry check: [    FAIL    ]\n')
                    log.write('\t\t- Effected shape: "{name:s}" "{label:s}"\n'.format(name=o.Name, label=o.Label))
                    #stop
                else:
                    #msg='shape \''+o.Name+'\' \''+ mk_string(o.Label)+'\' is valid\n'
                    msg = 'shape "{name:s}" "{label:s}" is valid\n'.format(name=o.Name, label=o.Label)
                    FreeCAD.Console.PrintMessage(msg)
                    log.write('\t- Geometry check: [    pass    ]\n')
    else:
        log.write('\t- Geometry check: [  skipped   ]\n')
        log.write('\t\t- Geometry check needs FC 0.17+\n')
        raise FreeCADVersionError('0.17', 'Geometry check needs FC 0.17')

    if stop_on_first_error and geometry_error_container.error_encountered:
        raise geometry_error_container

    if save_memory == True:
        saveFCdoc(App, Gui, docu, 'temp', './', False)
        docu = FreeCAD.ActiveDocument
        FreeCAD.closeDocument(docu.Name)

    if geometry_error_container.error_encountered:
        raise geometry_error_container
开发者ID:poeschlr,项目名称:kicad-3d-models-in-freecad,代码行数:68,代码来源:cq_cad_tools.py

示例5: MakeHeader

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

#.........这里部分代码省略.........
    objs=GetListOfObjects(FreeCAD, doc)
    
    Color_Objects(Gui,objs[0],body_color)
    Color_Objects(Gui,objs[1],pins_color)
    #Color_Objects(Gui,objs[2],marking_color)

    col_body=Gui.ActiveDocument.getObject(objs[0].Name).DiffuseColor[0]
    col_pin=Gui.ActiveDocument.getObject(objs[1].Name).DiffuseColor[0]
    #col_mark=Gui.ActiveDocument.getObject(objs[2].Name).DiffuseColor[0]
    material_substitutions={
        col_body[:-1]:body_color_key,
        col_pin[:-1]:pins_color_key,
        #col_mark[:-1]:marking_color_key
    }
    expVRML.say(material_substitutions)

    #objs=GetListOfObjects(FreeCAD, doc)
    FuseObjs_wColors(FreeCAD, FreeCADGui,
                   doc.Name, objs[0].Name, objs[1].Name)
    doc.Label=CheckedModelName
    objs=GetListOfObjects(FreeCAD, doc)
    objs[0].Label=CheckedModelName
    restore_Main_Tools()

    if (rotation !=0):
        z_RotateObject(doc, rotation)
    
    #out_dir = models_dir+"/generated_pinheaders"
    
    doc.Label = CheckedModelName
    
    #save the STEP file
    exportSTEP(doc, ModelName, out_dir)
    if LIST_license[0]=="":
        LIST_license=Lic.LIST_int_license
        LIST_license.append("")
    Lic.addLicenseToStep(out_dir+'/', ModelName+".step", LIST_license,\
                       STR_licAuthor, STR_licEmail, STR_licOrgSys, STR_licOrg, STR_licPreProc)
    
    # scale and export Vrml model
    scale=1/2.54
    #exportVRML(doc,ModelName,scale,out_dir)
    objs=GetListOfObjects(FreeCAD, doc)
    expVRML.say("######################################################################")
    expVRML.say(objs)
    expVRML.say("######################################################################")
    export_objects, used_color_keys = expVRML.determineColors(Gui, objs, material_substitutions)
    export_file_name=out_dir+os.sep+ModelName+'.wrl'
    colored_meshes = expVRML.getColoredMesh(Gui, export_objects , scale)
    expVRML.writeVRMLFile(colored_meshes, export_file_name, used_color_keys, LIST_license)

    #save the VRML file
    #scale=0.3937001
    #exportVRML(doc,name,scale,out_dir)
    
    if save_memory == False:
        Gui.SendMsgToActiveView("ViewFit")
        Gui.activeDocument().activeView().viewAxometric()

    # Save the doc in Native FC format 
    saveFCdoc(App, Gui, doc, ModelName, out_dir, False) 
    
    check_Model=True
    if save_memory == True or check_Model==True:
        doc=FreeCAD.ActiveDocument
        FreeCAD.closeDocument(doc.Name)
    step_path=os.path.join(out_dir,ModelName+u'.step')
    if check_Model==True:
        #ImportGui.insert(step_path,ModelName)
        ImportGui.open(step_path)
        docu = FreeCAD.ActiveDocument
        if cq_cad_tools.checkUnion(docu) == True:
            FreeCAD.Console.PrintMessage('step file is correctly Unioned\n')
        else:
            FreeCAD.Console.PrintError('step file is NOT Unioned\n')
            stop
        FC_majorV=int(FreeCAD.Version()[0])
        FC_minorV=int(FreeCAD.Version()[1])
        if FC_majorV == 0 and FC_minorV >= 17:
            for o in docu.Objects:
                if hasattr(o,'Shape'):
                    chks=cq_cad_tools.checkBOP(o.Shape)
                    print 'chks ',chks
                    print cq_cad_tools.mk_string(o.Label)
                    if chks != True:
                        msg='shape \''+o.Name+'\' \''+cq_cad_tools.mk_string(o.Label)+'\' is INVALID!\n'
                        FreeCAD.Console.PrintError(msg)
                        FreeCAD.Console.PrintWarning(chks[0])
                        stop
                    else:
                        msg='shape \''+o.Name+'\' \''+cq_cad_tools.mk_string(o.Label)+'\' is valid\n'
                        FreeCAD.Console.PrintMessage(msg)
        else:
            FreeCAD.Console.PrintError('BOP check requires FC 0.17+\n')
            # Save the doc in Native FC format
        saveFCdoc(App, Gui, docu, ModelName,out_dir, False)
        doc=FreeCAD.ActiveDocument
        FreeCAD.closeDocument(doc.Name)
        
    return 0
开发者ID:poeschlr,项目名称:kicad-3d-models-in-freecad,代码行数:104,代码来源:main_generator.py


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