FEM: examplegui modified to setup different solvers
... based on the selection by user
This commit is contained in:
committed by
Bernd Hahnebach
parent
630208e879
commit
21aefcbed6
@@ -173,9 +173,17 @@ class FemExamples(QtGui.QWidget):
|
||||
item = self.view.selectedItems()[0]
|
||||
name = item.text(0)
|
||||
example = self.files_name[name]
|
||||
solver = "ccxtools"
|
||||
parent = item.parent()
|
||||
if parent is not None:
|
||||
grand_parent = parent.parent()
|
||||
if grand_parent is not None:
|
||||
grand_parent_name = grand_parent.text(0)
|
||||
if grand_parent_name == "Solvers":
|
||||
solver = parent.text(0)
|
||||
# if done this way the Python commands are printed in Python console
|
||||
FreeCADGui.doCommand("from femexamples." + str(example) + " import setup")
|
||||
FreeCADGui.doCommand("setup()")
|
||||
FreeCADGui.doCommand("from femexamples.{} import setup".format(str(example)))
|
||||
FreeCADGui.doCommand("setup(solvertype=\"{}\")".format(str(solver)))
|
||||
|
||||
def reject(self):
|
||||
self.close()
|
||||
@@ -189,9 +197,17 @@ class FemExamples(QtGui.QWidget):
|
||||
item = self.view.selectedItems()[0]
|
||||
name = item.text(0)
|
||||
example = self.files_name[name]
|
||||
solver = "ccxtools"
|
||||
parent = item.parent()
|
||||
if parent is not None:
|
||||
grand_parent = parent.parent()
|
||||
if grand_parent is not None:
|
||||
grand_parent_name = grand_parent.text(0)
|
||||
if grand_parent_name == "Solvers":
|
||||
solver = parent.text(0)
|
||||
# if done this way the Python commands are printed in Python console
|
||||
FreeCADGui.doCommand("from femexamples.manager import run_example")
|
||||
FreeCADGui.doCommand("run_example(\"" + str(example) + "\")")
|
||||
FreeCADGui.doCommand("run_example(\"{}\", solver=\"{}\")".format(str(example), str(solver)))
|
||||
|
||||
def enable_buttons(self):
|
||||
# only enable buttons if a example is selected
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
# ***************************************************************************
|
||||
# * Copyright (c) 2019 Bernd Hahnebach <bernd@bimstatik.org> *
|
||||
# * Copyright (c) 2020 Sudhanshu Dubey <sudhanshu.thethunder@gmail.com> *
|
||||
# * *
|
||||
# * This file is part of the FreeCAD CAx development system. *
|
||||
# * *
|
||||
@@ -90,7 +91,10 @@ def run_example(example, solver=None, base_name=None):
|
||||
from importlib import import_module
|
||||
module = import_module("femexamples." + example)
|
||||
if hasattr(module, "setup"):
|
||||
doc = getattr(module, "setup")()
|
||||
if solver is None:
|
||||
doc = getattr(module, "setup")()
|
||||
else:
|
||||
doc = getattr(module, "setup")(solvertype=solver)
|
||||
|
||||
if base_name is None:
|
||||
base_name = example
|
||||
|
||||
Reference in New Issue
Block a user