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


Python FreeCAD.setActiveDocument方法代碼示例

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


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

示例1: test_AA

# 需要導入模塊: import FreeCAD [as 別名]
# 或者: from FreeCAD import setActiveDocument [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 setActiveDocument [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: Activated

# 需要導入模塊: import FreeCAD [as 別名]
# 或者: from FreeCAD import setActiveDocument [as 別名]
def Activated(self):

        # check what we have selected
        selectedLink = self.checkSelection()
        if not selectedLink:
            return
        elif not selectedLink.TypeId=='App::Link':
            return
        linkedObj = selectedLink.LinkedObject

        # in case linking to a sub-object
        if isinstance(linkedObj, tuple):
            linkedObj = linkedObj[0].getSubObject(linkedObj[1], retType=1)
        
        # the non-magical command
        App.setActiveDocument(linkedObj.Document.Name)
        Gui.activateView('Gui::View3DInventor', True) 
開發者ID:Zolko-123,項目名稱:FreeCAD_Assembly4,代碼行數:19,代碼來源:gotoDocumentCmd.py

示例4: reset

# 需要導入模塊: import FreeCAD [as 別名]
# 或者: from FreeCAD import setActiveDocument [as 別名]
def reset():
    '''file laden und graph anzeigen testcase'''

    if 'aa' not in FreeCAD.listDocuments().keys():
        FreeCAD.open(u"/home/thomas/aa.FCStd")
    FreeCAD.setActiveDocument("aa")

    try:
        pfwrap.deleteInstance()
        del(FreeCAD.PF)
    except:
        pass
    instance=pfwrap.getInstance()
    clearGraph()
    loadGraph() 
開發者ID:microelly2,項目名稱:NodeEditor,代碼行數:17,代碼來源:Commands.py

示例5: loadFile

# 需要導入模塊: import FreeCAD [as 別名]
# 或者: from FreeCAD import setActiveDocument [as 別名]
def loadFile():

    hidePyFlow()
    if 'graph' not in FreeCAD.listDocuments().keys():
        FreeCAD.open(u"/home/thomas/graph.FCStd")
    FreeCAD.setActiveDocument("graph")
    clearGraph()
    loadGraph() 
開發者ID:microelly2,項目名稱:NodeEditor,代碼行數:10,代碼來源:Commands.py

示例6: loadAll

# 需要導入模塊: import FreeCAD [as 別名]
# 或者: from FreeCAD import setActiveDocument [as 別名]
def loadAll():
    showPyFlow()
    try:
        FreeCAD.getDocument(fn)
    except:
        FreeCAD.open(u"/home/thomas/{}.FCStd".format(fn))

    FreeCAD.setActiveDocument(fn)
    FreeCAD.ActiveDocument=FreeCAD.getDocument(fn)
    FreeCADGui.ActiveDocument=FreeCADGui.getDocument(fn)
    loadGraph()
    pass 
開發者ID:microelly2,項目名稱:NodeEditor,代碼行數:14,代碼來源:Commands.py

示例7: test_overlapping_parts

# 需要導入模塊: import FreeCAD [as 別名]
# 或者: from FreeCAD import setActiveDocument [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: get_data

# 需要導入模塊: import FreeCAD [as 別名]
# 或者: from FreeCAD import setActiveDocument [as 別名]
def get_data(self, data_name: str, scratch_dir: Optional[str] = None):
        """Get data from stored serial format.

        Parameters
        ----------
        data_name : str
            "fcdoc" freeCAD document.
        scratch_dir : str
            Optional existing temporary (fast) storage location. (Default value = None)
        mesh :
            (Default value = None)
        Returns
        -------
        data
        """
        if data_name == "fcdoc":

            def _load_fct(path):
                doc = FreeCAD.newDocument("instance")
                FreeCAD.setActiveDocument("instance")
                doc.load(path)
                return doc

            return load_serial(self.serial_fcdoc, _load_fct, scratch_dir=scratch_dir)
        else:
            raise ValueError(f"{data_name} was not a valid data_name.") 
開發者ID:microsoft,項目名稱:qmt,代碼行數:28,代碼來源:geo_3d_data.py

示例9: setUp

# 需要導入模塊: import FreeCAD [as 別名]
# 或者: from FreeCAD import setActiveDocument [as 別名]
def setUp(self):
		# setting a new document to hold the tests
		if FreeCAD.ActiveDocument:
			if FreeCAD.ActiveDocument.Name != "AnimTest":
				FreeCAD.newDocument("AnimTest")
		else:
			FreeCAD.newDocument("AnimTest")
		FreeCAD.setActiveDocument("AnimTest") 
開發者ID:microelly2,項目名稱:Animation,代碼行數:10,代碼來源:TestAnim.py


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