Skip to content

Commit

Permalink
method to extend trace (#3725)
Browse files Browse the repository at this point in the history
* fix

* fix

* fix

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* fix

* Update pyaedt/edb_core/dotnet/database.py

Co-authored-by: Kathy Pippert <[email protected]>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* fix

---------

Co-authored-by: ring630 <@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Kathy Pippert <[email protected]>
  • Loading branch information
3 people authored Oct 9, 2023
1 parent 06ebac8 commit a3f2803
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 0 deletions.
5 changes: 5 additions & 0 deletions _unittest/test_00_EDB.py
Original file line number Diff line number Diff line change
Expand Up @@ -886,6 +886,11 @@ 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
37 changes: 37 additions & 0 deletions pyaedt/edb_core/dotnet/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,43 @@ 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
22 changes: 22 additions & 0 deletions pyaedt/edb_core/edb_data/primitives_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from pyaedt.edb_core.dotnet.primitive import BondwireDotNet
from pyaedt.edb_core.dotnet.primitive import CircleDotNet
from pyaedt.edb_core.dotnet.primitive import PathDotNet
from pyaedt.edb_core.dotnet.primitive import PolygonDataDotNet
from pyaedt.edb_core.dotnet.primitive import PolygonDotNet
from pyaedt.edb_core.dotnet.primitive import RectangleDotNet
from pyaedt.edb_core.dotnet.primitive import TextDotNet
Expand Down Expand Up @@ -715,6 +716,27 @@ def length(self):
length += GeometryOperators.points_distance(center_line[pt_ind], center_line[pt_ind + 1])
return length

@pyaedt_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)

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

0 comments on commit a3f2803

Please sign in to comment.