Skip to content

FEATURE: Add GetConnectionPt SetConnectionPt API in PadstackDefData #392

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 1 commit into from
May 1, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ classifiers = [

# FIXME: add ansys-api-edb version
dependencies = [
"ansys-api-edb==1.0.2",
"ansys-api-edb==1.0.3",
"protobuf>=3.19.3,<4",
"grpcio>=1.44.0"
]
Expand Down
74 changes: 73 additions & 1 deletion src/ansys/edb/core/definition/padstack_def_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

from ansys.edb.core.inner import ObjBase, messages, parser
from ansys.edb.core.session import StubAccessor, StubType
from ansys.edb.core.utility import Value
from ansys.edb.core.utility import Value, conversions


class _PadstackDefDataQueryBuilder:
Expand Down Expand Up @@ -146,6 +146,20 @@ def padstack_def_data_set_solder_ball_param_message(target, d1, d2):
def padstack_def_data_set_solder_ball_material_message(target, material):
return pb.PadstackDefDataSetSolderBallMaterialMessage(target=target.msg, material=material)

@staticmethod
def padstack_def_data_get_connection_pt_message(target, layer):
return pb.PadstackDefDataGetConnectionPtMessage(target=target.msg, layer=layer)

@staticmethod
def padstack_def_data_set_connection_pt_message(target, layer, position, direction):
return pb.PadstackDefDataSetConnectionPtMessage(
target=target.msg,
layer=layer,
x=messages.value_message(position.x),
y=messages.value_message(position.y),
direction=direction.value,
)


class PadType(Enum):
"""Provides an enum representing pad types."""
Expand Down Expand Up @@ -202,6 +216,22 @@ class SolderballPlacement(Enum):
UNKNOWN_PLACEMENT = pb.UNKNOWN_PLACEMENT


class ConnectionPtDirection(Enum):
"""Provides an enum representing connection pt direction."""

PS_NO_DIRECTION = pb.PS_NO_DIRECTION
PS_ANY_DIRECTION = pb.PS_ANY_DIRECTION
PS_0_DIRECTION = pb.PS_0_DIRECTION
PS_45_DIRECTION = pb.PS_45_DIRECTION
PS_90_DIRECTION = pb.PS_90_DIRECTION
PS_135_DIRECTION = pb.PS_135_DIRECTION
PS_180_DIRECTION = pb.PS_180_DIRECTION
PS_225_DIRECTION = pb.PS_225_DIRECTION
PS_270_DIRECTION = pb.PS_270_DIRECTION
PS_315_DIRECTION = pb.PS_315_DIRECTION
PS_UNKNOWN_DIRECTION = pb.PS_UNKNOWN_DIRECTION


class PadstackDefData(ObjBase):
"""Represents a padstack data definition."""

Expand Down Expand Up @@ -473,3 +503,45 @@ def solder_ball_material(self, material):
self, material
)
)

def get_connection_pt(self, layer):
"""
Get connection point position and direction by layer name.

Parameters
----------
layer : str
Layer name.

Returns
-------
tuple[:class:`geometry.PointData`, :class:`ConnectionPtDirection`]

The tuple is in a ``(position, direction)`` format:

- ``position``: Position of the connection point.
- ``direction``: Direction of the connection point.
"""
msg = self.__stub.GetConnectionPt(
_PadstackDefDataQueryBuilder.padstack_def_data_get_connection_pt_message(self, layer)
)
return parser.to_point_data(msg), ConnectionPtDirection(msg.direction)

def set_connection_pt(self, layer, position, direction):
"""
Set connection point position and direction.

Parameters
----------
layer : str
Layer name.
position : ansys.edb.core.typing.PointLike
Position.
direction : :class:`ConnectionPtDirection`
Direction.
"""
self.__stub.SetConnectionPt(
_PadstackDefDataQueryBuilder.padstack_def_data_set_connection_pt_message(
self, layer, conversions.to_point(position), direction
)
)