Esempio n. 1
1
    def Activated(self):
        MatObj = None
        for i in FemGui.getActiveAnalysis().Member:
            if i.isDerivedFrom("App::MaterialObject"):
                MatObj = i

        if not MatObj:
            femDoc = FemGui.getActiveAnalysis().Document
            if FreeCAD.ActiveDocument is not femDoc:
                FreeCADGui.setActiveDocument(femDoc)
            FreeCAD.ActiveDocument.openTransaction("Create Material")
            FreeCADGui.addModule("MechanicalMaterial")
            FreeCADGui.doCommand("MechanicalMaterial.makeMechanicalMaterial('MechanicalMaterial')")
            FreeCADGui.doCommand(
                "App.activeDocument()."
                + FemGui.getActiveAnalysis().Name
                + ".Member = App.activeDocument()."
                + FemGui.getActiveAnalysis().Name
                + ".Member + [App.ActiveDocument.ActiveObject]"
            )
            FreeCADGui.doCommand("Gui.activeDocument().setEdit(App.ActiveDocument.ActiveObject.Name,0)")
            # FreeCADGui.doCommand("Fem.makeMaterial()")
        else:
            if FreeCAD.ActiveDocument is not MatObj.Document:
                FreeCADGui.setActiveDocument(MatObj.Document)
            FreeCADGui.doCommand("Gui.activeDocument().setEdit('" + MatObj.Name + "',0)")
    def setEdit(self, vobj, mode=0):

        if FemGui.getActiveAnalysis() is not None:
            if hasattr(self.Object, "Mesh") and self.Object.Mesh:
                mem = FemGui.getActiveAnalysis().Member
                if self.Object in mem:
                    if self.Object.Mesh in mem:
                        import PyGui._TaskPanelFemResultShow
                        taskd = PyGui._TaskPanelFemResultShow._TaskPanelFemResultShow(self.Object)
                        taskd.obj = vobj.Object
                        FreeCADGui.Control.showDialog(taskd)
                        return True
                    else:
                        error_message = 'FEM: Result mesh object is not in active analysis.\n'
                        FreeCAD.Console.PrintError(error_message)
                        QtGui.QMessageBox.critical(None, 'Not in activate analysis', error_message)
                        return False
                else:
                    error_message = 'FEM: Result object is not in active analysis.\n'
                    FreeCAD.Console.PrintError(error_message)
                    QtGui.QMessageBox.critical(None, 'Not in activate analysis', error_message)
                    return False
            else:
                error_message = 'FEM: Result object has no appropriate FEM mesh.\n'
                FreeCAD.Console.PrintError(error_message)
                QtGui.QMessageBox.critical(None, 'No result object', error_message)
                return False
        else:
            error_message = 'FEM: No active analysis found! Please activate the analysis you would like to view results for.\n'
            FreeCAD.Console.PrintError(error_message)
            QtGui.QMessageBox.critical(None, 'No activate analysis', error_message)
            return False
Esempio n. 3
0
 def IsActive(self):
     if not self.is_active:
         active = False
     elif self.is_active == "with_document":
         active = FreeCADGui.ActiveDocument is not None
     elif self.is_active == "with_analysis":
         active = FemGui.getActiveAnalysis() is not None and self.active_analysis_in_active_doc()
     elif self.is_active == "with_results":
         active = (
             FemGui.getActiveAnalysis() is not None
             and self.active_analysis_in_active_doc()
             and self.results_present()
         )
     elif self.is_active == "with_part_feature":
         active = FreeCADGui.ActiveDocument is not None and self.part_feature_selected()
     elif self.is_active == "with_solver":
         active = (
             FemGui.getActiveAnalysis() is not None
             and self.active_analysis_in_active_doc()
             and self.solver_selected()
         )
     elif self.is_active == "with_analysis_without_solver":
         active = (
             FemGui.getActiveAnalysis() is not None
             and self.active_analysis_in_active_doc()
             and not self.analysis_has_solver()
         )
     return active
 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 Activated(self):
     femDoc = FemGui.getActiveAnalysis().Document
     if FreeCAD.ActiveDocument is not femDoc:
         FreeCADGui.setActiveDocument(femDoc)
     FreeCAD.ActiveDocument.openTransaction("Create Solid Material")
     FreeCADGui.addModule("ObjectsFem")
     FreeCADGui.doCommand("ObjectsFem.makeMaterialSolid(FreeCAD.ActiveDocument, 'SolidMaterial')")
     FreeCADGui.doCommand("FreeCAD.ActiveDocument." + FemGui.getActiveAnalysis().Name + ".Member = FreeCAD.ActiveDocument." + FemGui.getActiveAnalysis().Name + ".Member + [FreeCAD.ActiveDocument.ActiveObject]")
     FreeCADGui.doCommand("FreeCADGui.ActiveDocument.setEdit(FreeCAD.ActiveDocument.ActiveObject.Name)")
 def Activated(self):
     femDoc = FemGui.getActiveAnalysis().Document
     if FreeCAD.ActiveDocument is not femDoc:
         FreeCADGui.setActiveDocument(femDoc)
     FreeCAD.ActiveDocument.openTransaction("Create Fluid Material")
     FreeCADGui.addModule("ObjectsFem")
     FreeCADGui.doCommand("ObjectsFem.makeMaterialFluid('FluidMaterial')")
     FreeCADGui.doCommand("App.activeDocument()." + FemGui.getActiveAnalysis().Name + ".Member = App.activeDocument()." + FemGui.getActiveAnalysis().Name + ".Member + [App.ActiveDocument.ActiveObject]")
     FreeCADGui.doCommand("Gui.activeDocument().setEdit(App.ActiveDocument.ActiveObject.Name)")
Esempio n. 7
0
    def Activated(self):
        self.result_object = None
        for i in FemGui.getActiveAnalysis().Member:
            if i.isDerivedFrom("Fem::FemResultObject"):
                self.result_object = i

        if not self.result_object:
            QtGui.QMessageBox.critical(None, "Missing prerequisite", "No result found in active Analysis")
            return

        taskd = _ResultControlTaskPanel(FemGui.getActiveAnalysis())
        FreeCADGui.Control.showDialog(taskd)
