Skip to content

method to extend trace #3725

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

Merged
merged 10 commits into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from 6 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
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
34 changes: 34 additions & 0 deletions pyaedt/edb_core/dotnet/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,40 @@ 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
Add point incrementally. If True, coordinates of the added point is incremental to the last point.
The default value is ``False``.
Returns
-------
bool
"""
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):
"""

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