Python FreeCAD.setActiveDocument() Examples
The following are 9
code examples of FreeCAD.setActiveDocument().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
FreeCAD
, or try the search function
.
Example #1
Source File: Commands.py From NodeEditor with MIT License | 6 votes |
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()
Example #2
Source File: test_data_data_utils.py From qmt with MIT License | 6 votes |
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")
Example #3
Source File: gotoDocumentCmd.py From FreeCAD_Assembly4 with GNU Lesser General Public License v2.1 | 6 votes |
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)
Example #4
Source File: Commands.py From NodeEditor with MIT License | 5 votes |
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()
Example #5
Source File: Commands.py From NodeEditor with MIT License | 5 votes |
def loadFile(): hidePyFlow() if 'graph' not in FreeCAD.listDocuments().keys(): FreeCAD.open(u"/home/thomas/graph.FCStd") FreeCAD.setActiveDocument("graph") clearGraph() loadGraph()
Example #6
Source File: Commands.py From NodeEditor with MIT License | 5 votes |
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
Example #7
Source File: test_geo_objects.py From qmt with MIT License | 5 votes |
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)
Example #8
Source File: geo_3d_data.py From qmt with MIT License | 5 votes |
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.")
Example #9
Source File: TestAnim.py From Animation with GNU General Public License v2.0 | 5 votes |
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")