Esempio n. 8
0
 def IsActive(self):
     if not self.is_active:
         active = False
     elif self.is_active == 'with_document':
         active = FreeCADGui.ActiveDocument is not None
     elif self.is_active == 'with_analysis':
         active = FreeCADGui.ActiveDocument is not None and FemGui.getActiveAnalysis() is not None
     elif self.is_active == 'with_results':
         active = FreeCADGui.ActiveDocument is not None and FemGui.getActiveAnalysis() is not None and self.results_present()
     elif self.is_active == 'with_part_feature':
         active = FreeCADGui.ActiveDocument is not None and FemGui.getActiveAnalysis() is not None and self.part_feature_selected()
     return active
    def check_prerequisites(self):
        self.Start = time.time()
        self.femConsoleMessage("Check dependencies...")
        self.form.label_Time.setText('Time: {0:4.1f}: '.format(time.time() - self.Start))
        self.MeshObject = None
        # [{'Object':MaterialObject}, {}, ...]
        self.MaterialObjects = []
        # [{'Object':FixedObject, 'NodeSupports':bool}, {}, ...]
        self.FixedObjects = []
        # [{'Object':ForceObject, 'NodeLoad':value}, {}, ...
        self.ForceObjects = []
        # [{'Object':PressureObject, 'xxxxxxxx':value}, {}, ...]
        self.PressureObjects = []
        if not FemGui.getActiveAnalysis():
            QtGui.QMessageBox.critical(None, "Missing prerequisite", "No active Analysis")
            return False

        for i in FemGui.getActiveAnalysis().Member:
            if i.isDerivedFrom("Fem::FemMeshObject"):
                self.MeshObject = i
            elif i.isDerivedFrom("App::MaterialObjectPython"):
                MaterialObjectDict = {}
                MaterialObjectDict['Object'] = i
                self.MaterialObjects.append(MaterialObjectDict)
            elif i.isDerivedFrom("Fem::ConstraintFixed"):
                FixedObjectDict = {}
                FixedObjectDict['Object'] = i
                self.FixedObjects.append(FixedObjectDict)
            elif i.isDerivedFrom("Fem::ConstraintForce"):
                ForceObjectDict = {}
                ForceObjectDict['Object'] = i
                self.ForceObjects.append(ForceObjectDict)
            elif i.isDerivedFrom("Fem::ConstraintPressure"):
                PressureObjectDict = {}
                PressureObjectDict['Object'] = i
                self.PressureObjects.append(PressureObjectDict)

        if not self.MeshObject:
            QtGui.QMessageBox.critical(None, "Missing prerequisite", "No mesh object in the Analysis")
            return False

        if not self.MaterialObjects:
            QtGui.QMessageBox.critical(None, "Missing prerequisite", "No material object in the Analysis")
            return False

        if not self.FixedObjects:
            QtGui.QMessageBox.critical(None, "Missing prerequisite", "No fixed-constraint nodes defined in the Analysis")
            return False

        if not (self.ForceObjects or self.PressureObjects):
            QtGui.QMessageBox.critical(None, "Missing prerequisite", "No force-constraint or pressure-constraint defined in the Analysis")
            return False
        return True
 def get_active_analysis(self):
     import FemGui
     self.analysis = FemGui.getActiveAnalysis()
     if self.analysis:
         for m in FemGui.getActiveAnalysis().Member:
             if m.Name == self.mesh_obj.Name:
                 print(self.analysis.Name)
                 return
         else:
             # print('Mesh is not member of active analysis, means no group meshing')
             self.analysis = None  # no group meshing
     else:
         # print('No active analyis, means no group meshing')
         self.analysis = None  # no group meshing
Esempio n. 11
0
 def IsActive(self):
     if not self.is_active:
         active = False
     elif self.is_active == 'with_document':
         active = FreeCADGui.ActiveDocument is not None
     elif self.is_active == 'with_analysis':
         active = FemGui.getActiveAnalysis() is not None and self.active_analysis_in_active_doc()
     elif self.is_active == 'with_results':
         active = FemGui.getActiveAnalysis() is not None and self.active_analysis_in_active_doc() and self.results_present()
     elif self.is_active == 'with_selresult':
         active = FemGui.getActiveAnalysis() is not None and self.active_analysis_in_active_doc() and self.result_selected()
     elif self.is_active == 'with_part_feature':
         active = FreeCADGui.ActiveDocument is not None and self.part_feature_selected()
     elif self.is_active == 'with_femmesh':
         active = FreeCADGui.ActiveDocument is not None and self.femmesh_selected()
     elif self.is_active == 'with_gmsh_femmesh':
         active = FreeCADGui.ActiveDocument is not None and self.gmsh_femmesh_selected()
     elif self.is_active == 'with_femmesh_andor_res':
         active = FreeCADGui.ActiveDocument is not None and self.with_femmesh_andor_res_selected()
     elif self.is_active == 'with_material':
         active = FemGui.getActiveAnalysis() is not None and self.active_analysis_in_active_doc() and self.material_selected()
     elif self.is_active == 'with_material_solid_which_has_no_nonlinear_material':
         active = FemGui.getActiveAnalysis() is not None and self.active_analysis_in_active_doc() and self.material_solid_selected() and self.has_no_nonlinear_material()
     elif self.is_active == 'with_solver':
         active = FemGui.getActiveAnalysis() is not None and self.active_analysis_in_active_doc() and self.solver_selected()
     elif self.is_active == 'with_solver_elmer':
         active = FemGui.getActiveAnalysis() is not None and self.active_analysis_in_active_doc() and self.solver_elmer_selected()
     elif self.is_active == 'with_analysis_without_solver':
         active = FemGui.getActiveAnalysis() is not None and self.active_analysis_in_active_doc() and not self.analysis_has_solver()
     return active
