From 0335bbc4b28a5774d3af42eee40847f77e1a06fd Mon Sep 17 00:00:00 2001 From: byang Date: Wed, 22 Jan 2025 20:26:09 +0100 Subject: [PATCH 1/6] add instance_dict to speed up net_filter and delete --- src/pyedb/dotnet/edb_core/padstack.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/pyedb/dotnet/edb_core/padstack.py b/src/pyedb/dotnet/edb_core/padstack.py index 110372b532..d68d475b23 100644 --- a/src/pyedb/dotnet/edb_core/padstack.py +++ b/src/pyedb/dotnet/edb_core/padstack.py @@ -1651,7 +1651,9 @@ def merge_via(self, contour_boxes, net_filter=None, start_layer=None, stop_layer raise Exception(f"No padstack instances found inside {contour_box}") else: if net_filter: - instances = [id for id in instances if not self.instances[id].net_name in net_filter] + # instances = [id for id in instances if not self.instances[id].net_name in net_filter] + instances_dict = self.instances + instances = [id for id in instances if instances_dict[id].net_name not in net_filter] net = self.instances[instances[0]].net_name x_values = [] @@ -1692,7 +1694,7 @@ def merge_via(self, contour_boxes, net_filter=None, start_layer=None, stop_layer merged_instance.stop_layer = stop_layer merged_via_ids.append(merged_instance.id) - [self.instances[id].delete() for id in instances] + [instances_dict[id].delete() for id in instances] return merged_via_ids def merge_via_along_lines( From a27464bf9799397cb6edac0e5dbcde085709de92 Mon Sep 17 00:00:00 2001 From: byang Date: Wed, 22 Jan 2025 21:01:19 +0100 Subject: [PATCH 2/6] add layer filter --- src/pyedb/dotnet/edb_core/padstack.py | 31 +++++++++++++++++++++------ 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/src/pyedb/dotnet/edb_core/padstack.py b/src/pyedb/dotnet/edb_core/padstack.py index d68d475b23..f206da8084 100644 --- a/src/pyedb/dotnet/edb_core/padstack.py +++ b/src/pyedb/dotnet/edb_core/padstack.py @@ -1636,14 +1636,12 @@ def merge_via(self, contour_boxes, net_filter=None, start_layer=None, stop_layer merged_via_ids = [] if not contour_boxes: raise Exception("No contour box provided, you need to pass a nested list as argument.") - if not start_layer: - start_layer = list(self._pedb.stackup.layers.values())[0].name - if not stop_layer: - stop_layer = list(self._pedb.stackup.layers.values())[-1].name + instances_index = {} for id, inst in self.instances.items(): instances_index[id] = inst.position for contour_box in contour_boxes: + all_instances_dict = self.instances instances = self.get_padstack_instances_id_intersecting_polygon( points=contour_box, padstack_instances_index=instances_index ) @@ -1652,8 +1650,27 @@ def merge_via(self, contour_boxes, net_filter=None, start_layer=None, stop_layer else: if net_filter: # instances = [id for id in instances if not self.instances[id].net_name in net_filter] - instances_dict = self.instances - instances = [id for id in instances if instances_dict[id].net_name not in net_filter] + instances = [id for id in instances if all_instances_dict[id].net_name not in net_filter] + + if start_layer: + if start_layer not in self._pedb.stackup.layers.keys(): + raise Exception(f"{start_layer} not exist") + else: + instances = [id for id in instances if all_instances_dict[id].start_layer == start_layer] + if stop_layer: + if stop_layer not in self._pedb.stackup.layers.keys(): + raise Exception(f"{stop_layer} not exist") + else: + instances = [id for id in instances if all_instances_dict[id].stop_layer == stop_layer] + if not instances: + raise Exception( + f"No padstack instances found inside {contour_box} between {start_layer} and" f"{stop_layer}" + ) + + if not start_layer: + start_layer = list(self._pedb.stackup.layers.values())[0].name + if not stop_layer: + stop_layer = list(self._pedb.stackup.layers.values())[-1].name net = self.instances[instances[0]].net_name x_values = [] @@ -1694,7 +1711,7 @@ def merge_via(self, contour_boxes, net_filter=None, start_layer=None, stop_layer merged_instance.stop_layer = stop_layer merged_via_ids.append(merged_instance.id) - [instances_dict[id].delete() for id in instances] + [all_instances_dict[id].delete() for id in instances] return merged_via_ids def merge_via_along_lines( From c51567f28a0f1713a5bfcad5eb8d5ff2c4d9b92c Mon Sep 17 00:00:00 2001 From: byang Date: Wed, 22 Jan 2025 21:12:37 +0100 Subject: [PATCH 3/6] add layer filter --- src/pyedb/dotnet/edb_core/padstack.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pyedb/dotnet/edb_core/padstack.py b/src/pyedb/dotnet/edb_core/padstack.py index f206da8084..1ae9db2b97 100644 --- a/src/pyedb/dotnet/edb_core/padstack.py +++ b/src/pyedb/dotnet/edb_core/padstack.py @@ -1664,7 +1664,7 @@ def merge_via(self, contour_boxes, net_filter=None, start_layer=None, stop_layer instances = [id for id in instances if all_instances_dict[id].stop_layer == stop_layer] if not instances: raise Exception( - f"No padstack instances found inside {contour_box} between {start_layer} and" f"{stop_layer}" + f"No padstack instances found inside {contour_box} between {start_layer} and {stop_layer}" ) if not start_layer: From abb1d1fb32255018d2e8c374a10a1e2856ab880c Mon Sep 17 00:00:00 2001 From: byang Date: Thu, 23 Jan 2025 08:53:47 +0100 Subject: [PATCH 4/6] add layer filter --- src/pyedb/dotnet/edb_core/padstack.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/pyedb/dotnet/edb_core/padstack.py b/src/pyedb/dotnet/edb_core/padstack.py index 1ae9db2b97..bc92be1b8d 100644 --- a/src/pyedb/dotnet/edb_core/padstack.py +++ b/src/pyedb/dotnet/edb_core/padstack.py @@ -1641,7 +1641,7 @@ def merge_via(self, contour_boxes, net_filter=None, start_layer=None, stop_layer for id, inst in self.instances.items(): instances_index[id] = inst.position for contour_box in contour_boxes: - all_instances_dict = self.instances + all_instances = self.instances instances = self.get_padstack_instances_id_intersecting_polygon( points=contour_box, padstack_instances_index=instances_index ) @@ -1650,18 +1650,18 @@ def merge_via(self, contour_boxes, net_filter=None, start_layer=None, stop_layer else: if net_filter: # instances = [id for id in instances if not self.instances[id].net_name in net_filter] - instances = [id for id in instances if all_instances_dict[id].net_name not in net_filter] + instances = [id for id in instances if all_instances[id].net_name not in net_filter] if start_layer: if start_layer not in self._pedb.stackup.layers.keys(): raise Exception(f"{start_layer} not exist") else: - instances = [id for id in instances if all_instances_dict[id].start_layer == start_layer] + instances = [id for id in instances if all_instances[id].start_layer == start_layer] if stop_layer: if stop_layer not in self._pedb.stackup.layers.keys(): raise Exception(f"{stop_layer} not exist") else: - instances = [id for id in instances if all_instances_dict[id].stop_layer == stop_layer] + instances = [id for id in instances if all_instances[id].stop_layer == stop_layer] if not instances: raise Exception( f"No padstack instances found inside {contour_box} between {start_layer} and {stop_layer}" @@ -1711,7 +1711,7 @@ def merge_via(self, contour_boxes, net_filter=None, start_layer=None, stop_layer merged_instance.stop_layer = stop_layer merged_via_ids.append(merged_instance.id) - [all_instances_dict[id].delete() for id in instances] + [all_instances[id].delete() for id in instances] return merged_via_ids def merge_via_along_lines( From 6deb9e95bd5c62ba4929a654ea69796d755d5492 Mon Sep 17 00:00:00 2001 From: byang Date: Thu, 23 Jan 2025 08:54:49 +0100 Subject: [PATCH 5/6] add layer filter --- src/pyedb/dotnet/edb_core/padstack.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pyedb/dotnet/edb_core/padstack.py b/src/pyedb/dotnet/edb_core/padstack.py index bc92be1b8d..08dde2bceb 100644 --- a/src/pyedb/dotnet/edb_core/padstack.py +++ b/src/pyedb/dotnet/edb_core/padstack.py @@ -1651,7 +1651,7 @@ def merge_via(self, contour_boxes, net_filter=None, start_layer=None, stop_layer if net_filter: # instances = [id for id in instances if not self.instances[id].net_name in net_filter] instances = [id for id in instances if all_instances[id].net_name not in net_filter] - + # filter instances by start and stop layer if start_layer: if start_layer not in self._pedb.stackup.layers.keys(): raise Exception(f"{start_layer} not exist") From 0a6313e65ec5399f4549274b2521f5b5309a9914 Mon Sep 17 00:00:00 2001 From: byang Date: Thu, 23 Jan 2025 09:59:59 +0100 Subject: [PATCH 6/6] add layer filter --- src/pyedb/dotnet/edb_core/padstack.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pyedb/dotnet/edb_core/padstack.py b/src/pyedb/dotnet/edb_core/padstack.py index 08dde2bceb..f7b5e851b2 100644 --- a/src/pyedb/dotnet/edb_core/padstack.py +++ b/src/pyedb/dotnet/edb_core/padstack.py @@ -1711,7 +1711,7 @@ def merge_via(self, contour_boxes, net_filter=None, start_layer=None, stop_layer merged_instance.stop_layer = stop_layer merged_via_ids.append(merged_instance.id) - [all_instances[id].delete() for id in instances] + _ = [all_instances[id].delete() for id in instances] return merged_via_ids def merge_via_along_lines(