Skip to content

Commit f065efe

Browse files
authored
Fix/component catalog (#870)
* Fixed components_catalog load * Fixed components_catalog load * Fixed example * Fixed example * removed unused definitions * improved props * Improved Coverage of UT * Black Fix * Black Fix Co-authored-by: maxcapodi78 <Shark78>
1 parent 9e5010c commit f065efe

File tree

8 files changed

+42
-24
lines changed

8 files changed

+42
-24
lines changed

_unittest/test_21_Circuit.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,3 +310,4 @@ def test_26_component_catalog(self):
310310
assert isinstance(comp_catalog.find_components("cap"), list)
311311
assert comp_catalog["LISN:CISPR25_LISN"].place("Lisn1")
312312
assert not comp_catalog["Capacitors"]
313+
assert comp_catalog["LISN:CISPR25_LISN"].props

_unittest/test_34_TwinBuilder.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,9 @@ def test_10_set_hmin(self):
6666

6767
def test_11_set_end_time(self):
6868
assert self.aedtapp.set_end_time("5s")
69+
70+
def test_12_catalog(self):
71+
comp_catalog = self.aedtapp.modeler.components.components_catalog
72+
assert not comp_catalog["Capacitors"]
73+
assert comp_catalog["Aircraft Electrical VHDLAMS\\Basic:lowpass_filter"].props
74+
assert comp_catalog["Aircraft Electrical VHDLAMS\\Basic:lowpass_filter"].place("LP1")

examples/06-Multiphysics/Hfss_Icepak_Coupling.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -314,10 +314,7 @@
314314
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
315315
# This example use Matplotlib and Numpy to generate graphs outside of PyAEDT.
316316

317-
trace_names = []
318-
for el in portnames:
319-
for el2 in portnames:
320-
trace_names.append("S(" + el + "," + el2 + ")")
317+
trace_names = aedtapp.get_traces_for_plot(category="S")
321318
cxt = ["Domain:=", "Sweep"]
322319
families = ["Freq:=", ["All"]]
323320
my_data = aedtapp.post.get_report_data(expression=trace_names)

pyaedt/edb.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1084,6 +1084,7 @@ def create_cutout_on_point_list(
10841084
# if pad.parameters_values:
10851085
# point2 = self.edb.Geometry.PointData(self.edb_value(posx + 3 * pad.parameters_values[0]),
10861086
# self.edb_value(posy + 3 * pad.parameters_values[0]))
1087+
#
10871088
# point3 = self.edb.Geometry.PointData(self.edb_value(posx - 3 * pad.parameters_values[0]),
10881089
# self.edb_value(posy - 3 * pad.parameters_values[0]))
10891090
# if polygonData.PointInPolygon(
@@ -1094,12 +1095,11 @@ def create_cutout_on_point_list(
10941095
# if polygonData.GetIntersectionType(pad.polygon_data) >= 1:
10951096
# via_lists.append(via)
10961097
# break
1097-
10981098
_netsClip = convert_py_list_to_net_list(_ref_nets)
10991099
net_signals = List[type(_ref_nets[0])]()
11001100
# Create new cutout cell/design
11011101
_cutout = self.active_cell.CutOut(net_signals, _netsClip, polygonData)
1102-
1102+
self._active_cell
11031103
# TODO check and insert via check on polygon intersection
11041104
# if add_vias_on_cutout:
11051105
# layout = _cutout.GetLayout()

pyaedt/generic/LoadAEDTFile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def load_keyword_in_aedt_file(filename, keyword):
3434
3535
Returns
3636
-------
37-
type
37+
dict
3838
dictionary containing the decoded AEDT file
3939
4040
"""

pyaedt/generic/general_methods.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ def filter_string(value, search_key1):
575575
ignore_case = True
576576

577577
def _create_pattern(k1):
578-
k1a = re.sub(r"\?", r".", k1)
578+
k1a = re.sub(r"\?", r".", k1.replace("\\", "\\\\"))
579579
k1b = re.sub(r"\*", r".*?", k1a)
580580
pattern = r"^{}$".format(k1b)
581581
return pattern

pyaedt/modeler/PrimitivesCircuit.py

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from pyaedt.modeler.Object3d import CircuitComponent
1515
from pyaedt.generic.constants import AEDT_UNITS
1616
from pyaedt.generic.TouchstoneParser import _parse_ports_name
17-
from pyaedt.generic.LoadAEDTFile import load_entire_aedt_file
17+
from pyaedt.generic.LoadAEDTFile import load_keyword_in_aedt_file
1818

1919

2020
class CircuitComponents(object):
@@ -1242,12 +1242,21 @@ def arg_with_dim(self, Value, sUnits=None):
12421242
class ComponentInfo(object):
12431243
"""Class that manage Circuit Catalog info."""
12441244

1245-
def __init__(self, name, component_manager, props):
1245+
def __init__(self, name, component_manager, file_name, component_library):
12461246
self._component_manager = component_manager
1247-
self.props = props
1247+
self.file_name = file_name
12481248
self.name = name
1249-
self.component_library = self.props.get("ComponentLibrary", None)
1249+
self.component_library = component_library
1250+
self._props = None
12501251

1252+
@property
1253+
def props(self):
1254+
"""Retrieve the component properties."""
1255+
if not self._props:
1256+
self._props = load_keyword_in_aedt_file(self.file_name, self.name)
1257+
return self._props
1258+
1259+
@aedt_exception_handler
12511260
def place(self, inst_name, location=[], angle=0, use_instance_id_netlist=False):
12521261
"""Create a component from a library.
12531262
@@ -1326,19 +1335,20 @@ def _index_components(self, library_path=None):
13261335
sys_files = recursive_glob(os.path.join(self._app.syslib, self._component_manager.design_libray), "*.aclb")
13271336
root = os.path.normpath(self._app.syslib).split(os.path.sep)[-1]
13281337
for file in sys_files:
1329-
comps = load_entire_aedt_file(file)
1338+
comps1 = load_keyword_in_aedt_file(file, "DefInfo")
1339+
comps2 = load_keyword_in_aedt_file(file, "CompInfo")
1340+
comps = comps1.get("DefInfo", {})
1341+
comps.update(comps2.get("CompInfo", {}))
13301342
for compname, comp_value in comps.items():
1331-
if compname not in ["$base_index$", "$index$", "DefInfo"]:
1332-
root_name, ext = os.path.splitext(os.path.basename(file))
1333-
full_path = os.path.normpath(file).split(os.path.sep)
1334-
id = full_path.index(root) + 1
1335-
if self._component_manager.design_libray in full_path[id:]:
1336-
id += 1
1337-
full_path[-1] = full_path[-1].replace(".aclb", "")
1338-
comp_value["ComponentLibrary"] = "\\".join(full_path[id:])
1339-
self.components["{}:{}".format(root_name, compname)] = ComponentInfo(
1340-
compname, self._component_manager, comp_value
1341-
)
1343+
root_name, ext = os.path.splitext(os.path.normpath(file))
1344+
full_path = root_name.split(os.path.sep)
1345+
id = full_path.index(root) + 1
1346+
if self._component_manager.design_libray in full_path[id:]:
1347+
id += 1
1348+
comp_lib = "\\".join(full_path[id:]) + ":" + compname
1349+
self.components[comp_lib] = ComponentInfo(
1350+
compname, self._component_manager, file, comp_lib.split(":")[0]
1351+
)
13421352

13431353
@aedt_exception_handler
13441354
def find_components(self, filter_str="*"):

pyaedt/modeler/PrimitivesSimplorer.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ class SimplorerComponents(CircuitComponents):
2222
>>> prim = aedtapp.modeler.schematic
2323
"""
2424

25+
@property
26+
def _logger(self):
27+
return self._app.logger
28+
2529
@property
2630
def design_libray(self):
2731
"""Design Library."""

0 commit comments

Comments
 (0)