Esempio n. 12
0
def getActiveAnalysis():
    # find the fem analysis object this fem_object belongs to,
    # DEPRECATED: try to use `getParentAnalysisObject` as possible
    if FreeCAD.GuiUp:
        import FemGui
        if FemGui.getActiveAnalysis():
            return FemGui.getActiveAnalysis()
    else:  # assume the first Fem::FemAnalysis obj is active
        for o in FreeCAD.activeDocument().Objects:
            if o.Name.startswith(
                    "CfdAnalysis"
            ):  # FIXME: is the name always starts with "CfdAnalysis"?
                return o
            if 'Group' not in o.PropertiesList:
                return o
        return None
 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 calculixFinished(self, exitCode):
        print "calculixFinished()", exitCode
        print self.Calculix.state()
        out = self.Calculix.readAllStandardOutput()
        print out
        if out:
            self.OutStr = self.OutStr + unicode(out).replace('\n', '<br>')
            self.formUi.textEdit_Output.setText(self.OutStr)

        self.Timer.stop()

        self.OutStr = self.OutStr + '<font color="#0000FF">{0:4.1f}:</font> '.format(
            time.time() -
            self.Start) + '<font color="#00FF00">Calculix done!</font><br>'
        self.formUi.textEdit_Output.setText(self.OutStr)

        self.formUi.pushButton_generate.setText("Re-run Calculix")
        print "Loading results...."
        self.OutStr = self.OutStr + '<font color="#0000FF">{0:4.1f}:</font> '.format(
            time.time() - self.Start) + 'Loading result sets...<br>'
        self.formUi.textEdit_Output.setText(self.OutStr)
        self.formUi.label_Time.setText('Time: {0:4.1f}: '.format(time.time() -
                                                                 self.Start))

        QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
        CalculixLib.importFrd(self.Basename + '.frd',
                              FemGui.getActiveAnalysis())
        QApplication.restoreOverrideCursor()
        self.OutStr = self.OutStr + '<font color="#0000FF">{0:4.1f}:</font> '.format(
            time.time() - self.Start
        ) + '<font color="#00FF00">Loading results done!</font><br>'
        self.formUi.textEdit_Output.setText(self.OutStr)
        self.formUi.label_Time.setText('Time: {0:4.1f}: '.format(time.time() -
                                                                 self.Start))
Esempio n. 15
0
    def update(self):
        self.MeshObject = None
        self.result_object = get_results_object(FreeCADGui.Selection.getSelection())
        for i in FemGui.getActiveAnalysis().Member:
            if i.isDerivedFrom("Fem::FemMeshObject"):
                self.MeshObject = i
                break

        self.suitable_results = False
        if self.result_object:
            # Disable temperature radio button if it does ot exist in results
            if len(self.result_object.Temperature) == 1:
                self.form.rb_temperature.setEnabled(0)

            if self.MeshObject.FemMesh.NodeCount == len(self.result_object.NodeNumbers):
                self.suitable_results = True
            else:
                if not self.MeshObject.FemMesh.VolumeCount:
                    FreeCAD.Console.PrintError(
                        "FEM: Graphical bending stress output for beam or shell FEM Meshes not yet supported.\n"
                    )
                else:
                    FreeCAD.Console.PrintError("FEM: Result node numbers are not equal to FEM Mesh NodeCount.\n")
        else:
            error_message = "FEM: Result task panel, no result object to display results for.\n"
            FreeCAD.Console.PrintError(error_message)
            QtGui.QMessageBox.critical(None, "No result object", error_message)
Esempio n. 16
0
    def __init__(self, solver_runner_obj):
        ui_path = os.path.dirname(__file__) + os.path.sep + "TaskPanelCfdSolverControl.ui"
        self.form = FreeCADGui.PySideUic.loadUi(ui_path)
        self.fem_prefs = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Fem")

        self.analysis_object = FemGui.getActiveAnalysis()

        self.solver_runner = solver_runner_obj
        self.solver_object = solver_runner_obj.solver
        # test if Proxy instance is not None and correct type, or create a new python instance
        #self.solver_python_object = CfdTools.getSolverPythonFromAnalysis(self.analysis_object)

        self.SolverProcess = QtCore.QProcess()
        self.Timer = QtCore.QTimer()
        self.Timer.start(3000)

        # update UI
        self.fem_console_message = ''

        # Connect Signals and Slots
        QtCore.QObject.connect(self.form.tb_choose_working_dir, QtCore.SIGNAL("clicked()"), self.choose_working_dir)
        QtCore.QObject.connect(self.form.pb_write_inp, QtCore.SIGNAL("clicked()"), self.write_input_file_handler)
        QtCore.QObject.connect(self.form.pb_edit_inp, QtCore.SIGNAL("clicked()"), self.editSolverInputFile)
        QtCore.QObject.connect(self.form.pb_run_solver, QtCore.SIGNAL("clicked()"), self.runSolverProcess)
        QtCore.QObject.connect(self.form.pb_show_result, QtCore.SIGNAL("clicked()"), self.showResult)
        #
        QtCore.QObject.connect(self.SolverProcess, QtCore.SIGNAL("started()"), self.solverProcessStarted)
        QtCore.QObject.connect(self.SolverProcess, QtCore.SIGNAL("stateChanged(QProcess::ProcessState)"), self.solverProcessStateChanged)
        QtCore.QObject.connect(self.SolverProcess, QtCore.SIGNAL("error(QProcess::ProcessError)"), self.solverProcessError)
        QtCore.QObject.connect(self.SolverProcess, QtCore.SIGNAL("finished(int)"), self.solverProcessFinished)

        QtCore.QObject.connect(self.Timer, QtCore.SIGNAL("timeout()"), self.updateText)
        self.form.pb_show_result.setEnabled(True)
        self.Start = time.time() #debug tobe removed, it is not used in this taskpanel
        self.update()  # update UI from FemSolverObject, like WorkingDir
Esempio n. 17
0
 def results_present(self):
     results = False
     analysis_members = FemGui.getActiveAnalysis().Member
     for o in analysis_members:
         if o.isDerivedFrom('Fem::FemResultObject'):
             results = True
     return results
Esempio n. 18
0
 def Activated(self):
     # a mesh could be made with and without an analysis,
     # we're going to check not for an analysis in command manager module
     FreeCAD.ActiveDocument.openTransaction("Create FEM mesh Netgen")
     mesh_obj_name = "FEMMeshNetgen"
     # if requested by some people add Preference for this
     # mesh_obj_name = sel[0].Name + "_Mesh"
     FreeCADGui.addModule("ObjectsFem")
     FreeCADGui.doCommand(
         "ObjectsFem.makeMeshNetgen(FreeCAD.ActiveDocument, '" +
         mesh_obj_name + "')")
     FreeCADGui.doCommand(
         "FreeCAD.ActiveDocument.ActiveObject.Shape = FreeCAD.ActiveDocument.{}"
         .format(self.selobj.Name))
     # Netgen mesh object could be added without an active analysis
     # but if there is an active analysis move it in there
     import FemGui
     if FemGui.getActiveAnalysis():
         FreeCADGui.addModule("FemGui")
         FreeCADGui.doCommand(
             "FemGui.getActiveAnalysis().addObject(FreeCAD.ActiveDocument.ActiveObject)"
         )
     FreeCADGui.doCommand(
         "FreeCADGui.ActiveDocument.setEdit(FreeCAD.ActiveDocument.ActiveObject.Name)"
     )
     FreeCADGui.Selection.clearSelection()
Esempio n. 19
0
 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
