2626from ansys .geometry .core .errors import protect_grpc
2727
2828from ..base .model_tools import GRPCModelToolsService
29+ from .conversions import (
30+ build_grpc_id ,
31+ from_length_to_grpc_quantity ,
32+ serialize_tracked_command_response ,
33+ )
2934
3035
3136class GRPCModelToolsServiceV1 (GRPCModelToolsService ):
@@ -43,30 +48,162 @@ class GRPCModelToolsServiceV1(GRPCModelToolsService):
4348
4449 @protect_grpc
4550 def __init__ (self , channel : grpc .Channel ): # noqa: D102
46- from ansys .api .geometry .v1 .model_tools_pb2_grpc import ModelToolsStub
51+ from ansys .api .discovery .v1 .operations .edit_pb2_grpc import EditStub
52+ from ansys .api .discovery .v1 .operations .sketch_pb2_grpc import SketchStub
4753
48- self ._stub = ModelToolsStub (channel )
54+ self .stub = EditStub (channel )
55+ self .sketch_stub = SketchStub (channel )
4956
5057 @protect_grpc
5158 def chamfer (self , ** kwargs ) -> dict : # noqa: D102
52- raise NotImplementedError
59+ from ansys .api .discovery .v1 .operations .edit_pb2 import ChamferRequest , ChamferRequestData
60+
61+ # Create the request - assumes all inputs are valid and of the proper type
62+ request = ChamferRequest (
63+ request_data = [
64+ ChamferRequestData (
65+ ids = [build_grpc_id (id ) for id in kwargs ["selection_ids" ]],
66+ distance = from_length_to_grpc_quantity (kwargs ["distance" ]),
67+ )
68+ ]
69+ )
70+
71+ # Call the gRPC service
72+ response = self .stub .Chamfer (request ).response_data [0 ]
73+
74+ # Return the response as a dictionary
75+ return {
76+ "success" : response .success ,
77+ }
5378
5479 @protect_grpc
5580 def fillet (self , ** kwargs ) -> dict : # noqa: D102
56- raise NotImplementedError
81+ from ansys .api .discovery .v1 .operations .edit_pb2 import FilletRequest , FilletRequestData
82+
83+ # Create the request - assumes all inputs are valid and of the proper type
84+ request = FilletRequest (
85+ request_data = [
86+ FilletRequestData (
87+ ids = [build_grpc_id (id ) for id in kwargs ["selection_ids" ]],
88+ radius = from_length_to_grpc_quantity (kwargs ["radius" ]),
89+ )
90+ ]
91+ )
92+
93+ # Call the gRPC service and serialize the response
94+ response = self .stub .Fillet (request )
95+ tracked_response = serialize_tracked_command_response (response .tracked_command_response )
96+
97+ # Return the response as a dictionary
98+ return {
99+ "success" : tracked_response .get ("success" ),
100+ }
57101
58102 @protect_grpc
59103 def full_fillet (self , ** kwargs ) -> dict : # noqa: D102
60- raise NotImplementedError
104+ from ansys .api .discovery .v1 .operations .edit_pb2 import FullFilletRequest
105+
106+ # Create the request - assumes all inputs are valid and of the proper type
107+ request = FullFilletRequest (
108+ face_ids = [build_grpc_id (id ) for id in kwargs ["selection_ids" ]],
109+ )
110+
111+ # Call the gRPC service and serialize the response
112+ response = self .stub .FullFillet (request )
113+ tracked_response = serialize_tracked_command_response (response .tracked_command_response )
114+
115+ # Return the response as a dictionary
116+ return {
117+ "success" : tracked_response .get ("success" ),
118+ }
61119
62120 @protect_grpc
63121 def move_rotate (self , ** kwargs ) -> dict : # noqa: D102
64- raise NotImplementedError
122+ from ansys .api .discovery .v1 .operations .edit_pb2 import (
123+ MoveRotateRequest ,
124+ MoveRotateRequestData ,
125+ )
126+
127+ from .conversions import from_angle_to_grpc_quantity , from_line_to_grpc_line
128+
129+ # Create the request - assumes all inputs are valid and of the proper type
130+ request = MoveRotateRequest (
131+ request_data = [
132+ MoveRotateRequestData (
133+ selection_ids = [build_grpc_id (kwargs ["selection_id" ])],
134+ axis = from_line_to_grpc_line (kwargs ["axis" ]),
135+ angle = from_angle_to_grpc_quantity (kwargs ["angle" ]),
136+ )
137+ ]
138+ )
139+
140+ # Call the gRPC service and serialize the response
141+ response = self .stub .MoveRotate (request )
142+ tracked_response = serialize_tracked_command_response (response .tracked_command_response )
143+
144+ # Return the response as a dictionary
145+ return {
146+ "success" : tracked_response .get ("success" ),
147+ "modified_bodies" : [
148+ body .get ("id" ).id for body in tracked_response .get ("modified_bodies" )
149+ ],
150+ "modified_faces" : [
151+ face .get ("id" ).id for face in tracked_response .get ("modified_faces" )
152+ ],
153+ "modified_edges" : [
154+ edge .get ("id" ).id for edge in tracked_response .get ("modified_edges" )
155+ ],
156+ }
65157
66158 @protect_grpc
67159 def move_translate (self , ** kwargs ) -> dict : # noqa: D102
68- raise NotImplementedError
160+ from ansys .api .discovery .v1 .operations .edit_pb2 import (
161+ MoveTranslateRequest ,
162+ MoveTranslateRequestData ,
163+ )
164+
165+ from .conversions import from_unit_vector_to_grpc_direction
166+
167+ # Create the request - assumes all inputs are valid and of the proper type
168+ request = MoveTranslateRequest (
169+ request_data = [
170+ MoveTranslateRequestData (
171+ selection_ids = [build_grpc_id (kwargs ["selection_id" ])],
172+ direction = from_unit_vector_to_grpc_direction (kwargs ["direction" ]),
173+ distance = from_length_to_grpc_quantity (kwargs ["distance" ]),
174+ )
175+ ]
176+ )
177+ # Call the gRPC service and serialize the response
178+ response = self .stub .MoveTranslate (request )
179+ tracked_response = serialize_tracked_command_response (response .tracked_command_response )
180+
181+ # Return the response as a dictionary
182+ return {
183+ "success" : tracked_response .get ("success" ),
184+ }
69185
70186 @protect_grpc
71187 def create_sketch_line (self , ** kwargs ) -> dict : # noqa: D102
72- raise NotImplementedError
188+ from ansys .api .discovery .v1 .operations .sketch_pb2 import (
189+ CreateSketchLineRequest ,
190+ CreateSketchLineRequestData ,
191+ )
192+
193+ from .conversions import from_point3d_to_grpc_point
194+
195+ # Create the request - assumes all inputs are valid and of the proper type
196+ request = CreateSketchLineRequest (
197+ request_data = [
198+ CreateSketchLineRequestData (
199+ point1 = from_point3d_to_grpc_point (kwargs ["start" ]),
200+ point2 = from_point3d_to_grpc_point (kwargs ["end" ]),
201+ )
202+ ]
203+ )
204+
205+ # Call the gRPC service
206+ _ = self .sketch_stub .CreateSketchLine (request )
207+
208+ # Return the response - formatted as a dictionary
209+ return {}
0 commit comments