FEM: Add WorkingDir property
that allows to set individual directory to be used for each analysis object Signed-off-by: Przemo Firszt <przemo@firszt.eu>
This commit is contained in:
parent
8055b189be
commit
26cd01e346
|
@ -325,7 +325,11 @@ class FemTools(QtCore.QRunnable, QtCore.QObject):
|
|||
if working_dir is not None:
|
||||
self.working_dir = working_dir
|
||||
else:
|
||||
self.working_dir = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Fem").GetString("WorkingDir")
|
||||
try:
|
||||
self.working_dir = self.analysis.WorkingDir
|
||||
except:
|
||||
FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Fem").GetString("WorkingDir")
|
||||
self.working_dir = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Fem").GetString("WorkingDir")
|
||||
|
||||
if not (os.path.isdir(self.working_dir)):
|
||||
try:
|
||||
|
|
|
@ -38,6 +38,8 @@ class _FemAnalysis:
|
|||
obj.AnalysisType = FemTools.known_analysis_types
|
||||
analysis_type = fem_prefs.GetInt("AnalysisType", 0)
|
||||
obj.AnalysisType = FemTools.known_analysis_types[analysis_type]
|
||||
obj.addProperty("App::PropertyPath", "WorkingDir", "Fem", "Working directory for calculations")
|
||||
obj.WorkingDir = fem_prefs.GetString("WorkingDir", "")
|
||||
|
||||
def execute(self, obj):
|
||||
return
|
||||
|
|
|
@ -55,7 +55,6 @@ class _JobControlTaskPanel:
|
|||
else:
|
||||
self.CalculixBinary = 'ccx'
|
||||
self.fem_prefs = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Fem")
|
||||
self.working_dir = self.fem_prefs.GetString("WorkingDir", '/tmp')
|
||||
|
||||
self.analysis_object = analysis_object
|
||||
|
||||
|
@ -160,7 +159,7 @@ class _JobControlTaskPanel:
|
|||
|
||||
def update(self):
|
||||
'fills the widgets'
|
||||
self.form.le_working_dir.setText(self.working_dir)
|
||||
self.form.le_working_dir.setText(self.analysis_object.WorkingDir)
|
||||
if self.analysis_object.AnalysisType == 'static':
|
||||
self.form.rb_static_analysis.setChecked(True)
|
||||
elif self.analysis_object.AnalysisType == 'frequency':
|
||||
|
@ -174,7 +173,7 @@ class _JobControlTaskPanel:
|
|||
FreeCADGui.Control.closeDialog()
|
||||
|
||||
def choose_working_dir(self):
|
||||
current_wd = get_working_dir()
|
||||
current_wd = self.setup_working_dir()
|
||||
wd = QtGui.QFileDialog.getExistingDirectory(None, 'Choose CalculiX working directory',
|
||||
current_wd)
|
||||
if wd:
|
||||
|
@ -262,17 +261,15 @@ class _JobControlTaskPanel:
|
|||
def select_frequency_analysis(self):
|
||||
self.select_analysis_type('frequency')
|
||||
|
||||
|
||||
#Code duplication!!!!
|
||||
def get_working_dir():
|
||||
fem_prefs = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Fem")
|
||||
working_dir = fem_prefs.GetString("WorkingDir", "")
|
||||
if not (os.path.isdir(working_dir)):
|
||||
try:
|
||||
os.path.makedirs(working_dir)
|
||||
except:
|
||||
print ("Dir \'{}\' from FEM preferences doesn't exist and cannot be created.".format(working_dir))
|
||||
import tempfile
|
||||
working_dir = tempfile.gettempdir()
|
||||
print ("Dir \'{}\' will be used instead.".format(working_dir))
|
||||
return working_dir
|
||||
# That function overlaps with FemTools setup_working_dir and needs to be removed when we migrate fully to FemTools
|
||||
def setup_working_dir(self):
|
||||
wd = self.analysis_object.WorkingDir
|
||||
if not (os.path.isdir(wd)):
|
||||
try:
|
||||
os.makedirs(wd)
|
||||
except:
|
||||
print ("Dir \'{}\' from FEM preferences doesn't exist and cannot be created.".format(wd))
|
||||
import tempfile
|
||||
wd = tempfile.gettempdir()
|
||||
print ("Dir \'{}\' will be used instead.".format(wd))
|
||||
return wd
|
||||
|
|
Loading…
Reference in New Issue
Block a user