Esempio n. 20
0
    def Activated(self):
        FreeCAD.ActiveDocument.openTransaction("Create FEM mesh by GMSH")
        FreeCADGui.addModule("FemGui")
        sel = FreeCADGui.Selection.getSelection()
        if (len(sel) == 1):
            if (sel[0].isDerivedFrom("Part::Feature")):
                mesh_obj_name = 'FEMMeshGMSH'
                # mesh_obj_name = sel[0].Name + "_Mesh"  # if requested by some people add Preference for this
                FreeCADGui.addModule("ObjectsFem")
                FreeCADGui.doCommand(
                    "ObjectsFem.makeMeshGmsh(FreeCAD.ActiveDocument, '" +
                    mesh_obj_name + "')")
                FreeCADGui.doCommand(
                    "FreeCAD.ActiveDocument.ActiveObject.Part = FreeCAD.ActiveDocument."
                    + sel[0].Name)
                if FemGui.getActiveAnalysis():
                    FreeCADGui.addModule("FemGui")
                    FreeCADGui.doCommand(
                        "FemGui.getActiveAnalysis().Member = FemGui.getActiveAnalysis().Member + [FreeCAD.ActiveDocument.ActiveObject]"
                    )
                FreeCADGui.doCommand(
                    "Gui.ActiveDocument.setEdit(FreeCAD.ActiveDocument.ActiveObject.Name)"
                )

        FreeCADGui.Selection.clearSelection()
 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
Esempio n. 22
0
    def update(self):
        self.MeshObject = None
        self.result_object = get_results_object(
            FreeCADGui.Selection.getSelection())
        # Disable temperature radio button if it does ot exist in results
        if len(self.result_object.Temperature) == 1:
            self.form.rb_temperature.setEnabled(0)

        for i in FemGui.getActiveAnalysis().Member:
            if i.isDerivedFrom("Fem::FemMeshObject"):
                self.MeshObject = i
                break

        self.suitable_results = False
        if self.result_object:
            if (self.MeshObject.FemMesh.NodeCount == len(
                    self.result_object.NodeNumbers)):
                self.suitable_results = True
            else:
                if not self.MeshObject.FemMesh.VolumeCount:
                    FreeCAD.Console.PrintError(
                        'Graphical bending stress output for beam or shell FEM Meshes not yet supported!\n'
                    )
                else:
                    FreeCAD.Console.PrintError(
                        'Result node numbers are not equal to FEM Mesh NodeCount!\n'
                    )
Esempio n. 23
0
    def __init__(self, analysis=None, test_mode=False):
        QtCore.QRunnable.__init__(self)
        QtCore.QObject.__init__(self)

        if analysis:
            ## @var analysis
            #  FEM analysis - the core object. Has to be present.
            #  It's set to analysis passed in "__init__" or set to current active analysis by default if nothing has been passed to "__init__".
            self.analysis = analysis
        else:
            import FemGui
            self.analysis = FemGui.getActiveAnalysis()
        if self.analysis:
            self.update_objects()
            self.set_analysis_type()
            self.set_eigenmode_parameters()
            ## @var base_name
            #  base name of .inp/.frd file (without extension). It is used to construct .inp file path that is passed to CalculiX ccx
            self.base_name = ""
            ## @var results_present
            #  boolean variable indicating if there are calculation results ready for use
            self.results_present = False
            self.setup_working_dir()
            if test_mode:
                self.ccx_binary_present = True
            else:
                self.ccx_binary_present = False
                self.setup_ccx()
        else:
            raise Exception('FEM: No active analysis found!')
Esempio n. 24
0
 def hide_meshes_show_parts_constraints(self):
     if FreeCAD.GuiUp:
         for acnstrmesh in FemGui.getActiveAnalysis().Group:
             if "Constraint" in acnstrmesh.TypeId:
                 acnstrmesh.ViewObject.Visibility = True
             if "Mesh" in acnstrmesh.TypeId:
                 acnstrmesh.ViewObject.Visibility = False  # OvG: Hide meshes and show constraints and meshed part e.g. on purging results
 def Activated(self):
     sel = FreeCADGui.Selection.getSelection()
     if len(sel) == 1 and sel[0].isDerivedFrom("App::MaterialObjectPython"):
         lin_mat_obj = sel[0]
         # check if an nonlinear material exists which is based on the selected material already
         allow_nonlinear_material = True
         for o in FreeCAD.ActiveDocument.Objects:
             if hasattr(o, "Proxy") and o.Proxy is not None and o.Proxy.Type == "FemMaterialMechanicalNonlinear" and o.LinearBaseMaterial == lin_mat_obj:
                 FreeCAD.Console.PrintError(o.Name + ' is based on the selected material: ' + lin_mat_obj.Name + '. Only one nonlinear object for each material allowed.\n')
                 allow_nonlinear_material = False
                 break
         if allow_nonlinear_material:
             string_lin_mat_obj = "App.ActiveDocument.getObject('" + lin_mat_obj.Name + "')"
             command_to_run = "FemGui.getActiveAnalysis().Member = FemGui.getActiveAnalysis().Member + [ObjectsFem.makeMaterialMechanicalNonlinear(" + string_lin_mat_obj + ")]"
             FreeCAD.ActiveDocument.openTransaction("Create FemMaterialMechanicalNonlinear")
             FreeCADGui.addModule("ObjectsFem")
             FreeCADGui.doCommand(command_to_run)
         # set the material nonlinear property of the solver to nonlinear if only one solver is available and if this solver is a CalculiX solver
         solver_object = None
         for m in FemGui.getActiveAnalysis().Member:
             if m.isDerivedFrom('Fem::FemSolverObjectPython'):
                 if not solver_object:
                     solver_object = m
                 else:
                     # we do not change the material nonlinear attribut if we have more than one solver
                     solver_object = None
                     break
         if solver_object and solver_object.SolverType == 'FemSolverCalculix':
             solver_object.MaterialNonlinearity = "nonlinear"
