Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retrieve PyAEDT PRs associated to EDB #5

Merged
merged 2 commits into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions _unittest/test_00_EDB.py
Original file line number Diff line number Diff line change
Expand Up @@ -886,6 +886,12 @@ def test_069_create_path(self):
assert trace
assert isinstance(trace.get_center_line(), list)
assert isinstance(trace.get_center_line(True), list)
self.edbapp["delta_x"] = "1mm"
assert trace.add_point("delta_x", "1mm", True)
assert trace.get_center_line(True)[-1][0] == "(delta_x)+(0.025)"
assert trace.add_point(0.001, 0.002)
assert trace.get_center_line()[-1] == [0.001, 0.002]


def test_070_create_outline(self):
edbapp = Edb(
Expand Down Expand Up @@ -2896,6 +2902,9 @@ def test_147_find_dc_shorts(self):
edbapp = Edb(target_path, edbversion=desktop_version)
dc_shorts = edbapp.layout_validation.dc_shorts()
assert dc_shorts
edbapp.nets.nets["DDR4_A0"].name = "DDR4$A0"
edbapp.layout_validation.illegal_net_names(True)

# assert len(dc_shorts) == 20
assert ["LVDS_CH09_N", "GND"] in dc_shorts
assert ["LVDS_CH09_N", "DDR4_DM3"] in dc_shorts
Expand Down
33 changes: 33 additions & 0 deletions src/pyedb/legacy/edb_core/dotnet/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,39 @@ def arcs(self): # pragma: no cover
"""List of Edb.Geometry.ArcData."""
return list(self.edb_api.GetArcData())

def get_points(self):
"""Get all points in polygon.
Returns
-------
list[list[edb_value]]
"""

return [[self._pedb.edb_value(i.X), self._pedb.edb_value(i.Y)] for i in list(self.edb_api.Points)]

def add_point(self, x, y, incremental=False):
"""Add a point at the end of the point list of the polygon.
Parameters
----------
x: str, int, float
X coordinate.
y: str, in, float
Y coordinate.
incremental: bool
Whether to add the point incrementally. The default value is ``False``. When
``True``, the coordinates of the added point are incremental to the last point.
Returns
-------
bool
``True`` when successful, ``False`` when failed.
"""
if incremental:
x = self._pedb.edb_value(x)
y = self._pedb.edb_value(y)
last_point = self.get_points()[-1]
x = "({})+({})".format(x, last_point[0].ToString())
y = "({})+({})".format(y, last_point[1].ToString())
return self.edb_api.AddPoint(GeometryDotNet(self._pedb).point_data(x, y))

def get_bbox_of_boxes(self, points):
"""Get the EDB .NET API ``Edb.Geometry.GetBBoxOfBoxes`` database.

Expand Down
75 changes: 48 additions & 27 deletions src/pyedb/legacy/edb_core/edb_data/primitives_data.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import math

from pyedb.edb_core.dotnet.primitive import BondwireDotNet
from pyedb.edb_core.dotnet.primitive import CircleDotNet
from pyedb.edb_core.dotnet.primitive import PathDotNet
from pyedb.edb_core.dotnet.primitive import PolygonDotNet
from pyedb.edb_core.dotnet.primitive import RectangleDotNet
from pyedb.edb_core.dotnet.primitive import TextDotNet
from pyedb.edb_core.edb_data.connectable import Connectable
from pyedb.edb_core.general import convert_py_list_to_net_list
from pyedb.generic.general_methods import pyaedt_function_handler
from pyedb.legacy.edb_core.dotnet.primitive import BondwireDotNet
from pyedb.legacy.edb_core.dotnet.primitive import CircleDotNet
from pyedb.legacy.edb_core.dotnet.primitive import PathDotNet
from pyedb.legacy.edb_core.dotnet.primitive import PolygonDataDotNet
from pyedb.legacy.edb_core.dotnet.primitive import PolygonDotNet
from pyedb.legacy.edb_core.dotnet.primitive import RectangleDotNet
from pyedb.legacy.edb_core.dotnet.primitive import TextDotNet
from pyedb.legacy.edb_core.edb_data.connectable import Connectable
from pyedb.legacy.edb_core.general import convert_py_list_to_net_list
from pyedb.generic.general_methods import pyedb_function_handler
from pyedb.modeler.geometry_operators import GeometryOperators


Expand Down Expand Up @@ -171,7 +172,7 @@ class EDBPrimitives(EDBPrimitivesMain):
def __init__(self, raw_primitive, core_app):
EDBPrimitivesMain.__init__(self, raw_primitive, core_app)

@pyaedt_function_handler()
@pyedb_function_handler()
def area(self, include_voids=True):
"""Return the total area.

Expand Down Expand Up @@ -331,7 +332,7 @@ def center(self):
bbox = self.bbox
return [(bbox[0] + bbox[2]) / 2, (bbox[1] + bbox[3]) / 2]

@pyaedt_function_handler()
@pyedb_function_handler()
def is_arc(self, point):
"""Either if a point is an arc or not.

Expand All @@ -341,7 +342,7 @@ def is_arc(self, point):
"""
return point.IsArc()

@pyaedt_function_handler()
@pyedb_function_handler()
def get_connected_object_id_set(self):
"""Produce a list of all geometries physically connected to a given layout object.

Expand All @@ -354,7 +355,7 @@ def get_connected_object_id_set(self):
layoutObjInst = layoutInst.GetLayoutObjInstance(self.primitive_object, None) # 2nd arg was []
return [loi.GetLayoutObj().GetId() for loi in layoutInst.GetConnectedObjects(layoutObjInst).Items]

@pyaedt_function_handler()
@pyedb_function_handler()
def convert_to_polygon(self):
"""Convert path to polygon.

Expand All @@ -369,7 +370,7 @@ def convert_to_polygon(self):
self.primitive_object.Delete()
return polygon

@pyaedt_function_handler()
@pyedb_function_handler()
def subtract(self, primitives):
"""Subtract active primitive with one or more primitives.

Expand Down Expand Up @@ -423,7 +424,7 @@ def subtract(self, primitives):
continue
return new_polys

@pyaedt_function_handler()
@pyedb_function_handler()
def intersect(self, primitives):
"""Intersect active primitive with one or more primitives.

Expand Down Expand Up @@ -508,7 +509,7 @@ def intersect(self, primitives):
continue
return new_polys

@pyaedt_function_handler()
@pyedb_function_handler()
def unite(self, primitives):
"""Unite active primitive with one or more primitives.

Expand Down Expand Up @@ -563,7 +564,7 @@ def unite(self, primitives):
continue
return new_polys

@pyaedt_function_handler()
@pyedb_function_handler()
def intersection_type(self, primitive):
"""Get intersection type between actual primitive and another primitive or polygon data.

Expand All @@ -588,7 +589,7 @@ def intersection_type(self, primitive):
pass
return int(self.polygon_data.edb_api.GetIntersectionType(poly.edb_api))

@pyaedt_function_handler()
@pyedb_function_handler()
def is_intersecting(self, primitive):
"""Check if actual primitive and another primitive or polygon data intesects.

Expand All @@ -602,7 +603,7 @@ def is_intersecting(self, primitive):
"""
return True if self.intersection_type(primitive) >= 1 else False

@pyaedt_function_handler()
@pyedb_function_handler()
def get_closest_point(self, point):
"""Get the closest point of the primitive to the input data.

Expand All @@ -620,7 +621,7 @@ def get_closest_point(self, point):
p0 = self.polygon_data.edb_api.GetClosestPoint(point)
return [p0.X.ToDouble(), p0.Y.ToDouble()]

@pyaedt_function_handler()
@pyedb_function_handler()
def get_closest_arc_midpoint(self, point):
"""Get the closest arc midpoint of the primitive to the input data.

Expand Down Expand Up @@ -715,7 +716,27 @@ def length(self):
length += GeometryOperators.points_distance(center_line[pt_ind], center_line[pt_ind + 1])
return length

@pyaedt_function_handler
@pyedb_function_handler()
def add_point(self, x, y, incremental=False):
"""Add a point at the end of the path.
Parameters
----------
x: str, int, float
X coordinate.
y: str, in, float
Y coordinate.
incremental: bool
Add point incrementally. If True, coordinates of the added point is incremental to the last point.
The default value is ``False``.
Returns
-------
bool
"""
center_line = PolygonDataDotNet(self._pedb, self._edb_object.GetCenterLine())
center_line.add_point(x, y, incremental)
return self._edb_object.SetCenterLine(center_line.edb_api)

@pyedb_function_handler()
def get_center_line(self, to_string=False):
"""Get the center line of the trace.

Expand All @@ -733,7 +754,7 @@ def get_center_line(self, to_string=False):
else:
return [[p.X.ToDouble(), p.Y.ToDouble()] for p in list(self.primitive_object.GetCenterLine().Points)]

@pyaedt_function_handler
@pyedb_function_handler()
def clone(self):
"""Clone a primitive object with keeping same definition and location.

Expand All @@ -759,8 +780,8 @@ def clone(self):
if cloned_path:
return cloned_path

# @pyaedt_function_handler
@pyaedt_function_handler
# @pyedb_function_handler()
@pyedb_function_handler()
def create_edge_port(
self,
name,
Expand Down Expand Up @@ -831,7 +852,7 @@ def __init__(self, raw_primitive, core_app):
EDBPrimitives.__init__(self, raw_primitive, core_app)
PolygonDotNet.__init__(self, self._app, raw_primitive)

@pyaedt_function_handler
@pyedb_function_handler()
def clone(self):
"""Clone a primitive object with keeping same definition and location.

Expand All @@ -853,7 +874,7 @@ def clone(self):
return cloned_poly
return False

@pyaedt_function_handler()
@pyedb_function_handler()
def in_polygon(
self,
point_data,
Expand Down Expand Up @@ -892,7 +913,7 @@ def in_polygon(
else:
return False

# @pyaedt_function_handler()
# @pyedb_function_handler()
# def add_void(self, point_list):
# """Add a void to current primitive.
#
Expand Down
31 changes: 26 additions & 5 deletions src/pyedb/legacy/edb_core/layout_validation.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
from pyedb.edb_core.edb_data.padstacks_data import EDBPadstackInstance
from pyedb.edb_core.edb_data.primitives_data import EDBPrimitives
import re

from pyedb.legacy.edb_core.edb_data.padstacks_data import EDBPadstackInstance
from pyedb.legacy.edb_core.edb_data.primitives_data import EDBPrimitives
from pyedb.generic.general_methods import generate_unique_name
from pyedb.generic.general_methods import pyaedt_function_handler
from pyedb.generic.general_methods import pyedb_function_handler



class LayoutValidation:
Expand All @@ -10,7 +13,7 @@ class LayoutValidation:
def __init__(self, pedb):
self._pedb = pedb

@pyaedt_function_handler()
@pyedb_function_handler()
def dc_shorts(self, net_list=None, fix=False):
"""Find DC shorts on layout.

Expand Down Expand Up @@ -91,7 +94,7 @@ def dc_shorts(self, net_list=None, fix=False):
i.net = temp_name
return dc_shorts

@pyaedt_function_handler()
@pyedb_function_handler()
def disjoint_nets(
self, net_list=None, keep_only_main_net=False, clean_disjoints_less_than=0.0, order_by_area=False
):
Expand Down Expand Up @@ -211,3 +214,21 @@ def area_calc(elem):
self._pedb._logger.info_timer("Disjoint Cleanup Completed.", timer_start)

return new_nets


def illegal_net_names(self, fix=False):
"""Find and fix illegal net names."""
pattern = r"[\(\)\\\/:;*?<>\'\"|`~$]"

nets = self._pedb.nets.nets

renamed_nets = []
for net, val in nets.items():
if re.findall(pattern, net):
renamed_nets.append(net)
if fix:
new_name = re.sub(pattern, "_", net)
val.name = new_name

self._pedb._logger.info("Found {} illegal net names.".format(len(renamed_nets)))
return
Loading
Loading