Skip to content

Commit 7061756

Browse files
FEAT: layout validation padstack names (#847)
* FIX: SIwave padstack aedt name * MISC: Auto fixes from pre-commit.com hooks For more information, see https://pre-commit.ci * minor fix * minor fix --------- Co-authored-by: ring630 <@gmail.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 8e38420 commit 7061756

File tree

5 files changed

+56
-7
lines changed

5 files changed

+56
-7
lines changed

src/pyedb/configuration/cfg_components.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ def __init__(self, pedb, components_data):
5353
self.components = [CfgComponent(**comp) for comp in components_data]
5454

5555
def apply(self):
56-
comps_in_db = self._pedb.components.components
56+
comps_in_db = self._pedb.components
5757
for comp in self.components:
58-
c_db = comps_in_db[comp.reference_designator]
58+
c_db = comps_in_db.instances[comp.reference_designator]
5959
if comp.definition:
6060
c_db.definition = comp.definition
6161
if comp.type:

src/pyedb/configuration/cfg_padstacks.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,21 @@ def get_data_from_db(self):
7373
definitions.append(i.get_attributes())
7474
data["definitions"] = definitions
7575

76-
instances_layout = self._pedb.padstacks.instances_by_name
77-
for name, obj in instances_layout.items():
76+
for obj in self._pedb.layout.padstack_instances:
77+
temp = obj.properties
7878
self.instances.append(
79-
Instance(name=name, definition=obj.padstack_definition, backdrill_parameters=obj.backdrill_parameters)
79+
Instance(
80+
name=temp["name"],
81+
definition=temp["definition"],
82+
backdrill_parameters=temp["backdrill_parameters"],
83+
id=temp["id"],
84+
position=temp["position"],
85+
rotation=temp["rotation"],
86+
)
8087
)
8188
instances = []
8289
for i in self.instances:
83-
instances.append(i.get_attributes())
90+
instances.append(i.get_attributes("id"))
8491
data["instances"] = instances
8592
return data
8693

@@ -104,3 +111,6 @@ def __init__(self, **kwargs):
104111
self.name = kwargs["name"]
105112
self.definition = kwargs.get("definition", None)
106113
self.backdrill_parameters = kwargs.get("backdrill_parameters", None)
114+
self.id = kwargs.get("id", None)
115+
self.position = kwargs.get("position", [])
116+
self.rotation = kwargs.get("rotation", None)

src/pyedb/dotnet/edb_core/edb_data/padstacks_data.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2324,3 +2324,15 @@ def get_reference_pins(self, reference_net="GND", search_radius=5e-3, max_limit=
23242324
max_limit=max_limit,
23252325
component_only=component_only,
23262326
)
2327+
2328+
@property
2329+
def properties(self):
2330+
data = {}
2331+
data["name"] = self.aedt_name
2332+
data["definition"] = self.padstack_definition
2333+
data["backdrill_parameters"] = self.backdrill_parameters
2334+
_, position, rotation = self._edb_object.GetPositionAndRotationValue()
2335+
data["position"] = [position.X.ToString(), position.Y.ToString()]
2336+
data["rotation"] = [rotation.ToString()]
2337+
data["id"] = self.id
2338+
return data

src/pyedb/dotnet/edb_core/layout_validation.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
import re
2424

25+
from pyedb.dotnet.clr_module import String
2526
from pyedb.dotnet.edb_core.edb_data.padstacks_data import EDBPadstackInstance
2627
from pyedb.dotnet.edb_core.edb_data.primitives_data import Primitive
2728
from pyedb.generic.general_methods import generate_unique_name
@@ -318,3 +319,25 @@ def illegal_rlc_values(self, fix=False):
318319

319320
self._pedb._logger.info("Found {} inductors have no value.".format(len(temp)))
320321
return
322+
323+
def padstacks_no_name(self, fix=False):
324+
pds = self._pedb.layout.padstack_instances
325+
counts = 0
326+
via_count = 1
327+
for obj in pds:
328+
val = String("")
329+
_, name = obj._edb_object.GetProductProperty(self._pedb.edb_api.ProductId.Designer, 11, val)
330+
name = str(name).strip("'")
331+
if name == "":
332+
counts += 1
333+
if fix:
334+
if not obj.component:
335+
obj._edb_object.SetProductProperty(
336+
self._pedb.edb_api.ProductId.Designer, 11, f"via_{via_count}"
337+
)
338+
via_count = via_count + 1
339+
else:
340+
obj._edb_object.SetProductProperty(
341+
self._pedb.edb_api.ProductId.Designer, 11, f"{obj.component.name}-{obj.component_pin}"
342+
)
343+
self._pedb._logger.info(f"Found {counts}/{len(pds)} padstacks have no name.")

src/pyedb/siwave.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,13 +555,15 @@ def load_configuration(self, file_path: str):
555555
self.import_edb(temp_edb)
556556
shutil.rmtree(Path(temp_edb), ignore_errors=True)
557557

558-
def export_configuration(self, file_path: str):
558+
def export_configuration(self, file_path: str, fix_padstack_names: bool = False):
559559
"""Export layout information into a configuration file.
560560
561561
Parameters
562562
----------
563563
file_path : str
564564
Path to the configuration file.
565+
fix_padstack_names : bool
566+
Name all the padstacks in edb.
565567
"""
566568
file_path = parser_file_path(file_path)
567569

@@ -570,5 +572,7 @@ def export_configuration(self, file_path: str):
570572

571573
self.export_edb(temp_edb)
572574
edbapp = Edb(temp_edb, edbversion=self.current_version)
575+
if fix_padstack_names:
576+
edbapp.layout_validation.padstacks_no_name(fix=True)
573577
edbapp.configuration.export(file_path)
574578
edbapp.close()

0 commit comments

Comments
 (0)