Skip to content

Commit

Permalink
FIX: Path center line returning points (#645)
Browse files Browse the repository at this point in the history
* hfsspi SimsetupInfo bug fixed

* temp

* center line get setter

* center line get setter
  • Loading branch information
svandenb-dev authored Jul 5, 2024
1 parent 5a3505c commit 90a4299
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 7 deletions.
15 changes: 9 additions & 6 deletions src/pyedb/dotnet/edb_core/dotnet/primitive.py
Original file line number Diff line number Diff line change
Expand Up @@ -837,21 +837,24 @@ def create(self, layout, layer, net, width, end_cap1, end_cap2, corner_style, po
net = net.api_object
width = self._app.edb_api.utility.value(width)
if isinstance(points, list):
points = self._app.edb_api.geometry.polygon_data.api_class(
convert_py_list_to_net_list([self._app.geometry.point_data(i) for i in points]), False
)
points = convert_py_list_to_net_list([self._app.point_data(i[0], i[1]) for i in points])
points = self._app.edb_api.geometry.polygon_data.dotnetobj(points)
return PathDotNet(
self._app, self.api.Path.Create(layout, layer, net, width, end_cap1, end_cap2, corner_style, points)
)

@property
def center_line(self):
""":class:`PolygonData <ansys.edb.geometry.PolygonData>`: Center line for this Path."""
return self.prim_obj.GetCenterLine()
edb_center_line = self.prim_obj.GetCenterLine()
return [[pt.X.ToDouble(), pt.Y.ToDouble()] for pt in list(edb_center_line.Points)]

@center_line.setter
def center_line(self, center_line):
self.prim_obj.SetCenterLineMessage(center_line)
def center_line(self, value):
if isinstance(value, list):
points = [self._pedb.point_data(i[0], i[1]) for i in value]
polygon_data = self._edb.geometry.polygon_data.dotnetobj(convert_py_list_to_net_list(points), False)
self.prim_obj.SetCenterLine(polygon_data)

@property
def end_cap_style(self):
Expand Down
2 changes: 1 addition & 1 deletion src/pyedb/dotnet/edb_core/edb_data/primitives_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ def length(self):
float
Path length in meters.
"""
center_line_arcs = list(self.center_line.GetArcData())
center_line_arcs = list(self.api_object.GetCenterLine().GetArcData())
path_length = 0.0
for arc in center_line_arcs:
path_length += arc.GetLength()
Expand Down
21 changes: 21 additions & 0 deletions tests/legacy/system/test_edb_modeler.py
Original file line number Diff line number Diff line change
Expand Up @@ -537,3 +537,24 @@ def arbitrary_wave_ports(self):
assert "ref" in test_edb.stackup.layers
assert len(test_edb.modeler.polygons) == 12
test_edb.close()

def test_path_center_line(self):
edb = Edb()
edb.stackup.add_layer("GND", "Gap")
edb.stackup.add_layer("Substrat", "GND", layer_type="dielectric", thickness="0.2mm", material="Duroid (tm)")
edb.stackup.add_layer("TOP", "Substrat")
trace_length = 10e-3
trace_width = 200e-6
trace_gap = 1e-3
edb.modeler.create_trace(
path_list=[[-trace_gap / 2, 0.0], [-trace_gap / 2, trace_length]],
layer_name="TOP",
width=trace_width,
net_name="signal1",
start_cap_style="Flat",
end_cap_style="Flat",
)
centerline = edb.modeler.paths[0].center_line
assert centerline == [[-0.0005, 0.0], [-0.0005, 0.01]]
edb.modeler.paths[0].center_line = [[0.0, 0.0], [0.0, 5e-3]]
assert edb.modeler.paths[0].center_line == [[0.0, 0.0], [0.0, 5e-3]]

0 comments on commit 90a4299

Please sign in to comment.