Skip to content

Commit

Permalink
FEM: writer base, improve working dir handling
Browse files Browse the repository at this point in the history
  • Loading branch information
berndhahnebach committed Oct 4, 2021
1 parent e60e6c3 commit fa843ad
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions src/Mod/Fem/femsolver/writerbase.py
Expand Up @@ -55,19 +55,29 @@ def __init__(
self.analysis_type = self.solver_obj.AnalysisType
self.document = self.analysis.Document
# working dir
self.dir_name = dir_name
# if dir_name was not given or if it exists but is not empty: create a temporary dir
# Purpose: makes sure the analysis can be run even on wired situation
if not dir_name:
make_tmp_dir = False
if dir_name is None:
FreeCAD.Console.PrintWarning(
"Error: The working_dir in base input file writer class was not set. "
"A temporary directory is used.\n"
)
make_tmp_dir = True
elif not os.path.isdir(dir_name):
FreeCAD.Console.PrintWarning(
"Error: FemInputWriter has no working_dir --> "
"we are going to make a temporary one!\n"
"Error: The working_dir: '{}' given to "
"base input file writer class does not exist. "
"A temporary directory is used.\n".format(dir_name)
)
self.dir_name = self.document.TransientDir.replace(
make_tmp_dir = True
if make_tmp_dir is True:
dir_name = self.document.TransientDir.replace(
"\\", "/"
) + "/FemAnl_" + analysis_obj.Uid[-4:]
if not os.path.isdir(self.dir_name):
os.mkdir(self.dir_name)

os.mkdir(dir_name)
self.dir_name = dir_name

# new class attributes
self.fc_ver = FreeCAD.Version()
Expand Down

0 comments on commit fa843ad

Please sign in to comment.