Esempio n. 26
0
    def __init__(self, analysis=None, solver=None, test_mode=False):
        if analysis:
            ## @var analysis
            #  FEM analysis - the core object. Has to be present.
            #  It's set to analysis passed in "__init__" or set to current active analysis by default if nothing has been passed to "__init__".
            self.analysis = analysis
        else:
            import FemGui
            self.analysis = FemGui.getActiveAnalysis()
        if solver:
            ## @var solver
            #  solver of the analysis. Used to store the active solver and analysis parameters
            self.solver = solver
        else:
            self.solver = None
        if self.analysis:
            self.update_objects()
            self.base_name = ""
            if self.solver:
                self.set_analysis_type()
                self.setup_working_dir()
                self.setup_z88()
            else:
                raise Exception('FEM: No solver found!')
        else:
            raise Exception('FEM: No active analysis found!')

        self.z88_is_running = False
        self.z88_testrun = QtCore.QProcess()
        self.z88_solverun = QtCore.QProcess()
        QtCore.QObject.connect(self.z88_testrun, QtCore.SIGNAL("started()"), self.z88_testrun_started)
        QtCore.QObject.connect(self.z88_testrun, QtCore.SIGNAL("finished(int)"), self.z88_testrun_finished)
        QtCore.QObject.connect(self.z88_solverun, QtCore.SIGNAL("started()"), self.z88_solverun_started)
        QtCore.QObject.connect(self.z88_solverun, QtCore.SIGNAL("finished(int)"), self.z88_solverun_finished)
Esempio n. 27
0
 def hide_meshes_show_parts_constraints(self):
     if FreeCAD.GuiUp:
         for acnstrmesh in FemGui.getActiveAnalysis().Group:
             if "Constraint" in acnstrmesh.TypeId:
                 acnstrmesh.ViewObject.Visibility = True
             if "Mesh" in acnstrmesh.TypeId:
                 acnstrmesh.ViewObject.Visibility = False  # OvG: Hide meshes and show constraints and meshed part e.g. on purging results
Esempio n. 28
0
 def IsActive(self):
     if not self.is_active:
         active = False
     elif self.is_active == 'with_document':
         active = FreeCADGui.ActiveDocument is not None
     elif self.is_active == 'with_analysis':
         active = FemGui.getActiveAnalysis() is not None and self.active_analysis_in_active_doc()
     elif self.is_active == 'with_results':
         active = FemGui.getActiveAnalysis() is not None and self.active_analysis_in_active_doc() and self.results_present()
     elif self.is_active == 'with_part_feature':
         active = FreeCADGui.ActiveDocument is not None and self.part_feature_selected()
     elif self.is_active == 'with_solver':
         active = FemGui.getActiveAnalysis() is not None and self.active_analysis_in_active_doc() and self.solver_selected()
     elif self.is_active == 'with_analysis_without_solver':
         active = FemGui.getActiveAnalysis() is not None and self.active_analysis_in_active_doc() and not self.analysis_has_solver()
     return active
Esempio n. 29
0
 def active_analysis_in_active_doc(self):
     analysis = FemGui.getActiveAnalysis()
     if analysis.Document is FreeCAD.ActiveDocument:
         self.active_analysis = analysis
         return True
     else:
         return False
Esempio n. 30
0
 def createSolver(solver_name):
     FreeCAD.ActiveDocument.openTransaction("Create Solver")
     FreeCADGui.addModule("FemGui")
     FreeCADGui.addModule("CfdObjects")
     FreeCADGui.doCommand("CfdObjects.makeCfdSolver('{}')".format(solver_name))
     if FemGui.getActiveAnalysis():
         FreeCADGui.doCommand("FemGui.getActiveAnalysis().addObject(App.ActiveDocument.ActiveObject)")
Esempio n. 31
0
    def update(self):
        self.MeshObject = None
        self.result_object = CfdTools.getResultObject(
        )  # return the first one, or the currently selected result object
        # Disable temperature radio button if it does not exist in results
        if len(self.result_object.Temperature) == 1:
            self.form.rb_temperature.setEnabled(0)
        #
        for i in FemGui.getActiveAnalysis().Member:
            if i.isDerivedFrom("Fem::FemMeshObject"):
                self.MeshObject = i
                break

        self.suitable_results = False
        if self.result_object:
            if (self.MeshObject.FemMesh.NodeCount == len(
                    self.result_object.NodeNumbers)):
                self.suitable_results = True
            else:
                if not self.MeshObject.FemMesh.VolumeCount:
                    FreeCAD.Console.PrintError(
                        'Only 3D FEM or CFD Meshes are supported!\n')
                else:
                    FreeCAD.Console.PrintError(
                        'Result node numbers are not equal to FEM Mesh NodeCount!\n'
                    )
Esempio n. 32
0
 def result_mesh_present(self):
     result_mesh = False
     analysis_members = FemGui.getActiveAnalysis().Group
     for o in analysis_members:
         if femutils.is_of_type(o, 'Fem::FemMeshResult'):
             result_mesh = True
     return result_mesh
Esempio n. 33
0
    def __init__(self, analysis=None, solver=None):
        if analysis and analysis.isDerivedFrom("Fem::FemAnalysisPython"):
            ## @var analysis
            #  FEM analysis - the core object. Has to be present.
            #  It's set to analysis passed in "__init__" or set to current active analysis by default if nothing has been passed to "__init__"
            self.analysis = analysis
        else:
            if FreeCAD.GuiUp:
                import FemGui
                self.analysis = FemGui.getActiveAnalysis()

        self.solver = None
        if solver and solver.isDerivedFrom("Fem::FemSolverObjectPython"):
            ## @var solver
            #  solver of the analysis. Used to store the active solver and analysis parameters
            self.solver = solver
        else:
            if analysis:
                self.solver = CfdTools.getSolver(self.analysis)
            if self.solver == None:
                FreeCAD.Console.printMessage(
                    "FemSolver object is missing from Analysis Object")

        if self.analysis:
            self.results_present = False
            self.result_object = None
        else:
            raise Exception('FEM: No active analysis found!')
    def calculixFinished(self,exitCode):
        print "calculixFinished()",exitCode
        print self.Calculix.state()
        out = self.Calculix.readAllStandardOutput()
        print out
        if out:
            self.femConsoleMessage(unicode(out).replace('\n','<br>'))

        self.Timer.stop()
        
        self.femConsoleMessage("Calculix done!", "#00FF00")

        self.form.pushButton_generate.setText("Re-run Calculix")
        print "Loading results...."
        self.femConsoleMessage("Loading result sets...")
        self.form.label_Time.setText('Time: {0:4.1f}: '.format(time.time() - self.Start) )

        if os.path.isfile(self.Basename + '.frd'):
            QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
            CalculixLib.importFrd(self.Basename + '.frd',FemGui.getActiveAnalysis() )
            QApplication.restoreOverrideCursor()
            self.femConsoleMessage("Loading results done!", "#00FF00")
        else:
            self.femConsoleMessage("Loading results failed! Results file doesn\'t exist", "#FF0000")
        self.form.label_Time.setText('Time: {0:4.1f}: '.format(time.time() - self.Start) )
