Skip to content

Commit 995221b

Browse files
committed
Merge branch 'main' into rmxprt_set_material_threshold
2 parents b9595f1 + 23edbe5 commit 995221b

File tree

3 files changed

+70
-8
lines changed

3 files changed

+70
-8
lines changed

_unittest/test_00_EDB.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,12 @@ def test_08_nets_query(self):
166166
assert not signalnets[list(signalnets.keys())[0]].IsPowerGround()
167167
assert len(list(signalnets[list(signalnets.keys())[0]].primitives)) > 0
168168

169+
assert self.edbapp.core_nets.find_or_create_net("GND")
170+
assert self.edbapp.core_nets.find_or_create_net(start_with="gn")
171+
assert self.edbapp.core_nets.find_or_create_net(start_with="g", end_with="d")
172+
assert self.edbapp.core_nets.find_or_create_net(end_with="d")
173+
assert self.edbapp.core_nets.find_or_create_net(contain="usb")
174+
169175
def test_09_assign_rlc(self):
170176
assert self.edbapp.core_components.set_component_rlc(
171177
"C3B14", res_value=1e-3, cap_value="10e-6", isparallel=False

examples/02-Maxwell/Maxwell2D_NissanLeaf.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""
2-
Maxwell 2d: Magnet Transient Analysis
3-
------------------------------
2+
Maxwell 2d: PM Synchronous Motor Transient Analysis
3+
---------------------------------------------------
44
This example shows how you can use PyAEDT to create a Maxwell 2D Transient Analysis for an interior permanent magnet
55
electric motor,starting from the parameter definition through the post-processing preparation
66
Tested on pyaedt 0.4.70
@@ -455,6 +455,10 @@ def create_cs_magnets(pm_id, cs_name, point_direction):
455455
# Design Settings: Set Model Depth
456456
M2D.model_depth = "Magnetic_Axial_Length"
457457

458+
##########################################################
459+
# Design Settings: Set Symmetry Factor
460+
M2D.change_symmetry_multiplier("SymmetryFactor")
461+
458462
##########################################################
459463
# Setup: Create and Validate
460464
setup = M2D.create_setup(setupname=sName)

pyaedt/edb_core/nets.py

Lines changed: 58 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -598,27 +598,79 @@ def delete_nets(self, netlist):
598598
return nets_deleted
599599

600600
@pyaedt_function_handler()
601-
def find_or_create_net(self, net_name=""):
601+
def find_or_create_net(self, net_name="", start_with="", contain="", end_with=""):
602602
"""Find or create the net with the given name in the layout.
603603
604604
Parameters
605605
----------
606606
net_name : str, optional
607607
Name of the net to find or create. The default is ``""``.
608608
609+
start_with : str, optional
610+
All net name starting with the string. Not case-sensitive.
611+
612+
contain : str, optional
613+
All net name containing the string. Not case-sensitive.
614+
615+
end_with : str, optional
616+
All net name ending with the string. Not case-sensitive.
617+
609618
Returns
610619
-------
611620
object
612621
Net Object
613622
"""
614-
if not net_name:
623+
if not net_name and not start_with and not contain and not end_with:
615624
net_name = generate_unique_name("NET_")
616625
net = self._edb.Cell.Net.Create(self._active_layout, net_name)
626+
return net
617627
else:
618-
net = self._edb.Cell.Net.FindByName(self._active_layout, net_name)
619-
if net.IsNull():
620-
net = self._edb.Cell.Net.Create(self._active_layout, net_name)
621-
return net
628+
if not start_with and not contain and not end_with:
629+
net = self._edb.Cell.Net.FindByName(self._active_layout, net_name)
630+
if net.IsNull():
631+
net = self._edb.Cell.Net.Create(self._active_layout, net_name)
632+
return net
633+
elif start_with:
634+
nets_found = [
635+
self.nets[net].net_object for net in list(self.nets.keys()) if net.lower().startswith(start_with)
636+
]
637+
return nets_found
638+
elif start_with and end_with:
639+
nets_found = [
640+
self.nets[net].net_object
641+
for net in list(self.nets.keys())
642+
if net.lower().startswith(start_with) and net.lower().endswith(end_with)
643+
]
644+
return nets_found
645+
elif start_with and contain and end_with:
646+
nets_found = [
647+
self.nets[net].net_object
648+
for net in list(self.nets.keys())
649+
if net.lower().startswith(start_with) and net.lower().endswith(end_with) and contain in net.lower()
650+
]
651+
return nets_found
652+
elif start_with and contain:
653+
nets_found = [
654+
self.nets[net].net_object
655+
for net in list(self.nets.keys())
656+
if net.lower().startswith(start_with) and contain in net.lower()
657+
]
658+
return nets_found
659+
elif contain and end_with:
660+
nets_found = [
661+
self.nets[net].net_object
662+
for net in list(self.nets.keys())
663+
if net.lower().endswith(end_with) and contain in net.lower()
664+
]
665+
return nets_found
666+
elif end_with and not start_with and not contain:
667+
nets_found = [
668+
self.nets[net].net_object for net in list(self.nets.keys()) if net.lower().endswith(end_with)
669+
]
670+
return nets_found
671+
elif contain and not start_with and not end_with:
672+
nets_found = [self.nets[net].net_object for net in list(self.nets.keys()) if contain in net.lower()]
673+
return nets_found
622674

623675
@pyaedt_function_handler()
624676
def is_net_in_component(self, component_name, net_name):

0 commit comments

Comments
 (0)