當前位置: 首頁>>代碼示例>>Python>>正文


Python FreeCAD.closeDocument方法代碼示例

本文整理匯總了Python中FreeCAD.closeDocument方法的典型用法代碼示例。如果您正苦於以下問題:Python FreeCAD.closeDocument方法的具體用法?Python FreeCAD.closeDocument怎麽用?Python FreeCAD.closeDocument使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在FreeCAD的用法示例。


在下文中一共展示了FreeCAD.closeDocument方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_AA

# 需要導入模塊: import FreeCAD [as 別名]
# 或者: from FreeCAD import closeDocument [as 別名]
def  test_AA():
    import FreeCAD
    import FreeCADGui
    App=FreeCAD
    Gui=FreeCADGui
    ### Begin command Std_RecentFiles
    try:
        App.closeDocument('Unnamed')
    except:
        pass
        App.setActiveDocument("")
        App.ActiveDocument=None
        Gui.ActiveDocument=None

    FreeCAD.open(u"/home/thomas/Schreibtisch/move_2.FCStd")
    App.setActiveDocument("move_2")
    App.ActiveDocument=App.getDocument("move_2")
    Gui.ActiveDocument=Gui.getDocument("move_2")
    ### End command Std_RecentFiles
    loadGraph() 
開發者ID:microelly2,項目名稱:NodeEditor,代碼行數:22,代碼來源:Commands.py

示例2: test_store_serial

# 需要導入模塊: import FreeCAD [as 別名]
# 或者: from FreeCAD import closeDocument [as 別名]
def test_store_serial(datadir, fix_FCDoc):
    """Test serialisation to memory."""
    import FreeCAD

    # Serialise document
    obj = fix_FCDoc.addObject("App::FeaturePython", "some_content")
    serial_data = store_serial(fix_FCDoc, lambda d, p: d.saveAs(p), "fcstd")

    # Write to a file
    file_path = os.path.join(datadir, "test.fcstd")

    data = codecs.decode(serial_data.encode(), "base64")
    with open(file_path, "wb") as of:
        of.write(data)

    # Load back and check
    doc = FreeCAD.newDocument("instance")
    FreeCAD.setActiveDocument("instance")
    doc.load(file_path)

    assert doc.getObject("some_content") is not None
    FreeCAD.closeDocument("instance") 
開發者ID:microsoft,項目名稱:qmt,代碼行數:24,代碼來源:test_data_data_utils.py

示例3: _test_file

# 需要導入模塊: import FreeCAD [as 別名]
# 或者: from FreeCAD import closeDocument [as 別名]
def _test_file( self, testFile_basename, solution = None ):
        testFile = os.path.join( test_assembly_path, testFile_basename + '.fcstd' )
        debugPrint(1, testFile_basename )
        stats.n_attempted += 1
        #if testFile == 'tests/testAssembly11-Pipe_assembly.fcstd':
        #    print('Skipping known fail')
        #    continue
        doc =  FreeCAD.open(testFile)
        t_start_solver = time.time()
        xOpt = solveConstraints( doc, solver_name = 'newton_solver_slsqp', use_cache = self.use_cache, showFailureErrorDialog=False )
        if solution:
            self.check_solution( xOpt, solution )
        stats.t_solver += time.time() - t_start_solver
        assert not self.use_cache
        if not xOpt is None:
            stats.n_solved += 1
        FreeCAD.closeDocument( doc.Name )
        debugPrint(1,'\n\n\n')
        return xOpt 
開發者ID:hamish2014,項目名稱:FreeCAD_assembly2,代碼行數:21,代碼來源:tests.py

示例4: shutdown

# 需要導入模塊: import FreeCAD [as 別名]
# 或者: from FreeCAD import closeDocument [as 別名]
def shutdown():
    '''fast stop of freecad test environ'''
    try:
        FreeCAD.closeDocument("Unnamed")
    except:
        pass
    try:
        FreeCAD.closeDocument("graph")
    except:
        pass

    FreeCADGui.runCommand("Std_Quit") 
開發者ID:microelly2,項目名稱:NodeEditor,代碼行數:14,代碼來源:Commands.py

示例5: Activated

# 需要導入模塊: import FreeCAD [as 別名]
# 或者: from FreeCAD import closeDocument [as 別名]
def Activated(self):
        doc = FreeCAD.activeDocument()
        try:
            doc.save()
            FreeCAD.closeDocument(doc.Name)
        except:
            FreeCADGui.SendMsgToActiveView("Save")
            if not FreeCADGui.activeDocument().Modified: # user really saved the file           
                FreeCAD.closeDocument(doc.Name)
        #
        mw = FreeCADGui.getMainWindow()
        mdi = mw.findChild(QtGui.QMdiArea)
        sub = mdi.activeSubWindow()
        if sub != None:
            sub.showMaximized() 
開發者ID:kbwbe,項目名稱:A2plus,代碼行數:17,代碼來源:a2p_importpart.py

示例6: fix_FCDoc

# 需要導入模塊: import FreeCAD [as 別名]
# 或者: from FreeCAD import closeDocument [as 別名]
def fix_FCDoc():
    """Set up and tear down a FreeCAD document."""
    import FreeCAD

    doc = FreeCAD.newDocument("testDoc")
    yield doc
    FreeCAD.closeDocument("testDoc")


################################################################################
# Sketches 
開發者ID:microsoft,項目名稱:qmt,代碼行數:13,代碼來源:conftest.py

示例7: test_overlapping_parts