Esempio n. 35
0
    def calculixFinished(self, exitCode):
        print "calculixFinished()", exitCode
        print self.Calculix.state()

        # Restore previous cwd
        QtCore.QDir.setCurrent(self.cwd)

        self.printCalculiXstdout()
        self.Timer.stop()

        self.femConsoleMessage("Calculix done!", "#00AA00")

        self.form.pushButton_generate.setText("Re-run Calculix")
        print "Loading results...."
        self.femConsoleMessage("Loading result sets...")
        self.form.label_Time.setText('Time: {0:4.1f}: '.format(time.time() -
                                                               self.Start))
        purge_fem_results()
        reset_mesh_color()
        reset_mesh_deformation()
        if os.path.isfile(self.base_name + '.frd'):
            QApplication.setOverrideCursor(Qt.WaitCursor)
            ccxFrdReader.importFrd(self.base_name + '.frd',
                                   FemGui.getActiveAnalysis())
            QApplication.restoreOverrideCursor()
            self.femConsoleMessage("Loading results done!", "#00AA00")
        else:
            self.femConsoleMessage(
                "Loading results failed! Results file doesn\'t exist",
                "#FF0000")
        self.form.label_Time.setText('Time: {0:4.1f}: '.format(time.time() -
                                                               self.Start))
Esempio n. 36
0
 def result_mesh_present(self):
     result_mesh = False
     analysis_members = FemGui.getActiveAnalysis().Group
     for o in analysis_members:
         if is_of_type(o, "Fem::MeshResult"):
             result_mesh = True
     return result_mesh
Esempio n. 37
0
 def Activated(self):
     sel = FreeCADGui.Selection.getSelection()
     if len(sel) == 1 and sel[0].isDerivedFrom("App::MaterialObjectPython"):
         lin_mat_obj = sel[0]
         # check if an nonlinear material exists which is based on the selected material already
         allow_nonlinear_material = True
         for o in FreeCAD.ActiveDocument.Objects:
             if hasattr(o, "Proxy") and o.Proxy is not None and o.Proxy.Type == "FemMaterialMechanicalNonlinear" and o.LinearBaseMaterial == lin_mat_obj:
                 FreeCAD.Console.PrintError(o.Name + ' is based on the selected material: ' + lin_mat_obj.Name + '. Only one nonlinear object for each material allowed.\n')
                 allow_nonlinear_material = False
                 break
         if allow_nonlinear_material:
             string_lin_mat_obj = "FreeCAD.ActiveDocument.getObject('" + lin_mat_obj.Name + "')"
             command_to_run = "FemGui.getActiveAnalysis().addObject(ObjectsFem.makeMaterialMechanicalNonlinear(FreeCAD.ActiveDocument, " + string_lin_mat_obj + "))"
             FreeCAD.ActiveDocument.openTransaction("Create FemMaterialMechanicalNonlinear")
             FreeCADGui.addModule("ObjectsFem")
             FreeCADGui.doCommand(command_to_run)
         # set some property of the solver to nonlinear (only if one solver is available and if this solver is a CalculiX solver):
         # nonlinear material
         # nonlinear geometry --> its is triggered anyway https://forum.freecadweb.org/viewtopic.php?f=18&t=23101&p=180489#p180489
         solver_object = None
         for m in FemGui.getActiveAnalysis().Group:
             if m.isDerivedFrom('Fem::FemSolverObjectPython'):
                 if not solver_object:
                     solver_object = m
                 else:
                     # we do not change attributes if we have more than one solver, since we do not know which one to take
                     solver_object = None
                     break
         if solver_object and solver_object.SolverType == 'FemSolverCalculix':
             solver_object.MaterialNonlinearity = "nonlinear"
             solver_object.GeometricalNonlinearity = "nonlinear"
Esempio n. 38
0
 def update(self):
     self.MeshObject = None
     for i in FemGui.getActiveAnalysis().Member:
         if i.isDerivedFrom("Fem::FemMeshObject"):
             self.MeshObject = i
         elif i.isDerivedFrom('Fem::FemResultObject'):
             self.result_object = i
Esempio n. 39
0
 def result_mesh_present(self):
     result_mesh = False
     analysis_members = FemGui.getActiveAnalysis().Group
     for o in analysis_members:
         if femutils.is_of_type(o, 'Fem::FemMeshResult'):
             result_mesh = True
     return result_mesh
Esempio n. 40
0
 def active_analysis_in_active_doc(self):
     analysis = FemGui.getActiveAnalysis()
     if analysis.Document is FreeCAD.ActiveDocument:
         self.active_analysis = analysis
         return True
     else:
         return False
Esempio n. 41
0
 def Activated(self):
     import _JobControlTaskPanel
     taskd = _JobControlTaskPanel._JobControlTaskPanel(
         FemGui.getActiveAnalysis())
     #taskd.obj = vobj.Object
     taskd.update()
     FreeCADGui.Control.showDialog(taskd)
Esempio n. 42
0
    def update(self):
        self.MeshObject = None
        self.result_object = get_results_object(
            FreeCADGui.Selection.getSelection())
        for i in FemGui.getActiveAnalysis().Member:
            if i.isDerivedFrom("Fem::FemMeshObject"):
                self.MeshObject = i
                break

        self.suitable_results = False
        if self.result_object:
            # Disable temperature radio button if it does ot exist in results
            if len(self.result_object.Temperature) == 1:
                self.form.rb_temperature.setEnabled(0)

            if (self.MeshObject.FemMesh.NodeCount == len(
                    self.result_object.NodeNumbers)):
                self.suitable_results = True
            else:
                if not self.MeshObject.FemMesh.VolumeCount:
                    FreeCAD.Console.PrintError(
                        'FEM: Graphical bending stress output for beam or shell FEM Meshes not yet supported.\n'
                    )
                else:
                    FreeCAD.Console.PrintError(
                        'FEM: Result node numbers are not equal to FEM Mesh NodeCount.\n'
                    )
        else:
            error_message = 'FEM: Result task panel, no result object to display results for.\n'
            FreeCAD.Console.PrintError(error_message)
            QtGui.QMessageBox.critical(None, 'No result object', error_message)
