Skip to content

Commit 0a03146

Browse files
authored
FEAT: new property file/dir project path (#748)
Co-authored-by: ring630 <@gmail.com>
1 parent cbefee6 commit 0a03146

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

src/pyedb/siwave.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,16 @@ def open_project(self, proj_path=None):
266266
else:
267267
return False
268268

269+
@property
270+
def file_dir(self) -> str:
271+
"""Directory path of the open project."""
272+
return self.oproject.GetFileDir()
273+
274+
@property
275+
def file_path(self) -> str:
276+
"""Path of the open project file."""
277+
return self.oproject.GetFilePath()
278+
269279
def save_project(self, projectpath=None, projectName=None):
270280
"""Save the project.
271281
@@ -283,7 +293,9 @@ def save_project(self, projectpath=None, projectName=None):
283293
284294
"""
285295
if projectName and projectpath:
286-
self.oproject.ScrSaveProjectAs(os.path.join(projectpath, projectName + ".siw"))
296+
if not projectName.endswith(".siw"):
297+
projectName = projectName + ".siw"
298+
self.oproject.ScrSaveProjectAs(os.path.join(projectpath, projectName))
287299
else:
288300
self.oproject.Save()
289301
return True
@@ -476,6 +488,7 @@ def import_edb(self, file_path: str):
476488
if isinstance(file_path, Path):
477489
file_path = str(file_path)
478490
flag = self.oproject.ScrImportEDB(file_path)
491+
# self.save_project(self.di)
479492
if flag == 0:
480493
self._logger.info(f"Importing EDB to {file_path}.")
481494
return True
@@ -493,11 +506,12 @@ def load_configuration(self, file_path: str):
493506
if isinstance(file_path, Path):
494507
file_path = str(file_path)
495508

496-
temp_folder = tempfile.TemporaryDirectory(suffix=".ansys")
497-
temp_edb = os.path.join(temp_folder.name, "temp.aedb")
509+
# temp_folder = tempfile.TemporaryDirectory(suffix=".ansys")
510+
# temp_edb = os.path.join(temp_folder.name, "temp.aedb")
511+
512+
temp_edb = os.path.join(self.file_dir, "temp.aedb")
498513

499514
self.export_edb(temp_edb)
500-
self.save_project()
501515
self.oproject.ScrCloseProject()
502516
edbapp = Edb(temp_edb, edbversion=self.current_version)
503517
edbapp.configuration.load(file_path)

0 commit comments

Comments
 (0)