2626from ansys .geometry .core .errors import protect_grpc
2727
2828from ..base .coordinate_systems import GRPCCoordinateSystemService
29+ from .conversions import from_frame_to_grpc_frame , from_grpc_frame_to_frame
2930
3031
3132class 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