Esempio n. 43
0
    def calculixFinished(self, exitCode):
        print "calculixFinished()", exitCode
        print self.Calculix.state()

        # Restore previous cwd
        QtCore.QDir.setCurrent(self.cwd)

        self.printCalculiXstdout()
        self.Timer.stop()

        self.femConsoleMessage("Calculix done!", "#00AA00")

        self.form.pushButton_generate.setText("Re-run Calculix")
        print "Loading results...."
        self.femConsoleMessage("Loading result sets...")
        self.form.label_Time.setText('Time: {0:4.1f}: '.format(time.time() - self.Start))
        fea = FemTools()
        fea.reset_all()
        frd_result_file = os.path.splitext(self.inp_file_name)[0] + '.frd'
        if os.path.isfile(frd_result_file):
            QApplication.setOverrideCursor(Qt.WaitCursor)
            ccxFrdReader.importFrd(frd_result_file, FemGui.getActiveAnalysis())
            QApplication.restoreOverrideCursor()
            self.femConsoleMessage("Loading results done!", "#00AA00")
        else:
            self.femConsoleMessage("Loading results failed! Results file doesn\'t exist", "#FF0000")
        self.form.label_Time.setText('Time: {0:4.1f}: '.format(time.time() - self.Start))
Esempio n. 44
0
 def update(self):
     self.MeshObject = None
     for i in FemGui.getActiveAnalysis().Member:
         if i.isDerivedFrom("Fem::FemMeshObject"):
             self.MeshObject = i
         elif i.isDerivedFrom('Fem::FemResultObject'):
             self.result_object = i
Esempio n. 45
0
    def __init__(self, analysis=None, test_mode=False):
        QtCore.QRunnable.__init__(self)
        QtCore.QObject.__init__(self)

        if analysis:
            ## @var analysis
            #  FEM analysis - the core object. Has to be present.
            #  It's set to analysis passed in "__init__" or set to current active analysis by default if nothing has been passed to "__init__".
            self.analysis = analysis
        else:
            import FemGui
            self.analysis = FemGui.getActiveAnalysis()
        if self.analysis:
            self.update_objects()
            self.set_analysis_type()
            self.set_eigenmode_parameters()
            ## @var base_name
            #  base name of .inp/.frd file (without extension). It is used to construct .inp file path that is passed to CalculiX ccx
            self.base_name = ""
            ## @var results_present
            #  boolean variable indicating if there are calculation results ready for use
            self.results_present = False
            self.setup_working_dir()
            if test_mode:
                self.ccx_binary_present = True
            else:
                self.ccx_binary_present = False
                self.setup_ccx()
            self.result_object = None
        else:
            raise Exception('FEM: No active analysis found!')
Esempio n. 46
0
    def Activated(self):
        import FemGui

        taskd = _JobControlTaskPanel(FemGui.getActiveAnalysis())
        #taskd.obj = vobj.Object
        taskd.update()
        FreeCADGui.Control.showDialog(taskd)
Esempio n. 47
0
    def __init__(self, analysis=None, test_mode=False):
        if analysis:
            ## @var analysis
            #  FEM analysis - the core object. Has to be present.
            #  It's set to analysis passed in "__init__" or set to current active analysis by default if nothing has been passed to "__init__".
            self.analysis = analysis
        else:
            import FemGui
            self.analysis = FemGui.getActiveAnalysis()
        if self.analysis:
            self.update_objects()
            self.base_name = ""
            if self.solver:
                self.set_analysis_type()
                self.setup_working_dir()
                self.setup_z88()
            else:
                raise Exception('FEM: No solver found!')
        else:
            raise Exception('FEM: No active analysis found!')

        self.z88_is_running = False
        self.z88_testrun = QtCore.QProcess()
        self.z88_solverun = QtCore.QProcess()
        QtCore.QObject.connect(self.z88_testrun, QtCore.SIGNAL("started()"), self.z88_testrun_started)
        QtCore.QObject.connect(self.z88_testrun, QtCore.SIGNAL("finished(int)"), self.z88_testrun_finished)
        QtCore.QObject.connect(self.z88_solverun, QtCore.SIGNAL("started()"), self.z88_solverun_started)
        QtCore.QObject.connect(self.z88_solverun, QtCore.SIGNAL("finished(int)"), self.z88_solverun_finished)
 def Activated(self):
     sel = FreeCADGui.Selection.getSelection()
     if len(sel) == 1 and sel[0].isDerivedFrom("App::MaterialObjectPython"):
         lin_mat_obj = sel[0]
         # check if an nonlinear material exists which is based on the selected material already
         allow_nonlinear_material = True
         for o in FreeCAD.ActiveDocument.Objects:
             if hasattr(o, "Proxy") and o.Proxy is not None and o.Proxy.Type == "FemMaterialMechanicalNonlinear" and o.LinearBaseMaterial == lin_mat_obj:
                 FreeCAD.Console.PrintError(o.Name + ' is based on the selected material: ' + lin_mat_obj.Name + '. Only one nonlinear object for each material allowed.\n')
                 allow_nonlinear_material = False
                 break
         if allow_nonlinear_material:
             string_lin_mat_obj = "App.ActiveDocument.getObject('" + lin_mat_obj.Name + "')"
             command_to_run = "FemGui.getActiveAnalysis().Member = FemGui.getActiveAnalysis().Member + [FemMaterialMechanicalNonlinear.makeFemMaterialMechanicalNonlinear(" + string_lin_mat_obj + ")]"
             FreeCAD.ActiveDocument.openTransaction("Create FemMaterialMechanicalNonlinear")
             FreeCADGui.addModule("FemMaterialMechanicalNonlinear")
             FreeCADGui.doCommand(command_to_run)
         # set the material nonlinear property of the solver to nonlinear if only one solver is available and if this solver is a CalculiX solver
         solver_object = None
         for m in FemGui.getActiveAnalysis().Member:
             if m.isDerivedFrom('Fem::FemSolverObjectPython'):
                 if not solver_object:
                     solver_object = m
                 else:
                     # we do not change the material nonlinear attribut if we have more than one solver
                     solver_object = None
                     break
         if solver_object and solver_object.SolverType == 'FemSolverCalculix':
             solver_object.MaterialNonlinearity = "nonlinear"
    def calculixFinished(self,exitCode):
        print "calculixFinished()",exitCode
        print self.Calculix.state()
        out = self.Calculix.readAllStandardOutput()
        print out
        if out:
            self.OutStr = self.OutStr + unicode(out).replace('\n','<br>')
            self.formUi.textEdit_Output.setText(self.OutStr)

        self.Timer.stop()
        
        self.OutStr = self.OutStr + '<font color="#0000FF">{0:4.1f}:</font> '.format(time.time() - self.Start) + '<font color="#00FF00">Calculix done!</font><br>'
        self.formUi.textEdit_Output.setText(self.OutStr)

        self.formUi.pushButton_generate.setText("Re-run Calculix")
        print "Loading results...."
        self.OutStr = self.OutStr + '<font color="#0000FF">{0:4.1f}:</font> '.format(time.time() - self.Start) + 'Loading result sets...<br>'
        self.formUi.textEdit_Output.setText(self.OutStr)
        self.formUi.label_Time.setText('Time: {0:4.1f}: '.format(time.time() - self.Start) )

        QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
        CalculixLib.importFrd(self.Basename + '.frd',FemGui.getActiveAnalysis() )
        QApplication.restoreOverrideCursor()
        self.OutStr = self.OutStr + '<font color="#0000FF">{0:4.1f}:</font> '.format(time.time() - self.Start) + '<font color="#00FF00">Loading results done!</font><br>'
        self.formUi.textEdit_Output.setText(self.OutStr)
        self.formUi.label_Time.setText('Time: {0:4.1f}: '.format(time.time() - self.Start) )