# 需要導入模塊: import FreeCAD [as 別名]
# 或者: from FreeCAD import closeDocument [as 別名]
def test_overlapping_parts(datadir):
    """
    This tests that two parts that were generated from lithography over a wire register as intersecting. Due to
    an OCC bug, FC 0.18 at one point would claim that these didn't intersect, resulting in geometry and meshing errors.
    """
    path = os.path.join(datadir, "intersection_test.FCStd")
    doc = FreeCAD.newDocument("instance")
    FreeCAD.setActiveDocument("instance")
    doc.load(path)
    shape_1 = doc.Objects[0]
    shape_2 = doc.Objects[1]
    assert checkOverlap([shape_1, shape_2])
    FreeCAD.closeDocument(doc.Name) 
開發者ID:microsoft,項目名稱:qmt,代碼行數:15,代碼來源:test_geo_objects.py

示例8: _test_file

# 需要導入模塊: import FreeCAD [as 別名]
# 或者: from FreeCAD import closeDocument [as 別名]
def _test_file( self, testFile_basename, solution = None ):
        testFile = os.path.join( test_assembly_path, testFile_basename + '.fcstd' )
        debugPrint(1, testFile_basename )
        stats.n_attempted += 1
        #if testFile == 'tests/testAssembly11-Pipe_assembly.fcstd':
        #    print('Skipping known fail')
        #    continue
        doc =  FreeCAD.open(testFile)
        t_start_solver = time.time()
        constraintSystem = solveConstraints( doc, solver_name = 'dof_reduction_solver', use_cache = self.use_cache, showFailureErrorDialog=False )
        if solution:
            self.check_solution( constraintSystem, solution )
        stats.t_solver += time.time() - t_start_solver
        if  self.use_cache:
            debugPrint(1,'\n\n')
            X_org = constraintSystem.variableManager.X
            t_start_cache = time.time()
            #cache.debugMode = 1
            constraintSystem = solveConstraints( doc, solver_name = 'dof_reduction_solver', use_cache =  self.use_cache )
            self.assertTrue(
                numpy.allclose( X_org , constraintSystem.variableManager.X ),
                'Cache solution differs from originial solution: %s != %s' % ( X_org , constraintSystem.variableManager.X )
            )
            #cache.debugMode = 0
            stats.t_cache += time.time() - t_start_cache
            constraintSystem.update()
        stats.n_solved += 1
        FreeCAD.closeDocument( doc.Name )
        debugPrint(1,'\n\n\n') 
開發者ID:hamish2014,項目名稱:FreeCAD_assembly2,代碼行數:31,代碼來源:tests.py

示例9: Activated

# 需要導入模塊: import FreeCAD [as 別名]
# 或者: from FreeCAD import closeDocument [as 別名]
def Activated(self):
        # So we can open the save-as dialog
        mw = FreeCADGui.getMainWindow()
        cqCodePane = Shared.getActiveCodePane()

        if cqCodePane == None:
            FreeCAD.Console.PrintError("Nothing to save.\r\n")
            return

        # Try to keep track of the previous path used to open as a convenience to the user
        if self.previousPath is None:
            self.previousPath = "/home/"

        filename = QtGui.QFileDialog.getSaveFileName(mw, mw.tr("Save CadQuery Script As"), self.previousPath,
                                                     mw.tr("CadQuery Files (*.py)"))

        self.previousPath = filename[0]

        # Make sure the user didn't click cancel
        if filename[0]:
            # Close the 3D view for the original script if it's open
            try:
                docname = os.path.splitext(os.path.basename(cqCodePane.get_path()))[0]
                FreeCAD.closeDocument(docname)
            except:
                # Assume that there was no 3D view to close
                pass

            # Change the name of our script window's tab
            Shared.setActiveWindowTitle(os.path.basename(filename[0]))

            # Save the file before closing the original and the re-rendering the new one
            ExportCQ.save(filename[0])
            CadQueryExecuteScript().Activated() 
開發者ID:jmwright,項目名稱:cadquery-freecad-module,代碼行數:36,代碼來源:Command.py

示例10: tearDown

# 需要導入模塊: import FreeCAD [as 別名]
# 或者: from FreeCAD import closeDocument [as 別名]
def tearDown(self):
		FreeCAD.closeDocument("AnimTest")
		pass 
開發者ID:microelly2,項目名稱:Animation,代碼行數:5,代碼來源:TestAnim.py

示例11: close_CQ_Example

# 需要導入模塊: import FreeCAD [as 別名]
# 或者: from FreeCAD import closeDocument [as 別名]
def close_CQ_Example(App, Gui):

    #close the example
    App.setActiveDocument("Ex000_Introduction")
    App.ActiveDocument=App.getDocument("Ex000_Introduction")
    Gui.ActiveDocument=Gui.getDocument("Ex000_Introduction")
    App.closeDocument("Ex000_Introduction")
    FreeCAD.Console.PrintMessage('\r\nEx000 Closed\r\n')

    #Getting the main window will allow us to start setting things up the way we want
    mw = FreeCADGui.getMainWindow()

    #Adjust the docks as usual
    dockWidgets = mw.findChildren(QtGui.QDockWidget)
    for widget in dockWidgets:
        if (widget.objectName() == "Report view") or (widget.objectName() == "Python console") or (widget.objectName() == "Combo View"):
            widget.setVisible(True)
        if (widget.objectName()=="cqCodeView"):
            widget.setVisible(False)
    FreeCAD.Console.PrintMessage('Dock adjusted\r\n')

    return 0


###################################################################
# FuseObjs_wColors()  maui
#   Function to fuse two objects together.
################################################################### 
開發者ID:easyw,項目名稱:kicad-3d-models-in-freecad,代碼行數:30,代碼來源:cq_cad_tools.py


注:本文中的FreeCAD.closeDocument方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。