def doubleClicked(self, vobj): if not FemGui.getActiveAnalysis() == self.Object: if FreeCADGui.activeWorkbench().name() != 'CfdWorkbench': FreeCADGui.activateWorkbench("CfdWorkbench") FemGui.setActiveAnalysis(self.Object) return True return True
def testHandler(self): import __main__ class UnitWorkbench(__main__.Workbench): MenuText = "Unittest" ToolTip = "Unittest" def Initialize(self): cmds = ["Test_Test"] self.appendToolbar("My Unittest", cmds) def GetClassName(self): return "Gui::PythonWorkbench" FreeCADGui.addWorkbench(UnitWorkbench()) wbs = FreeCADGui.listWorkbenches() self.failUnless("UnitWorkbench" in wbs, "Test on adding workbench handler failed") FreeCADGui.activateWorkbench("UnitWorkbench") FreeCADGui.updateGui() self.failUnless(FreeCADGui.activeWorkbench().name() == "UnitWorkbench", "Test on loading workbench 'Unittest' failed") FreeCADGui.removeWorkbench("UnitWorkbench") wbs = FreeCADGui.listWorkbenches() self.failUnless(not "UnitWorkbench" in wbs, "Test on removing workbench handler failed")
def prepare_dsph_case(): """ Creates a few objects and setups a new case for DesignSPHysics. """ FreeCAD.setActiveDocument(SINGLETON_DOCUMENT_NAME) FreeCAD.ActiveDocument = FreeCAD.ActiveDocument FreeCADGui.ActiveDocument = FreeCADGui.ActiveDocument FreeCADGui.activateWorkbench(DEFAULT_WORKBENCH) FreeCADGui.activeDocument().activeView().viewAxonometric() FreeCAD.ActiveDocument.addObject(FreeCADObjectType.BOX, CASE_LIMITS_OBJ_NAME) FreeCAD.ActiveDocument.getObject( CASE_LIMITS_OBJ_NAME).Label = CASE_LIMITS_3D_LABEL FreeCAD.ActiveDocument.getObject( CASE_LIMITS_OBJ_NAME).Length = CASE_LIMITS_DEFAULT_LENGTH FreeCAD.ActiveDocument.getObject( CASE_LIMITS_OBJ_NAME).Width = CASE_LIMITS_DEFAULT_LENGTH FreeCAD.ActiveDocument.getObject( CASE_LIMITS_OBJ_NAME).Height = CASE_LIMITS_DEFAULT_LENGTH FreeCADGui.ActiveDocument.getObject( CASE_LIMITS_OBJ_NAME).DisplayMode = FreeCADDisplayMode.WIREFRAME FreeCADGui.ActiveDocument.getObject( CASE_LIMITS_OBJ_NAME).LineColor = CASE_LIMITS_LINE_COLOR FreeCADGui.ActiveDocument.getObject( CASE_LIMITS_OBJ_NAME).LineWidth = CASE_LIMITS_LINE_WIDTH FreeCADGui.ActiveDocument.getObject( CASE_LIMITS_OBJ_NAME).Selectable = False FreeCAD.ActiveDocument.recompute() FreeCADGui.SendMsgToActiveView("ViewFit")
def Activated(self): import PythonQt from PyQt4 import QtGui mw=QtGui.qApp.activeWindow() QtGui.QMessageBox.information(mw,"PyQt","""PyQt was loaded successfully.\n Load the PyQt sandbox now...""") FreeCADGui.activateWorkbench("PythonQtWorkbench")
def postStart(): "executes needed operations after loading a file" param = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Start") # switch workbench wb = param.GetString("AutoloadModule", "") if wb: # don't switch workbenches if we are not in Start anymore if FreeCADGui.activeWorkbench() and ( FreeCADGui.activeWorkbench().name() == "StartWorkbench"): FreeCADGui.activateWorkbench(wb) # close start tab cl = param.GetBool("closeStart", False) if cl: title = QtGui.QApplication.translate("Workbench", "Start page") mw = FreeCADGui.getMainWindow() if mw: mdi = mw.findChild(QtGui.QMdiArea) if mdi: for mdichild in mdi.children(): for subw in mdichild.findChildren(QtGui.QMdiSubWindow): if subw.windowTitle() == title: subw.close()
def Activated(self): sel = FreeCADGui.Selection.getSelectionEx() if sel: obj = sel[0].Object if Draft.getType(obj) == "Structure": if len(sel) > 1: sk = sel[1].Object if hasattr(sk, 'Shape'): if len(sk.Shape.Wires) == 1: # we have a structure and a wire: create the rebar now FreeCAD.ActiveDocument.openTransaction( translate("Arch", "Create Rebar")) FreeCADGui.addModule("Arch") FreeCADGui.doCommand( "Arch.makeRebar(FreeCAD.ActiveDocument." + obj.Name + ",FreeCAD.ActiveDocument." + sk.Name + ")") FreeCAD.ActiveDocument.commitTransaction() FreeCAD.ActiveDocument.recompute() return else: # we have only a structure: open the sketcher FreeCADGui.activateWorkbench("SketcherWorkbench") FreeCADGui.runCommand("Sketcher_NewSketch") FreeCAD.ArchObserver = ArchComponent.ArchSelectionObserver( obj, FreeCAD.ActiveDocument.Objects[-1], hide=False, nextCommand="Arch_Rebar") FreeCADGui.Selection.addObserver(FreeCAD.ArchObserver) return elif hasattr(obj, 'Shape'): if len(obj.Shape.Wires) == 1: # we have only a wire: extract its support object, if available, and make the rebar support = "None" if hasattr(obj, "Support"): if obj.Support: if len(obj.Support) != 0: support = "FreeCAD.ActiveDocument." + obj.Support[ 0][0].Name FreeCAD.ActiveDocument.openTransaction( translate("Arch", "Create Rebar")) FreeCADGui.addModule("Arch") FreeCADGui.doCommand("Arch.makeRebar(" + support + ",FreeCAD.ActiveDocument." + obj.Name + ")") FreeCAD.ActiveDocument.commitTransaction() FreeCAD.ActiveDocument.recompute() return FreeCAD.Console.PrintMessage( translate("Arch", "Please select a base face on a structural object") + "\n") FreeCADGui.Control.closeDialog() FreeCADGui.Control.showDialog(ArchComponent.SelectionTaskPanel()) FreeCAD.ArchObserver = ArchComponent.ArchSelectionObserver( nextCommand="Arch_Rebar") FreeCADGui.Selection.addObserver(FreeCAD.ArchObserver)
def Activated(self): sel = FreeCADGui.Selection.getSelection() if sel: if Draft.getType(sel[0]) == "Wall": FreeCADGui.activateWorkbench("SketcherWorkbench") FreeCADGui.runCommand("Sketcher_NewSketch") FreeCAD.ArchObserver = ArchComponent.ArchSelectionObserver(sel[0],FreeCAD.ActiveDocument.Objects[-1],hide=False,nextCommand="Arch_Window") FreeCADGui.Selection.addObserver(FreeCAD.ArchObserver) else: FreeCAD.ActiveDocument.openTransaction(str(translate("Arch","Create Window"))) FreeCADGui.doCommand("import Arch") for obj in sel: FreeCADGui.doCommand("Arch.makeWindow(FreeCAD.ActiveDocument."+obj.Name+")") if hasattr(obj,"Support"): if obj.Support: if isinstance(obj.Support,tuple): s = obj.Support[0] else: s = obj.Support w = FreeCAD.ActiveDocument.Objects[-1] # last created object FreeCADGui.doCommand("Arch.removeComponents(FreeCAD.ActiveDocument."+w.Name+",host=FreeCAD.ActiveDocument."+s.Name+")") elif Draft.isClone(obj,"Window"): if obj.Objects[0].Inlist: FreeCADGui.doCommand("Arch.removeComponents(FreeCAD.ActiveDocument."+obj.Name+",host=FreeCAD.ActiveDocument."+obj.Objects[0].Inlist[0].Name+")") FreeCAD.ActiveDocument.commitTransaction()
def selectWorkbench(self): Defaults = ['File', 'Workbench', 'Macro', 'View', 'Structure'] index = self._tabBar.currentIndex() tabName = self._tabBar.tabText(index) if tabName == 'FreeCAD': return FreeCADGui.activateWorkbench(self.actions[tabName]) workbench = FreeCADGui.activeWorkbench() for tbb in mw.findChildren(QtWidgets.QToolBar): tbb.hide() if self.Enabled[tabName]: return tab = self._tabs[index] for toolbar in workbench.listToolbars(): if toolbar in Defaults: continue section = tab.addSection(toolbar) TB = mw.findChildren(QtWidgets.QToolBar, toolbar) for button in TB[0].findChildren(QtWidgets.QToolButton): if button.text() == '': continue section.addButton(full=False, icon=button.icon(), title=button.text() + ' ', handler=button.defaultAction().triggered, shortcut=button.shortcut(), statusTip=button.statusTip(), menu=button.menu()) self.Enabled[tabName] = True
def doubleClicked(self, vobj): if FreeCADGui.activeWorkbench().name() != 'CfdWorkbench': FreeCADGui.activateWorkbench("CfdWorkbench") doc = FreeCADGui.getDocument(vobj.Object.Document) # it should be possible to find the AnalysisObject although it is not a documentObjectGroup if not FemGui.getActiveAnalysis(): analysis_obj = CfdTools.getParentAnalysisObject(self.Object) if analysis_obj: FemGui.setActiveAnalysis(analysis_obj) else: FreeCAD.Console.PrintError( 'No Active Analysis is detected from solver object in the active Document!\n' ) if not doc.getInEdit(): if FemGui.getActiveAnalysis().Document is FreeCAD.ActiveDocument: if self.Object in FemGui.getActiveAnalysis().Group: doc.setEdit(vobj.Object.Name) else: FreeCAD.Console.PrintError( 'Activate the analysis this solver belongs to!\n') else: FreeCAD.Console.PrintError( 'Active Analysis is not in active Document!\n') else: FreeCAD.Console.PrintError( 'Active Task Dialog found! Please close this one first!\n') return True
def Activated(self): sel = FreeCADGui.Selection.getSelectionEx() if sel: obj = sel[0].Object if Draft.getType(obj) == "Structure": if len(sel) > 1: sk = sel[1].Object if Draft.getType(sk) == "Sketch": # we have a base object and a sketch: create the rebar now FreeCAD.ActiveDocument.openTransaction( translate("Arch", "Create Rebar")) FreeCADGui.addModule("Arch") FreeCADGui.doCommand( "Arch.makeRebar(FreeCAD.ActiveDocument." + obj.Name + ",FreeCAD.ActiveDocument." + sk.Name + ")") FreeCAD.ActiveDocument.commitTransaction() FreeCAD.ActiveDocument.recompute() return else: # we have only a base object: open the sketcher FreeCADGui.activateWorkbench("SketcherWorkbench") FreeCADGui.runCommand("Sketcher_NewSketch") FreeCAD.ArchObserver = ArchComponent.ArchSelectionObserver( obj, FreeCAD.ActiveDocument.Objects[-1], hide=False, nextCommand="Arch_Rebar") FreeCADGui.Selection.addObserver(FreeCAD.ArchObserver) return elif Draft.getType(obj) == "Sketch": # we have only the sketch: extract the base object from it if hasattr(obj, "Support"): if obj.Support: if len(obj.Support) != 0: sup = obj.Support[0][0] else: print "Arch: error: couldn't extract a base object" return FreeCAD.ActiveDocument.openTransaction( translate("Arch", "Create Rebar")) FreeCADGui.addModule("Arch") FreeCADGui.doCommand( "Arch.makeRebar(FreeCAD.ActiveDocument." + sup.Name + ",FreeCAD.ActiveDocument." + obj.Name + ")") FreeCAD.ActiveDocument.commitTransaction() FreeCAD.ActiveDocument.recompute() return else: print "Arch: error: couldn't extract a base object" return FreeCAD.Console.PrintMessage( translate("Arch", "Please select a base face on a structural object\n")) FreeCADGui.Control.showDialog(ArchComponent.SelectionTaskPanel()) FreeCAD.ArchObserver = ArchComponent.ArchSelectionObserver( nextCommand="Arch_Rebar") FreeCADGui.Selection.addObserver(FreeCAD.ArchObserver)
def Activated(self): import PythonQt from PySide import QtGui mw = FreeCADGui.getMainWindow() QtGui.QMessageBox.information(mw, "PySide", """PySide was loaded successfully.""") FreeCADGui.activateWorkbench("PythonQtWorkbench")
def postStart(): "executes needed operations after loading a file" param = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Start") # switch workbench wb = param.GetString("AutoloadModule","") if wb: # don't switch workbenches if we are not in Start anymore if FreeCADGui.activeWorkbench() and (FreeCADGui.activeWorkbench().name() == "StartWorkbench"): FreeCADGui.activateWorkbench(wb) # close start tab cl = param.GetBool("closeStart",False) if cl: title = QtGui.QApplication.translate("Workbench","Start page") mw = FreeCADGui.getMainWindow() if mw: mdi = mw.findChild(QtGui.QMdiArea) if mdi: for mdichild in mdi.children(): for subw in mdichild.findChildren(QtGui.QMdiSubWindow): if subw.windowTitle() == title: subw.close()
def doubleClicked(self, vobj): if FreeCADGui.activeWorkbench().name() != 'CfdOFWorkbench': FreeCADGui.activateWorkbench("CfdOFWorkbench") doc = FreeCADGui.getDocument(vobj.Object.Document) if not CfdTools.getActiveAnalysis(): analysis_obj = CfdTools.getParentAnalysisObject(self.Object) if analysis_obj: CfdTools.setActiveAnalysis(analysis_obj) else: FreeCAD.Console.PrintError( 'No Active Analysis detected from Solver object in the active Document\n' ) if not doc.getInEdit(): if CfdTools.getActiveAnalysis().Document is FreeCAD.ActiveDocument: if self.Object in CfdTools.getActiveAnalysis().Group: doc.setEdit(vobj.Object.Name) else: FreeCAD.Console.PrintError( 'Please activate the Analysis this solver belongs to.\n' ) else: FreeCAD.Console.PrintError( 'Active Analysis is not in active Document\n') else: FreeCAD.Console.PrintError('Task dialog already active\n') FreeCADGui.Control.showTaskView() return True
def open_workbench(path, session, params, request, response): """ Activate Workbench """ Gui.activateWorkbench(params['workbenchKey']) response.html_ok()
def doubleClicked(self, vobj): if not FemGui.getActiveAnalysis() == self.Object: if FreeCADGui.activeWorkbench().name() != "FemWorkbench": FreeCADGui.activateWorkbench("FemWorkbench") FemGui.setActiveAnalysis(self.Object) return True return True
def doubleClicked(self, vobj): # bug: still not working, always bring up FemWorkbench if FreeCADGui.activeWorkbench().name() != 'CfdWorkbench': FreeCADGui.activateWorkbench("CfdWorkbench") if not FemGui.getActiveAnalysis() == self.Object: FemGui.setActiveAnalysis(self.Object) return True
def doubleClicked(self, vobj): FreeCADGui.activateWorkbench('FemWorkbench') # Group meshing is only active on active analysis, we should make sure the analysis the mesh belongs too is active gui_doc = FreeCADGui.getDocument(vobj.Object.Document) if not gui_doc.getInEdit(): # may be go the other way around and just activate the analysis the user has doubleClicked on ?! # not a fast one, we need to iterate over all member of all analysis to know to which analyis the object belongs too!!! # first check if there is an analysis in the active document found_an_analysis = False for o in gui_doc.Document.Objects: if o.isDerivedFrom('Fem::FemAnalysisPython'): found_an_analysis = True break if found_an_analysis: if FemGui.getActiveAnalysis() is not None: if FemGui.getActiveAnalysis().Document is FreeCAD.ActiveDocument: if self.Object in FemGui.getActiveAnalysis().Member: if not gui_doc.getInEdit(): gui_doc.setEdit(vobj.Object.Name) else: FreeCAD.Console.PrintError('Activate the analysis this GMSH FEM mesh object belongs too!\n') else: print('GMSH FEM mesh object does not belong to the active analysis.') found_mesh_analysis = False for o in gui_doc.Document.Objects: if o.isDerivedFrom('Fem::FemAnalysisPython'): for m in o.Member: if m == self.Object: found_mesh_analysis = True FemGui.setActiveAnalysis(o) print('The analysis the GMSH FEM mesh object belongs too was found and activated: ' + o.Name) gui_doc.setEdit(vobj.Object.Name) break if not found_mesh_analysis: print('GMSH FEM mesh object does not belong to an analysis. Analysis group meshing will be deactivated.') gui_doc.setEdit(vobj.Object.Name) else: FreeCAD.Console.PrintError('Active analysis is not in active document.') else: print('No active analysis in active document, we are going to have a look if the GMSH FEM mesh object belongs to a non active analysis.') found_mesh_analysis = False for o in gui_doc.Document.Objects: if o.isDerivedFrom('Fem::FemAnalysisPython'): for m in o.Member: if m == self.Object: found_mesh_analysis = True FemGui.setActiveAnalysis(o) print('The analysis the GMSH FEM mesh object belongs to was found and activated: ' + o.Name) gui_doc.setEdit(vobj.Object.Name) break if not found_mesh_analysis: print('GMSH FEM mesh object does not belong to an analysis. Analysis group meshing will be deactivated.') gui_doc.setEdit(vobj.Object.Name) else: print('No analysis in the active document.') gui_doc.setEdit(vobj.Object.Name) else: FreeCAD.Console.PrintError('Active Task Dialog found! Please close this one first!\n') return True
def doubleClicked(self, vobj): FreeCADGui.activateWorkbench('FemWorkbench') # Group meshing is only active on active analysis, we should make sure the analysis the mesh belongs too is active gui_doc = FreeCADGui.getDocument(vobj.Object.Document) if not gui_doc.getInEdit(): # may be go the other way around and just activate the analysis the user has doubleClicked on ?! # not a fast one, we need to iterate over all member of all analysis to know to which analyis the object belongs too!!! # first check if there is an analysis in the active document found_an_analysis = False for o in gui_doc.Document.Objects: if o.isDerivedFrom('Fem::FemAnalysisPython'): found_an_analysis = True break if found_an_analysis: if FemGui.getActiveAnalysis() is not None: if FemGui.getActiveAnalysis().Document is FreeCAD.ActiveDocument: if self.Object in FemGui.getActiveAnalysis().Group: if not gui_doc.getInEdit(): gui_doc.setEdit(vobj.Object.Name) else: FreeCAD.Console.PrintError('Activate the analysis this Gmsh FEM mesh object belongs too!\n') else: print('Gmsh FEM mesh object does not belong to the active analysis.') found_mesh_analysis = False for o in gui_doc.Document.Objects: if o.isDerivedFrom('Fem::FemAnalysisPython'): for m in o.Group: if m == self.Object: found_mesh_analysis = True FemGui.setActiveAnalysis(o) print('The analysis the Gmsh FEM mesh object belongs too was found and activated: ' + o.Name) gui_doc.setEdit(vobj.Object.Name) break if not found_mesh_analysis: print('Gmsh FEM mesh object does not belong to an analysis. Analysis group meshing will be deactivated.') gui_doc.setEdit(vobj.Object.Name) else: FreeCAD.Console.PrintError('Active analysis is not in active document.') else: print('No active analysis in active document, we are going to have a look if the Gmsh FEM mesh object belongs to a non active analysis.') found_mesh_analysis = False for o in gui_doc.Document.Objects: if o.isDerivedFrom('Fem::FemAnalysisPython'): for m in o.Group: if m == self.Object: found_mesh_analysis = True FemGui.setActiveAnalysis(o) print('The analysis the Gmsh FEM mesh object belongs to was found and activated: ' + o.Name) gui_doc.setEdit(vobj.Object.Name) break if not found_mesh_analysis: print('Gmsh FEM mesh object does not belong to an analysis. Analysis group meshing will be deactivated.') gui_doc.setEdit(vobj.Object.Name) else: print('No analysis in the active document.') gui_doc.setEdit(vobj.Object.Name) else: FreeCAD.Console.PrintError('Active Task Dialog found! Please close this one first!\n') return True
def setUp(self): FreeCADGui.activateWorkbench("TestWorkbench") FreeCAD.Console.PrintLog('Setup Test menu...\n') list = [ "Test_TestAll", "Test_TestDoc", "Test_TestBase", "Test_TestWork" ] w = FreeCADGui.getWorkbench('TestWorkbench') w.appendMenu("TestMenu", list)
def testActivate(self): list=FreeCADGui.listWorkbenches() for i in list: FreeCADGui.activateWorkbench(i) FreeCADGui.updateGui() FreeCAD.Console.PrintLog("Active: "+FreeCADGui.activeWorkbench().name()+ " Expected: "+i+"\n") FreeCADGui.updateGui() self.failUnless(FreeCADGui.activeWorkbench().name()==i, "Test on activating workbench failed")
def setEdit(self, vobj, mode): self.wb_before_edit = Gui.activeWorkbench() Gui.activateWorkbench("DraftWorkbench") self.task = ShapeStringTaskPanelEdit(vobj) Gui.Control.showDialog(self.task) return True
def show(self): self.update_constraints() doc = self.doc_slot.input() if doc: if self.sketch is None: self.sketch = doc.addObject('Sketcher::SketchObject', 'Sketch') Gui.getDocument(doc.Name).setEdit(self.sketch.Name) Gui.activateWorkbench("SketcherWorkbench")
def onCurrentIndexChanged(): """Activate workbench on selection.""" workbench = cBox.itemData(cBox.currentIndex()) wbList = Gui.listWorkbenches() for i in wbList: if wbList[i].__class__.__name__ == workbench: Gui.activateWorkbench(workbench) updateTable(cBox, table)
def unsetEdit(self, vobj, mode): if mode != 0: return None self.task.finish() Gui.activateWorkbench(self.wb_before_edit.name()) return True
def Activated(self): sel = FreeCADGui.Selection.getSelectionEx() if sel: obj = sel[0].Object if Draft.getType(obj) == "Structure": if len(sel) > 1: sk = sel[1].Object if Draft.getType(sk) == "Sketch": # we have a base object and a sketch: create the rebar now FreeCAD.ActiveDocument.openTransaction(translate("Arch", "Create Rebar")) FreeCADGui.doCommand("import Arch") FreeCADGui.doCommand( "Arch.makeRebar(FreeCAD.ActiveDocument." + obj.Name + ",FreeCAD.ActiveDocument." + sk.Name + ")" ) FreeCAD.ActiveDocument.commitTransaction() FreeCAD.ActiveDocument.recompute() return else: # we have only a base object: open the sketcher FreeCADGui.activateWorkbench("SketcherWorkbench") FreeCADGui.runCommand("Sketcher_NewSketch") FreeCAD.ArchObserver = ArchComponent.ArchSelectionObserver( obj, FreeCAD.ActiveDocument.Objects[-1], hide=False, nextCommand="Arch_Rebar" ) FreeCADGui.Selection.addObserver(FreeCAD.ArchObserver) return elif Draft.getType(obj) == "Sketch": # we have only the sketch: extract the base object from it if hasattr(obj, "Support"): if obj.Support: if isinstance(obj.Support, tuple): sup = obj.Support[0] else: sup = obj.Support FreeCAD.ActiveDocument.openTransaction(translate("Arch", "Create Rebar")) FreeCADGui.doCommand("import Arch") FreeCADGui.doCommand( "Arch.makeRebar(FreeCAD.ActiveDocument." + sup.Name + ",FreeCAD.ActiveDocument." + obj.Name + ")" ) FreeCAD.ActiveDocument.commitTransaction() FreeCAD.ActiveDocument.recompute() return else: print "Arch: error: couldn't extract a base object" return FreeCAD.Console.PrintMessage(translate("Arch", "Please select a base face on a structural object\n")) FreeCADGui.Control.showDialog(ArchComponent.SelectionTaskPanel()) FreeCAD.ArchObserver = ArchComponent.ArchSelectionObserver(nextCommand="Arch_Rebar") FreeCADGui.Selection.addObserver(FreeCAD.ArchObserver)
def importFrd(filename,Analysis=None): m = readResult(filename); MeshObject = None if(len(m) > 0): import Fem if Analysis == None: AnalysisName = os.path.splitext(os.path.basename(filename))[0] AnalysisObject = FreeCAD.ActiveDocument.addObject('Fem::FemAnalysis','Analysis') AnalysisObject.Label = AnalysisName else: AnalysisObject = Analysis if(m.has_key('Tet10Elem') and m.has_key('Nodes') and not Analysis ): mesh = Fem.FemMesh() nds = m['Nodes'] for i in nds: n = nds[i] mesh.addNode(n[0],n[1],n[2],i) elms = m['Tet10Elem'] for i in elms: e = elms[i] mesh.addVolume([e[0],e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8],e[9]],i) if len(nds) > 0: MeshObject = FreeCAD.ActiveDocument.addObject('Fem::FemMeshObject','ResultMesh') MeshObject.FemMesh = mesh AnalysisObject.Member = AnalysisObject.Member + [MeshObject] if(m.has_key('Displacement')): disp = m['Displacement'] if len(disp)>0: o = FreeCAD.ActiveDocument.addObject('Fem::FemResultVector','Displacement') o.Values = disp.values() o.DataType = 'Displacement' o.ElementNumbers = disp.keys() if(MeshObject): o.Mesh = MeshObject AnalysisObject.Member = AnalysisObject.Member + [o] if(m.has_key('Stress')): stress = m['Stress'] if len(stress)>0: o = FreeCAD.ActiveDocument.addObject('Fem::FemResultValue','MisesStress') mstress = [] for i in stress.values(): # van mises stress (http://en.wikipedia.org/wiki/Von_Mises_yield_criterion) mstress.append( sqrt( pow( i[0] - i[1] ,2) + pow( i[1] - i[2] ,2) + pow( i[2] - i[0] ,2) + 6 * (pow(i[3],2)+pow(i[4],2)+pow(i[5],2) ) ) ) o.Values = mstress o.DataType = 'VanMisesStress' o.ElementNumbers = stress.keys() if(MeshObject): o.Mesh = MeshObject AnalysisObject.Member = AnalysisObject.Member + [o] if(FreeCAD.GuiUp): import FemGui, FreeCADGui if FreeCADGui.activeWorkbench().name() != 'FemWorkbench': FreeCADGui.activateWorkbench("FemWorkbench") FemGui.setActiveAnalysis(AnalysisObject)
def doubleClicked(self, vobj): if FreeCADGui.activeWorkbench().name() != 'FemWorkbench': FreeCADGui.activateWorkbench("FemWorkbench") doc = FreeCADGui.getDocument(vobj.Object.Document) if not doc.getInEdit(): doc.setEdit(vobj.Object.Name) else: FreeCAD.Console.PrintError('Active Task Dialog found! Please close this one first!\n') return True
def doubleClicked(self, vobj): if FreeCADGui.activeWorkbench().name() != 'CfdOFWorkbench': FreeCADGui.activateWorkbench("CfdOFWorkbench") gui_doc = FreeCADGui.getDocument(vobj.Object.Document) if not gui_doc.getInEdit(): gui_doc.setEdit(vobj.Object.Name) else: FreeCAD.Console.PrintError('Task dialog already open\n') return True
def Initialize(self): import NewAlignment, Tangent, Curve1, Curve2, Curve3, CurveSpiral Gui.activateWorkbench("SketcherWorkbench") self.appendToolbar("Transportation", self.general_fn_list) self.appendToolbar("Transportation alignment", self.alignment_fn_list) self.appendMenu("Transportation", self.general_fn_list)
def Activated(self): # check that the Fasteners WB has been loaded before: if not 'FSChangeParams' in Gui.listCommands(): Gui.activateWorkbench('FastenersWorkbench') Gui.activateWorkbench('Assembly4Workbench') # check that we have selected a Fastener from the Fastener WB selection = getSelectionFS() if selection: Gui.runCommand('FSChangeParams')
def addSelection(self, document, object, element, position): if object == self.watched.Name: if not element: print "closing Sketch edit" self.origin.ViewObject.Transparency = 0 self.origin.ViewObject.Selectable = True self.watched.ViewObject.hide() FreeCADGui.activateWorkbench("ArchWorkbench") FreeCADGui.Selection.removeObserver(FreeCAD.ArchObserver) del FreeCAD.ArchObserver
def loadWorkbenches(): """Load workbenches.""" wb = Gui.listWorkbenches() mod = p.GetString("modules") mod = mod.split(",") for i in mod: if i in wb and i != default: Gui.activateWorkbench(i) if default in mod: Gui.activateWorkbench(default)
def Activated(self): sk = FreeCAD.ActiveDocument.addObject('Sketcher::SketchObject', 'Sketch') sk.MapMode = "Deactivated" p = FreeCAD.DraftWorkingPlane.getPlacement() p.Base = FreeCAD.DraftWorkingPlane.position sk.Placement = p FreeCADGui.ActiveDocument.setEdit(sk.Name) FreeCADGui.activateWorkbench('SketcherWorkbench')
def doubleClicked(self, vobj): if not FemGui.getActiveAnalysis() == self.Object: if FreeCADGui.activeWorkbench().name() != 'FemWorkbench': FreeCADGui.activateWorkbench("FemWorkbench") FemGui.setActiveAnalysis(self.Object) return True else: taskd = _JobControlTaskPanel(self.Object) FreeCADGui.Control.showDialog(taskd) return True
def addSelection(self,document, object, element, position): if object == self.watched.Name: if not element: print "closing Sketch edit" self.origin.ViewObject.Transparency = 0 self.origin.ViewObject.Selectable = True self.watched.ViewObject.hide() FreeCADGui.activateWorkbench("ArchWorkbench") FreeCADGui.Selection.removeObserver(FreeCAD.ArchObserver) del FreeCAD.ArchObserver
def make_3D_model(models_dir, model_class, modelID): LIST_license = ["",] CheckedmodelName = 'A_' + modelID.replace('.', '').replace('-', '_').replace('(', '').replace(')', '') CheckedmodelName = CheckedmodelName Newdoc = App.newDocument(CheckedmodelName) App.setActiveDocument(CheckedmodelName) Gui.ActiveDocument=Gui.getDocument(CheckedmodelName) destination_dir = model_class.get_dest_3D_dir(modelID) material_substitutions = model_class.make_3D_model(modelID) modelName = model_class.get_model_name(modelID) doc = FreeCAD.ActiveDocument doc.Label = CheckedmodelName objs=GetListOfObjects(FreeCAD, doc) objs[0].Label = CheckedmodelName restore_Main_Tools() script_dir=os.path.dirname(os.path.realpath(__file__)) expVRML.say(models_dir) out_dir=models_dir+os.sep+destination_dir if not os.path.exists(out_dir): os.makedirs(out_dir) exportSTEP(doc, modelName, out_dir) if LIST_license[0]=="": LIST_license=Lic.LIST_int_license LIST_license.append("") Lic.addLicenseToStep(out_dir + os.sep, 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) del objs 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 expVRML.writeVRMLFile(colored_meshes, export_file_name, used_color_keys, LIST_license) #scale=0.3937001 #exportVRML(doc,modelName,scale,out_dir) # Save the doc in Native FC format saveFCdoc(App, Gui, doc, modelName,out_dir) #display BBox Gui.activateWorkbench("PartWorkbench") Gui.SendMsgToActiveView("ViewFit") Gui.activeDocument().activeView().viewAxometric()
def make_3D_model(models_dir, model_class, modelID): LIST_license = ["",] CheckedmodelName = modelID.replace('.', '').replace('-', '_').replace('(', '').replace(')', '') Newdoc = App.newDocument(CheckedmodelName) App.setActiveDocument(CheckedmodelName) Gui.ActiveDocument=Gui.getDocument(CheckedmodelName) destination_dir = model_class.get_dest_3D_dir(modelID) material_substitutions = model_class.make_3D_model(modelID) modelName = model_class.get_model_name(modelID) doc = FreeCAD.ActiveDocument doc.Label = CheckedmodelName objs=GetListOfObjects(FreeCAD, doc) objs[0].Label = CheckedmodelName restore_Main_Tools() script_dir=os.path.dirname(os.path.realpath(__file__)) expVRML.say(models_dir) out_dir=models_dir+os.sep+destination_dir if not os.path.exists(out_dir): os.makedirs(out_dir) exportSTEP(doc, modelName, out_dir) if LIST_license[0]=="": LIST_license=Lic.LIST_int_license LIST_license.append("") Lic.addLicenseToStep(out_dir + os.sep, 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) del objs 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 expVRML.writeVRMLFile(colored_meshes, export_file_name, used_color_keys, LIST_license) #scale=0.3937001 #exportVRML(doc,modelName,scale,out_dir) # Save the doc in Native FC format saveFCdoc(App, Gui, doc, modelName,out_dir) #display BBox Gui.activateWorkbench("PartWorkbench") Gui.SendMsgToActiveView("ViewFit") Gui.activeDocument().activeView().viewAxometric()
def testActivate(self): list=FreeCADGui.listWorkbenches() try: for i in list: FreeCADGui.activateWorkbench(i) FreeCADGui.updateGui() FreeCAD.Console.PrintLog("Active: "+FreeCADGui.activeWorkbench().name()+ " Expected: "+i+"\n") FreeCADGui.updateGui() self.failUnless(FreeCADGui.activeWorkbench().name()==i, "Test on activating workbench failed") except Exception, e: self.failUnless(False, "Loading of workbench '%s' failed: %s" % (i, e.message))
def testActivate(self): list = FreeCADGui.listWorkbenches() for i in list: FreeCADGui.activateWorkbench(i) FreeCADGui.updateGui() FreeCAD.Console.PrintLog("Active: " + FreeCADGui.activeWorkbench().name() + " Expected: " + i + "\n") FreeCADGui.updateGui() self.failUnless(FreeCADGui.activeWorkbench().name() == i, "Test on activating workbench failed")
def testActivate(self): wbs=FreeCADGui.listWorkbenches() try: for i in wbs: FreeCADGui.activateWorkbench(i) FreeCADGui.updateGui() FreeCAD.Console.PrintLog("Active: "+FreeCADGui.activeWorkbench().name()+ " Expected: "+i+"\n") FreeCADGui.updateGui() self.assertEqual(FreeCADGui.activeWorkbench().name(), i, "Test on activating workbench {0} failed".format(i)) except Exception as e: self.fail("Loading of workbench '{0}' failed: {1}".format(i, e))
def editObject(self,wid,col): if wid.parent(): obj = FreeCAD.ActiveDocument.getObject(str(wid.text(0))) if obj: self.obj.ViewObject.Transparency = 80 self.obj.ViewObject.Selectable = False obj.ViewObject.show() self.accept() if obj.isDerivedFrom("Sketcher::SketchObject"): FreeCADGui.activateWorkbench("SketcherWorkbench") FreeCAD.ArchObserver = ArchSelectionObserver(self.obj,obj) FreeCADGui.Selection.addObserver(FreeCAD.ArchObserver) FreeCADGui.ActiveDocument.setEdit(obj.Name,0)
def onCurrentIndexChanged(): """ Activate workbench on selection. """ listWB = Gui.listWorkbenches() for i in listWB: if listWB[i].MenuText == cBox.currentText(): Gui.activateWorkbench(i) else: pass updateStats() updateTable()
def addSelection(self,document, object, element, position): if object == self.watched.Name: if not element: FreeCAD.Console.PrintMessage(str(translate("Arch","closing Sketch edit"))) if self.hide: self.origin.ViewObject.Transparency = 0 self.origin.ViewObject.Selectable = True self.watched.ViewObject.hide() FreeCADGui.activateWorkbench("ArchWorkbench") FreeCADGui.Selection.removeObserver(FreeCAD.ArchObserver) if self.nextCommand: FreeCADGui.Selection.clearSelection() FreeCADGui.Selection.addSelection(self.watched) FreeCADGui.runCommand(self.nextCommand) del FreeCAD.ArchObserver
def creaProjecte(name="Projecte"): """ Crea l'estructura basica de projecte """ FreeCADGui.activateWorkbench("Survey") # setting a new document to hold the tests if not FreeCAD.ActiveDocument: FreeCAD.newDocument("SurveyProject") FreeCAD.setActiveDocument("SurveyProject") doc = FreeCAD.activeDocument() creaCarpetaProjecte("Punts", "Punts", doc) creaCarpetaProjecte("Breaklines", "Breaklines", doc) creaCarpetaProjecte("Surfaces", "Surfaces", doc) creaCarpetaProjecte("Alignment", "Alignments", doc) return doc
def Activated(self): sel = FreeCADGui.Selection.getSelectionEx() if sel: obj = sel[0].Object if Draft.getType(obj) == "Structure": if len(sel) > 1: sk = sel[1].Object if sk.isDerivedFrom("Part::Feature"): if len(sk.Shape.Wires) == 1: # we have a structure and a wire: create the rebar now FreeCAD.ActiveDocument.openTransaction(translate("Arch","Create Rebar")) FreeCADGui.addModule("Arch") FreeCADGui.doCommand("Arch.makeRebar(FreeCAD.ActiveDocument."+obj.Name+",FreeCAD.ActiveDocument."+sk.Name+")") FreeCAD.ActiveDocument.commitTransaction() FreeCAD.ActiveDocument.recompute() return else: # we have only a structure: open the sketcher FreeCADGui.activateWorkbench("SketcherWorkbench") FreeCADGui.runCommand("Sketcher_NewSketch") FreeCAD.ArchObserver = ArchComponent.ArchSelectionObserver(obj,FreeCAD.ActiveDocument.Objects[-1],hide=False,nextCommand="Arch_Rebar") FreeCADGui.Selection.addObserver(FreeCAD.ArchObserver) return elif obj.isDerivedFrom("Part::Feature"): if len(obj.Shape.Wires) == 1: # we have only a wire: extract its support object, if available, and make the rebar support = "None" if hasattr(obj,"Support"): if obj.Support: if len(obj.Support) != 0: support = "FreeCAD.ActiveDocument."+obj.Support[0][0].Name FreeCAD.ActiveDocument.openTransaction(translate("Arch","Create Rebar")) FreeCADGui.addModule("Arch") FreeCADGui.doCommand("Arch.makeRebar("+support+",FreeCAD.ActiveDocument."+obj.Name+")") FreeCAD.ActiveDocument.commitTransaction() FreeCAD.ActiveDocument.recompute() return FreeCAD.Console.PrintMessage(translate("Arch","Please select a base face on a structural object")+"\n") FreeCADGui.Control.closeDialog() FreeCADGui.Control.showDialog(ArchComponent.SelectionTaskPanel()) FreeCAD.ArchObserver = ArchComponent.ArchSelectionObserver(nextCommand="Arch_Rebar") FreeCADGui.Selection.addObserver(FreeCAD.ArchObserver)
def Activated(self): i=0 while (i<20): FreeCADGui.activateWorkbench("MeshWorkbench") FreeCADGui.updateGui() FreeCADGui.activateWorkbench("NoneWorkbench") FreeCADGui.updateGui() FreeCADGui.activateWorkbench("PartWorkbench") FreeCADGui.updateGui() print i i=i+1 FreeCADGui.activateWorkbench("TestWorkbench")
def testHandler(self): import __main__ class UnitWorkbench(__main__.Workbench): MenuText = "Unittest" ToolTip = "Unittest" def Initialize(self): list = ["Test_Test"] self.appendToolbar("My Unittest",list) def GetClassName(self): return "Gui::PythonWorkbench" FreeCADGui.addWorkbench(UnitWorkbench()) list=FreeCADGui.listWorkbenches() self.failUnless(list.has_key("UnitWorkbench")==True, "Test on adding workbench handler failed") FreeCADGui.activateWorkbench("UnitWorkbench") FreeCADGui.updateGui() self.failUnless(FreeCADGui.activeWorkbench().name()=="UnitWorkbench", "Test on loading workbench 'Unittest' failed") FreeCADGui.removeWorkbench("UnitWorkbench") list=FreeCADGui.listWorkbenches() self.failUnless(list.has_key("UnitWorkbench")==False, "Test on removing workbench handler failed")
# Explicitly load all needed functions from cq_cad_tools import FuseObjs_wColors, GetListOfObjects, restore_Main_Tools, \ exportSTEP, close_CQ_Example, exportVRML, saveFCdoc, z_RotateObject, Color_Objects, \ CutObjs_wColors, checkRequirements # Sphinx workaround #1 try: QtGui except NameError: QtGui = None # try: # Gui.SendMsgToActiveView("Run") # from Gui.Command import * Gui.activateWorkbench("CadQueryWorkbench") import cadquery cq = cadquery from Helpers import show # CadQuery Gui except: # catch *all* exceptions msg = "missing CadQuery 0.3.0 or later Module!\r\n\r\n" msg += "https://github.com/jmwright/cadquery-freecad-module/wiki\n" if QtGui is not None: reply = QtGui.QMessageBox.information(None,"Info ...",msg) # maui end #checking requirements try: close_CQ_Example(FreeCAD, Gui)
def make_3D_model(models_dir, variant): LIST_license = ["",] FreeCAD.Console.PrintMessage("\r\nMaking %s\r\n" % variant) modelName = variant modelfileName = '' CheckedmodelName = modelName.replace('.', '').replace('-', '_').replace('(', '').replace(')', '') Newdoc = App.newDocument(CheckedmodelName) App.setActiveDocument(CheckedmodelName) Gui.ActiveDocument=Gui.getDocument(CheckedmodelName) case = None pins = None if all_params[variant].modeltype == 'BX0036': case = make_case_BX0036(all_params[variant]) pins = make_pins(all_params[variant]) show(case) show(pins) modelfileName = make_modelfileName_Common(all_params[variant]) # # elif all_params[variant].modeltype == 'Button1': case = make_case_Button1(all_params[variant]) pins = make_pins(all_params[variant]) show(case) show(pins) modelfileName = make_modelfileName_Common(all_params[variant]) # # elif all_params[variant].modeltype == 'Button2': case = make_case_Button2(all_params[variant]) pins = make_pins(all_params[variant]) show(case) show(pins) modelfileName = make_modelfileName_Common(all_params[variant]) # # elif all_params[variant].modeltype == 'Button3': case = make_case_Button3(all_params[variant]) pins = make_pins(all_params[variant]) show(case) show(pins) modelfileName = make_modelfileName_Common(all_params[variant]) # # elif all_params[variant].modeltype == 'Button4': case = make_case_Button4(all_params[variant]) pins = make_pins(all_params[variant]) show(case) show(pins) modelfileName = make_modelfileName_Common(all_params[variant]) # # elif all_params[variant].modeltype == 'Cylinder1': case = make_case_Cylinder1(all_params[variant]) pins = make_pins(all_params[variant]) show(case) show(pins) modelfileName = make_modelfileName_Common(all_params[variant]) # # elif variant == 'Seiko_MS621F': case = make_case_Seiko_MS621F(all_params[variant]) pins = make_pins_Seiko_MS621F(all_params[variant]) show(case) show(pins) modelfileName = make_modelfileName_Common(all_params[variant]) # # elif variant == 'Keystone_2993': case = make_case_Keystone_2993(all_params[variant]) pins = make_pins_Keystone_2993(all_params[variant]) show(case) show(pins) modelfileName = make_modelfileName_Common(all_params[variant]) # # else: FreeCAD.Console.PrintMessage("\r\nSerie %s does not exist, skipping'\r\n" % all_params[variant].serie) return #show(pinmark) #stop doc = FreeCAD.ActiveDocument objs=GetListOfObjects(FreeCAD, doc) body_color_key = all_params[variant].body_color_key pin_color_key = all_params[variant].pin_color_key body_color = shaderColors.named_colors[body_color_key].getDiffuseFloat() pin_color = shaderColors.named_colors[pin_color_key].getDiffuseFloat() Color_Objects(Gui,objs[0],body_color) Color_Objects(Gui,objs[1],pin_color) col_body=Gui.ActiveDocument.getObject(objs[0].Name).DiffuseColor[0] col_pin=Gui.ActiveDocument.getObject(objs[1].Name).DiffuseColor[0] material_substitutions={ col_body[:-1]:body_color_key, col_pin[:-1]:pin_color_key } expVRML.say(material_substitutions) while len(objs) > 1: FuseObjs_wColors(FreeCAD, FreeCADGui, doc.Name, objs[0].Name, objs[1].Name) del objs objs = GetListOfObjects(FreeCAD, doc) doc.Label = CheckedmodelName del objs objs=GetListOfObjects(FreeCAD, doc) objs[0].Label = CheckedmodelName restore_Main_Tools() script_dir=os.path.dirname(os.path.realpath(__file__)) expVRML.say(models_dir) out_dir=models_dir + os.sep + all_params[variant].dest_dir_prefix if not os.path.exists(out_dir): os.makedirs(out_dir) exportSTEP(doc, modelfileName, out_dir) if LIST_license[0]=="": LIST_license=Lic.LIST_int_license LIST_license.append("") Lic.addLicenseToStep(out_dir + os.sep, modelfileName + ".step", LIST_license,\ STR_licAuthor, STR_licEmail, STR_licOrgSys, STR_licOrg, STR_licPreProc) # scale and export Vrml model scale=1/2.54 #exportVRML(doc, modelfileName,scale,out_dir) del objs 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 + modelfileName + '.wrl' colored_meshes = expVRML.getColoredMesh(Gui, export_objects , scale) #expVRML.writeVRMLFile(colored_meshes, export_file_name, used_color_keys)# , LIST_license expVRML.writeVRMLFile(colored_meshes, export_file_name, used_color_keys, LIST_license) #scale=0.3937001 #exportVRML(doc, modelfileName,scale,out_dir) # Save the doc in Native FC format saveFCdoc(App, Gui, doc, modelfileName, out_dir) #display BBox Gui.activateWorkbench("PartWorkbench") Gui.SendMsgToActiveView("ViewFit") Gui.activeDocument().activeView().viewAxometric()
def makeParameter(): FreeCAD.newDocument() FreeCADGui.activateWorkbench("PartWorkbench") FreeCAD.ActiveDocument.addObject("Part::Box", "Box") createParameter()
#*************************************************************************** #* * #* Copyright (c) 2012 * #* Yorik van Havre <*****@*****.**> * #* * #* This program is free software; you can redistribute it and/or modify * #* it under the terms of the GNU Lesser General Public License (LGPL) * #* as published by the Free Software Foundation; either version 2 of * #* the License, or (at your option) any later version. * #* for detail see the LICENCE text file. * #* * #* This program is distributed in the hope that it will be useful, * #* but WITHOUT ANY WARRANTY; without even the implied warranty of * #* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * #* GNU Library General Public License for more details. * #* * #* You should have received a copy of the GNU Library General Public * #* License along with this program; if not, write to the Free Software * #* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * #* USA * #* * #*************************************************************************** import FreeCADGui FreeCADGui.activateWorkbench("ArchWorkbench") App.newDocument()
#*************************************************************************** #* * #* Copyright (c) 2012 * #* Yorik van Havre <*****@*****.**> * #* * #* This program is free software; you can redistribute it and/or modify * #* it under the terms of the GNU Lesser General Public License (LGPL) * #* as published by the Free Software Foundation; either version 2 of * #* the License, or (at your option) any later version. * #* for detail see the LICENCE text file. * #* * #* This program is distributed in the hope that it will be useful, * #* but WITHOUT ANY WARRANTY; without even the implied warranty of * #* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * #* GNU Library General Public License for more details. * #* * #* You should have received a copy of the GNU Library General Public * #* License along with this program; if not, write to the Free Software * #* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * #* USA * #* * #*************************************************************************** import FreeCAD, FreeCADGui workbench = FreeCAD.ConfigGet("DefaultWorkbench") if not workbench: workbench = "CompleteWorkbench" FreeCADGui.activateWorkbench(workbench) App.newDocument()
#*************************************************************************** #* * #* Copyright (c) 2012 * #* Yorik van Havre <*****@*****.**> * #* * #* This program is free software; you can redistribute it and/or modify * #* it under the terms of the GNU Lesser General Public License (LGPL) * #* as published by the Free Software Foundation; either version 2 of * #* the License, or (at your option) any later version. * #* for detail see the LICENCE text file. * #* * #* This program is distributed in the hope that it will be useful, * #* but WITHOUT ANY WARRANTY; without even the implied warranty of * #* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * #* GNU Library General Public License for more details. * #* * #* You should have received a copy of the GNU Library General Public * #* License along with this program; if not, write to the Free Software * #* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * #* USA * #* * #*************************************************************************** import FreeCAD,FreeCADGui FreeCADGui.activateWorkbench("DrawingWorkbench") FreeCAD.open(FreeCAD.getResourceDir()+"examples/DrawingExample.FCStd") FreeCADGui.activeDocument().sendMsgToViews("ViewFit") FreeCADGui.activeDocument().sendMsgToViews("ViewAxo")