Esempio n. 50
0
def results_present():
    results = False
    analysis_members = FemGui.getActiveAnalysis().Member
    for o in analysis_members:
        if o.isDerivedFrom('Fem::FemResultObject'):
            results = True
    return results
Esempio n. 51
0
def hide_parts_constraints():
    fem_prefs = FreeCAD.ParamGet(
        "User parameter:BaseApp/Preferences/Mod/Fem/General")
    hide_constraints = fem_prefs.GetBool("HideConstraint", False)
    if hide_constraints:
        for acnstrmesh in FemGui.getActiveAnalysis().Member:
            if "Constraint" in acnstrmesh.TypeId:
                acnstrmesh.ViewObject.Visibility = False
Esempio n. 52
0
 def doubleClicked(self, vobj):
     doc = FreeCADGui.getDocument(vobj.Object.Document)
     if not doc.getInEdit():
         # may be go the other way around and just activate the analysis the user has doubleClicked on ?!
         if FemGui.getActiveAnalysis() is not None:
             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('No active Analysis found!\n')
     else:
         FreeCAD.Console.PrintError('Active Task Dialog found! Please close this one first!\n')
     return True
Esempio n. 53
0
 def result_selected(self):
     sel = FreeCADGui.Selection.getSelection()
     if len(sel) == 1 and sel[0].isDerivedFrom("Fem::FemResultObject"):
         for o in FemGui.getActiveAnalysis().Group:
             if o == sel[0]:
                 self.selobj = o
                 return True
     return False
Esempio n. 54
0
    def update(self):
        self.MeshObject = None
        self.result_object = get_results_object(FreeCADGui.Selection.getSelection())

        for i in FemGui.getActiveAnalysis().Member:
            if i.isDerivedFrom("Fem::FemMeshObject"):
                self.MeshObject = i
                break
def makeFemConstraintSelfWeight(name="FemConstraintSelfWeight"):
    '''makeFemFemConstraintSelfWeight([name]): creates an beamsection object to define a cross section'''
    obj = FemGui.getActiveAnalysis().Document.addObject("Fem::FeaturePython", name)
    _FemConstraintSelfWeight._FemConstraintSelfWeight(obj)
    if FreeCAD.GuiUp:
        import _ViewProviderFemConstraintSelfWeight
        _ViewProviderFemConstraintSelfWeight._ViewProviderFemConstraintSelfWeight(obj.ViewObject)
    return obj
Esempio n. 56
0
def reset_mesh_color(mesh=None):
    if mesh is None:
        for i in FemGui.getActiveAnalysis().Member:
            if i.isDerivedFrom("Fem::FemMeshObject"):
                mesh = i
    mesh.ViewObject.NodeColor = {}
    mesh.ViewObject.ElementColor = {}
    mesh.ViewObject.setNodeColorByResult()
    def update(self):
        'fills the widgets'

        self.MeshObject = None
        if FemGui.getActiveAnalysis():
            for i in FemGui.getActiveAnalysis().Member:
                if i.isDerivedFrom("Fem::FemMeshObject"):
                    self.MeshObject = i

        for i in FemGui.getActiveAnalysis().Member:
            if i.isDerivedFrom("Fem::FemResultVector"):
                if i.DataType == 'Displacement':
                    self.DisplacementObject = i
        for i in FemGui.getActiveAnalysis().Member:
            if i.isDerivedFrom("Fem::FemResultValue"):
                if i.DataType == 'VanMisesStress':
                    self.StressObject = i
Esempio n. 58
0
    def update(self):
        'fills the widgets'

        self.MeshObject = None
        if FemGui.getActiveAnalysis():
            for i in FemGui.getActiveAnalysis().Member:
                if i.isDerivedFrom("Fem::FemMeshObject"):
                    self.MeshObject = i

        for i in FemGui.getActiveAnalysis().Member:
            if i.isDerivedFrom("Fem::FemResultVector"):
                if i.DataType == 'Displacement':
                    self.DisplacementObject = i
        for i in FemGui.getActiveAnalysis().Member:
            if i.isDerivedFrom("Fem::FemResultValue"):
                if i.DataType == 'VanMisesStress':
                    self.StressObject = i
 def Activated(self):
     femDoc = FemGui.getActiveAnalysis().Document
     if FreeCAD.ActiveDocument is not femDoc:
         FreeCADGui.setActiveDocument(femDoc)
     FreeCAD.ActiveDocument.openTransaction("Create Solid Material")
     FreeCADGui.addModule("ObjectsFem")
     FreeCADGui.doCommand(
         "ObjectsFem.makeMaterialSolid(FreeCAD.ActiveDocument, 'SolidMaterial')"
     )
     FreeCADGui.doCommand("FreeCAD.ActiveDocument." +
                          FemGui.getActiveAnalysis().Name +
                          ".Member = FreeCAD.ActiveDocument." +
                          FemGui.getActiveAnalysis().Name +
                          ".Member + [FreeCAD.ActiveDocument.ActiveObject]")
     FreeCADGui.doCommand(
         "FreeCADGui.ActiveDocument.setEdit(FreeCAD.ActiveDocument.ActiveObject.Name)"
     )
 def doubleClicked(self, vobj):
     doc = FreeCADGui.getDocument(vobj.Object.Document)
     if not doc.getInEdit():
         # may be go the other way around and just activate the analysis the user has doubleClicked on ?!
         if FemGui.getActiveAnalysis() is not None:
             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('No active Analysis found!\n')
     else:
         FreeCAD.Console.PrintError('Active Task Dialog found! Please close this one first!\n')
     return True