Skip to content

Commit e7a1acd

Browse files
gkorompipyansys-ci-botMaxJPRey
authored
FIX: improvements in circuit config (#6012)
Co-authored-by: pyansys-ci-bot <[email protected]> Co-authored-by: Maxime Rey <[email protected]>
1 parent 9f0b2b0 commit e7a1acd

File tree

2 files changed

+30
-12
lines changed

2 files changed

+30
-12
lines changed

doc/changelog.d/6012.fixed.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
improvements in circuit config

src/ansys/aedt/core/generic/configurations.py

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2322,15 +2322,24 @@ def export_config(self, config_file=None, overwrite=False):
23222322
for k, l in pin_mapping.items():
23232323
temp_dict3 = {}
23242324
for i in l:
2325-
temp_dict3.update({i._circuit_comp.refdes: i.name})
2325+
if i._circuit_comp.refdes in temp_dict3.keys():
2326+
temp_dict3[i._circuit_comp.refdes].append(i.name)
2327+
else:
2328+
temp_dict3.update({i._circuit_comp.refdes: [i.name]})
23262329
pin_mapping[k] = temp_dict3
23272330

2331+
port_dict = {}
2332+
temp = pin_mapping.copy()
2333+
for k, l in temp.items():
2334+
if k not in ["gnd", "ports"] and len(l) == 1:
2335+
if k not in port_dict.keys():
2336+
port_dict[k] = l
2337+
else:
2338+
port_dict[k].append(l)
2339+
del pin_mapping[k]
2340+
23282341
dict_out.update(
2329-
{
2330-
"models": data_models,
2331-
"refdes": data_refdes,
2332-
"pin_mapping": pin_mapping,
2333-
}
2342+
{"models": data_models, "refdes": data_refdes, "pin_mapping": pin_mapping, "ports": port_dict}
23342343
) # Call private export method to update dict_out.
23352344

23362345
# update the json if it exists already
@@ -2450,22 +2459,30 @@ def import_config(self, config_file, *args):
24502459
if new_comp_params.get(name, None) != parameter:
24512460
new_comp.parameters[name] = parameter
24522461

2462+
comp_list = list(self._app.modeler.schematic.components.values())
24532463
for i, j in data["pin_mapping"].items():
24542464
pins = []
24552465
for k, l in j.items():
2456-
for comp in list(self._app.modeler.schematic.components.values()):
2457-
if not comp.refdes:
2458-
continue
2459-
elif comp.refdes == k:
2466+
for comp in comp_list:
2467+
if comp.refdes == k:
24602468
for pin in comp.pins:
2461-
if pin.name == l:
2469+
if pin.name in l:
24622470
pins.append(pin)
24632471
if i == "gnd":
24642472
for gnd_pin in pins:
2465-
self._app.modeler.schematic.create_gnd(gnd_pin.location, gnd_pin.angle, page=i)
2473+
location = [x - y for x, y in zip(gnd_pin.location, [0, 0.00254])]
2474+
self._app.modeler.schematic.create_gnd(location, page=i)
24662475
elif len(pins) > 1:
24672476
pins[0].connect_to_component(pins[1:], page_name=i)
24682477

2478+
for i, j in data["ports"].items():
2479+
for k, l in j.items():
2480+
for comp in comp_list:
2481+
if comp.refdes == k:
2482+
for pin in comp.pins:
2483+
if pin.name in l:
2484+
self._app.modeler.schematic.create_interface_port(name=i, location=pin.location)
2485+
24692486
if self.options.import_setups and data.get("setups", None):
24702487
self.results.import_setup = True
24712488
for setup, props in data["setups"].items():

0 commit comments

Comments
 (0)