Skip to content

Commit 773afcb

Browse files
Refresh pyaedt object when design duplication (#1261)
* Refresh pyaedt object when design duplication Fix small bug in End Conenction boundary * Unittest * fixed UT * fixed UT * fixed UT on faces_by_area Co-authored-by: maxcapodi78 <Shark78>
1 parent 6026bee commit 773afcb

File tree

5 files changed

+20
-12
lines changed

5 files changed

+20
-12
lines changed

_unittest/test_01_Design.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ def test_14_get_nominal_variation(self):
130130
assert self.aedtapp.get_nominal_variation() != [] or self.aedtapp.get_nominal_variation() is not None
131131

132132
def test_15a_duplicate_design(self):
133+
self.aedtapp.duplicate_design("non_valid1", False)
133134
self.aedtapp.duplicate_design("myduplicateddesign")
134135
assert "myduplicateddesign" in self.aedtapp.design_list
135136
self.aedtapp.delete_design("myduplicateddesign", "NewDesign")
@@ -266,6 +267,7 @@ def test_29_change_registry_key(self):
266267
assert not desktop.change_registry_key("test_key", 2.0)
267268

268269
def test_30_object_oriented(self):
270+
self.aedtapp["my_oo_variable"] = "15mm"
269271
# self.aedtapp.set_active_design("myname")
270272
assert self.aedtapp.get_oo_name(self.aedtapp.oproject, "Variables")
271273
assert self.aedtapp.get_oo_name(self.aedtapp.odesign, "Variables")

_unittest/test_07_Object3D.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ def test_24_filter_faces_by_area(self):
434434
if faces_greater_equal:
435435
for face_object in faces_greater_equal:
436436
for face in face_object:
437-
assert (face.area - 100) >= 1e-12
437+
assert (face.area - 100) >= -1e-12
438438

439439
faces_smaller_equal = []
440440
for obj in self.aedtapp.modeler.object_list:
@@ -447,21 +447,21 @@ def test_24_filter_faces_by_area(self):
447447

448448
faces_greater = []
449449
for obj in self.aedtapp.modeler.object_list:
450-
if obj.faces_by_area(100):
451-
faces_greater.append(obj.faces_by_area(100, ">"))
450+
if obj.faces_by_area(99):
451+
faces_greater.append(obj.faces_by_area(99, ">"))
452452
if faces_greater:
453453
for face_object in faces_greater:
454454
for face in face_object:
455-
assert (face.area - 100) > 1e-12
455+
assert (face.area - 99) > 0
456456

457457
faces_smaller = []
458458
for obj in self.aedtapp.modeler.object_list:
459-
if obj.faces_by_area(100):
460-
faces_smaller.append(obj.faces_by_area(100, "<"))
459+
if obj.faces_by_area(105):
460+
faces_smaller.append(obj.faces_by_area(105, "<"))
461461
if faces_smaller:
462462
for face_object in faces_smaller:
463463
for face in face_object:
464-
assert (face.area - 100) < 1e-12
464+
assert (face.area - 105) < 0
465465

466466
if not is_ironpython:
467467
with pytest.raises(ValueError):

pyaedt/application/Design.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2922,7 +2922,7 @@ def copy_design_from(self, project_fullname, design_name):
29222922
return new_designname
29232923

29242924
@pyaedt_function_handler()
2925-
def duplicate_design(self, label):
2925+
def duplicate_design(self, label, save_after_duplicate=True):
29262926
"""Copy a design to a new name.
29272927
29282928
The new name consists of the original
@@ -2933,6 +2933,9 @@ def duplicate_design(self, label):
29332933
----------
29342934
label : str
29352935
Name of the design to copy.
2936+
save_after_duplicate : bool, optional
2937+
Save project after the duplication is completed. If ``False``, pyaedt objects like boundaries will not be
2938+
available.
29362939
29372940
Returns
29382941
-------
@@ -2960,6 +2963,9 @@ def duplicate_design(self, label):
29602963
self.design_name = newname
29612964
self._close_edb()
29622965
AedtObjects.__init__(self, is_inherithed=True)
2966+
if save_after_duplicate:
2967+
self.oproject.Save()
2968+
self._project_dictionary = None
29632969
return True
29642970

29652971
@pyaedt_function_handler()

pyaedt/modeler/Object3d.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2628,16 +2628,16 @@ def faces_by_area(self, area, area_filter="==", tolerance=1e-12):
26282628
if abs(face.area - area) < tolerance:
26292629
faces.append(face)
26302630
if area_filter == ">=":
2631-
if (face.area - area) >= tolerance:
2631+
if (face.area - area) >= -tolerance:
26322632
faces.append(face)
26332633
if area_filter == "<=":
26342634
if (face.area - area) <= tolerance:
26352635
faces.append(face)
26362636
if area_filter == ">":
2637-
if (face.area - area) > tolerance:
2637+
if (face.area - area) > 0:
26382638
faces.append(face)
26392639
if area_filter == "<":
2640-
if (face.area - area) < tolerance:
2640+
if (face.area - area) < 0:
26412641
faces.append(face)
26422642

26432643
return faces

pyaedt/modules/Boundary.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ def update(self):
590590
self._app.oboundary.SetSBRTxRxSettings(self._get_args()) # pragma: no cover
591591
elif self.type == "Floquet Port":
592592
self._app.oboundary.EditFloquetPort(self._boundary_name, self._get_args()) # pragma: no cover
593-
elif self.type == "EndConnection":
593+
elif self.type == "End Connection":
594594
self._app.oboundary.EditEndConnection(self._boundary_name, self._get_args())
595595
else:
596596
return False # pragma: no cover

0 commit comments

Comments
 (0)