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

FIX: Path center line returning points #645

Merged
merged 12 commits into from
Jul 5, 2024
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]]
Loading