diff --git a/src/pyedb/dotnet/edb_core/dotnet/primitive.py b/src/pyedb/dotnet/edb_core/dotnet/primitive.py index 5e5a22977e..f7c166b827 100644 --- a/src/pyedb/dotnet/edb_core/dotnet/primitive.py +++ b/src/pyedb/dotnet/edb_core/dotnet/primitive.py @@ -72,6 +72,10 @@ def __init__(self, api, prim_object=None): self.edb_api = api._edb self.prim_obj = prim_object + @property + def id(self): + return self.prim_obj.GetId() + @property def api_class(self): return self.api @@ -352,6 +356,26 @@ def points_raw(self): except: return points + def expand(self, offset=0.001, tolerance=1e-12, round_corners=True, maximum_corner_extension=0.001): + """Expand the polygon shape by an absolute value in all direction. + Offset can be negative for negative expansion. + + Parameters + ---------- + offset : float, optional + Offset value in meters. + tolerance : float, optional + Tolerance in meters. + round_corners : bool, optional + Whether to round corners or not. + If True, use rounded corners in the expansion otherwise use straight edges (can be degenerate). + maximum_corner_extension : float, optional + The maximum corner extension (when round corners are not used) at which point the corner is clipped. + """ + new_poly = self.polygon_data.edb_api.Expand(offset, tolerance, round_corners, maximum_corner_extension) + self.polygon_data = new_poly[0] + return True + class RectangleDotNet(PrimitiveDotNet): """Class representing a rectangle object.""" @@ -577,6 +601,28 @@ def can_be_zone_primitive(self): """:obj:`bool`: If a circle can be a zone.""" return True + def expand(self, offset=0.001, tolerance=1e-12, round_corners=True, maximum_corner_extension=0.001): + """Expand the polygon shape by an absolute value in all direction. + Offset can be negative for negative expansion. + + Parameters + ---------- + offset : float, optional + Offset value in meters. + tolerance : float, optional + Tolerance in meters. Ignored for Circle and Path. + round_corners : bool, optional + Whether to round corners or not. + If True, use rounded corners in the expansion otherwise use straight edges (can be degenerate). + Ignored for Circle and Path. + maximum_corner_extension : float, optional + The maximum corner extension (when round corners are not used) at which point the corner is clipped. + Ignored for Circle and Path. + """ + center_x, center_y, radius = self.get_parameters() + self.set_parameters(center_x, center_y, radius.ToFloat() + offset) + return True + class TextDotNet(PrimitiveDotNet): """Class representing a text object.""" @@ -851,6 +897,27 @@ def can_be_zone_primitive(self): """ return True + def expand(self, offset=0.001, tolerance=1e-12, round_corners=True, maximum_corner_extension=0.001): + """Expand the polygon shape by an absolute value in all direction. + Offset can be negative for negative expansion. + + Parameters + ---------- + offset : float, optional + Offset value in meters. + tolerance : float, optional + Tolerance in meters. Ignored for Circle and Path. + round_corners : bool, optional + Whether to round corners or not. + If True, use rounded corners in the expansion otherwise use straight edges (can be degenerate). + Ignored for Circle and Path. + maximum_corner_extension : float, optional + The maximum corner extension (when round corners are not used) at which point the corner is clipped. + Ignored for Circle and Path. + """ + self.width = self.width + offset + return True + class BondwireDotNet(PrimitiveDotNet): """Class representing a bondwire object.""" diff --git a/src/pyedb/dotnet/edb_core/edb_data/primitives_data.py b/src/pyedb/dotnet/edb_core/edb_data/primitives_data.py index da995d091e..3e805d7538 100644 --- a/src/pyedb/dotnet/edb_core/edb_data/primitives_data.py +++ b/src/pyedb/dotnet/edb_core/edb_data/primitives_data.py @@ -558,6 +558,15 @@ def get_closest_arc_midpoint(self, point): dist = GeometryOperators.points_distance(mid_point, point) return [out.X.ToDouble(), out.Y.ToDouble()] + @property + def voids(self): + """:obj:`list` of :class:`Primitive `: List of void\ + primitive objects inside the primitive. + + Read-Only. + """ + return [cast(void, self._app) for void in self.prim_obj.Voids] + @property def arcs(self): """Get the Primitive Arc Data.""" diff --git a/tests/legacy/system/test_edb_modeler.py b/tests/legacy/system/test_edb_modeler.py index 3d5b8f8a94..3e0958ba06 100644 --- a/tests/legacy/system/test_edb_modeler.py +++ b/tests/legacy/system/test_edb_modeler.py @@ -75,6 +75,15 @@ def test_modeler_polygons(self): assert isinstance(poly0.arcs[0].points, tuple) assert isinstance(poly0.intersection_type(poly0), int) assert poly0.is_intersecting(poly0) + poly_3022 = [i for i in self.edbapp.modeler.polygons if i.id == 3022][0] + + for i, k in enumerate(poly_3022.voids): + assert k.id + assert k.expand(0.0005) + # edb.modeler.parametrize_polygon(k, poly_5953, offset_name=f"offset_{i}", origin=centroid) + + poly_167 = [i for i in self.edbapp.modeler.paths if i.id == 167][0] + assert poly_167.expand(0.0005) def test_modeler_paths(self): """Evaluate modeler paths"""