Skip to content

FIX: Copy Design #5623 #5993

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Apr 2, 2025
Merged
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/5993.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Copy Design #5623
2 changes: 1 addition & 1 deletion src/ansys/aedt/core/application/design.py
Original file line number Diff line number Diff line change
Expand Up @@ -3639,7 +3639,7 @@
if set_active_design:
self._close_edb()
self._init_design(project_name=self.project_name, design_name=new_designname)
self.set_active_design(active_design)
self.set_active_design(new_designname)

Check warning on line 3642 in src/ansys/aedt/core/application/design.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/aedt/core/application/design.py#L3642

Added line #L3642 was not covered by tests
# return the pasted design name
return new_designname

Expand Down
37 changes: 37 additions & 0 deletions src/ansys/aedt/core/desktop.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

import atexit
import datetime
from difflib import get_close_matches
import gc
import os
from pathlib import Path
Expand Down Expand Up @@ -692,6 +693,42 @@
except Exception: # pragma: no cover
return self.installed_versions[version_key + "CL"]

@pyaedt_function_handler()
def get_example(self, example_name, folder_name="."):
"""Retrieve the path to a built-in example project.

Parameters
----------
example_name : str
Name of the example for which the full path is desired.
folder_name : str, optional
Name of the example for which the full path is desired.

Returns
-------
str
Return the full path and name of the example file if found, otherwise ``None``.
"""

root = Path(self.install_path) / "Examples" / folder_name

Check warning on line 713 in src/ansys/aedt/core/desktop.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/aedt/core/desktop.py#L713

Added line #L713 was not covered by tests

# Gather all files
all_files = [f for f in root.rglob("*") if f.is_file() and not f.suffix.lower() == ".pdf"]

Check warning on line 716 in src/ansys/aedt/core/desktop.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/aedt/core/desktop.py#L716

Added line #L716 was not covered by tests

# Normalize names for fuzzy matching
filenames = [f.name.lower() for f in all_files]
name_lower = example_name.lower()

Check warning on line 720 in src/ansys/aedt/core/desktop.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/aedt/core/desktop.py#L719-L720

Added lines #L719 - L720 were not covered by tests

# Get close matches
close = get_close_matches(name_lower, filenames, n=1, cutoff=0.6)

Check warning on line 723 in src/ansys/aedt/core/desktop.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/aedt/core/desktop.py#L723

Added line #L723 was not covered by tests

if close:
match_name = close[0]

Check warning on line 726 in src/ansys/aedt/core/desktop.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/aedt/core/desktop.py#L725-L726

Added lines #L725 - L726 were not covered by tests
# Find the original Path object that matches the filename (case-insensitive)
for file in all_files:
if file.name.lower() == match_name:
return str(file.resolve())

Check warning on line 730 in src/ansys/aedt/core/desktop.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/aedt/core/desktop.py#L728-L730

Added lines #L728 - L730 were not covered by tests

@property
def logger(self):
"""AEDT logger."""
Expand Down
6 changes: 6 additions & 0 deletions tests/system/general/test_01_Design.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,12 @@ def test_15b_copy_design_from(self):
new_design = self.aedtapp.copy_design_from(origin, "myduplicateddesign")
assert new_design in self.aedtapp.design_list

def test_15c_copy_example(self):
example_name = self.aedtapp.desktop_class.get_example("5G_SIW_Aperture_Antenna")
self.aedtapp.copy_design_from(example_name, "0_5G Aperture Element")
assert self.aedtapp.design_name == "0_5G Aperture Element"
assert not self.aedtapp.desktop_class.get_example("fake")

def test_16_renamedesign(self, add_app, test_project_file):
prj_file = test_project_file(test_project_name)
self.aedtapp.load_project(file_name=prj_file, design="myname", close_active=True)
Expand Down