Skip to content

Commit bfdb0d9

Browse files
umutsoysalansyspyansys-ci-botjacobrkerstetter
authored
chore: v1 implementation of coordinate system stub (#2402)
Co-authored-by: pyansys-ci-bot <[email protected]> Co-authored-by: Jacob Kerstetter <[email protected]>
1 parent 3a535c7 commit bfdb0d9

File tree

2 files changed

+33
-3
lines changed

2 files changed

+33
-3
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
V1 implementation of coordinate system stub

src/ansys/geometry/core/_grpc/_services/v1/coordinate_systems.py

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
from ansys.geometry.core.errors import protect_grpc
2727

2828
from ..base.coordinate_systems import GRPCCoordinateSystemService
29+
from .conversions import from_frame_to_grpc_frame, from_grpc_frame_to_frame
2930

3031

3132
class GRPCCoordinateSystemServiceV1(GRPCCoordinateSystemService): # pragma: no cover
@@ -43,10 +44,38 @@ class GRPCCoordinateSystemServiceV1(GRPCCoordinateSystemService): # pragma: no
4344

4445
@protect_grpc
4546
def __init__(self, channel: grpc.Channel): # noqa: D102
46-
from ansys.api.geometry.v1.coordinatesystems_pb2_grpc import CoordinateSystemsStub
47+
from ansys.api.discovery.v1.design.constructs.coordinatesystem_pb2_grpc import (
48+
CoordinateSystemStub,
49+
)
4750

48-
self.stub = CoordinateSystemsStub(channel)
51+
self.stub = CoordinateSystemStub(channel)
4952

5053
@protect_grpc
5154
def create(self, **kwargs) -> dict: # noqa: D102
52-
raise NotImplementedError
55+
from ansys.api.discovery.v1.design.constructs.coordinatesystem_pb2 import (
56+
CreateRequest,
57+
CreateRequestData,
58+
)
59+
60+
# Create the request data - assumes all inputs are valid and of the proper type
61+
request = CreateRequest(
62+
request_data=[
63+
CreateRequestData(
64+
parent_id=kwargs["parent_id"],
65+
name=kwargs["name"],
66+
frame=from_frame_to_grpc_frame(kwargs["frame"]),
67+
)
68+
]
69+
)
70+
71+
# Call the gRPC service
72+
response = self.stub.Create(request=request)
73+
74+
# Return the response - formatted as a dictionary
75+
# Note: response.coordinate_systems is a repeated field, we return the first one
76+
coord_system = response.coordinate_systems[0]
77+
return {
78+
"id": coord_system.id,
79+
"name": coord_system.name,
80+
"frame": from_grpc_frame_to_frame(coord_system.frame),
81+
}

0 commit comments

Comments
 (0)