Fem: Update command FEM_SolverRun
This commit is contained in:
@@ -29,6 +29,9 @@ __url__ = "https://www.freecad.org"
|
||||
# \ingroup FEM
|
||||
# \brief FreeCAD FEM command definitions
|
||||
|
||||
from PySide import QtCore
|
||||
from PySide import QtGui
|
||||
|
||||
import FreeCAD
|
||||
import FreeCADGui
|
||||
from FreeCAD import Qt
|
||||
@@ -1162,13 +1165,44 @@ class _SolverRun(CommandManager):
|
||||
"FEM_SolverRun", "Runs the calculations for the selected solver"
|
||||
)
|
||||
self.is_active = "with_solver"
|
||||
self.tool = None
|
||||
|
||||
def Activated(self):
|
||||
from femsolver.run import run_fem_solver
|
||||
if self.selobj.Proxy.Type == "Fem::SolverCalculiX":
|
||||
QtGui.QApplication.setOverrideCursor(QtCore.Qt.WaitCursor)
|
||||
try:
|
||||
from femsolver.calculix.calculixtools import CalculiXTools
|
||||
|
||||
run_fem_solver(self.selobj)
|
||||
FreeCADGui.Selection.clearSelection()
|
||||
FreeCAD.ActiveDocument.recompute()
|
||||
self.tool = CalculiXTools(self.selobj)
|
||||
self._conn(self.tool)
|
||||
self.tool.prepare()
|
||||
self.tool.compute()
|
||||
except Exception as e:
|
||||
QtGui.QApplication.restoreOverrideCursor()
|
||||
raise
|
||||
|
||||
else:
|
||||
from femsolver.run import run_fem_solver
|
||||
|
||||
run_fem_solver(self.selobj)
|
||||
FreeCADGui.Selection.clearSelection()
|
||||
FreeCAD.ActiveDocument.recompute()
|
||||
|
||||
def _conn(self, tool):
|
||||
QtCore.QObject.connect(
|
||||
tool.process,
|
||||
QtCore.SIGNAL("finished(int, QProcess::ExitStatus)"),
|
||||
self._process_finished,
|
||||
)
|
||||
|
||||
def _process_finished(self, code, status):
|
||||
if status == QtCore.QProcess.ExitStatus.NormalExit and code == 0:
|
||||
self.tool.update_properties()
|
||||
FreeCAD.ActiveDocument.recompute()
|
||||
QtGui.QApplication.restoreOverrideCursor()
|
||||
else:
|
||||
QtGui.QApplication.restoreOverrideCursor()
|
||||
FreeCAD.Console.PrintError("Process finished with errors. Result not updated\n")
|
||||
|
||||
|
||||
class _SolverZ88(CommandManager):
|
||||
|
||||
Reference in New Issue
Block a user