Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/changelog.d/1253.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Relative path for saving
10 changes: 10 additions & 0 deletions src/ansys/mechanical/core/embedding/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,9 +302,15 @@ def open(self, db_file, remove_lock=False):
def save(self, path=None):
"""Save the project."""
if path is not None:
if os.path.isabs(path):
self.DataModel.Project.Save(path)
else:
cwd = os.getcwd()
path = os.path.join(cwd, path)
self.DataModel.Project.Save(path)
else:
self.DataModel.Project.Save()
LOG.info(f"Project saved to {path}")

def save_as(self, path: str, overwrite: bool = False, remove_lock: bool = False):
"""
Expand All @@ -331,6 +337,9 @@ def save_as(self, path: str, overwrite: bool = False, remove_lock: bool = False)
For version 232, if `overwrite` is True, the existing file and its associated directory
(if any) will be removed before saving the new file.
"""
if not os.path.isabs(path):
cwd = os.getcwd()
path = os.path.join(cwd, path)
if not os.path.exists(path):
self.DataModel.Project.SaveAs(path)
return
Expand Down Expand Up @@ -373,6 +382,7 @@ def save_as(self, path: str, overwrite: bool = False, remove_lock: bool = False)
else:
self.log_error(f"Failed to save project as {path}: {error_msg}")
raise e
LOG.info(f"Project saved as {path}")

def launch_gui(self, delete_tmp_on_close: bool = True, dry_run: bool = False):
"""Launch the GUI."""
Expand Down
Loading