2222"""Module containing the bodies service implementation for v0."""
2323
2424import grpc
25- import pint
2625
2726import ansys .geometry .core as pyansys_geom
2827from ansys .geometry .core .errors import protect_grpc
29- from ansys .geometry .core .misc .measurements import DEFAULT_UNITS
3028
3129from ..base .bodies import GRPCBodyService
3230from ..base .conversions import from_measurement_to_server_angle , from_measurement_to_server_length
@@ -187,17 +185,19 @@ def sweep_with_guide(self, **kwargs) -> dict: # noqa: D102
187185 request = SweepWithGuideRequest (
188186 request_data = [
189187 SweepWithGuideRequestData (
190- name = data .name ,
191- parent = build_grpc_id (data .parent_id ),
192- plane = from_plane_to_grpc_plane (data .sketch .plane ),
188+ name = sweep_item .name ,
189+ parent = build_grpc_id (sweep_item .parent_id ),
190+ plane = from_plane_to_grpc_plane (sweep_item .sketch .plane ),
193191 geometries = from_sketch_shapes_to_grpc_geometries (
194- data .sketch .plane , data .sketch .edges , data .sketch .faces
192+ sweep_item .sketch .plane ,
193+ sweep_item .sketch .edges ,
194+ sweep_item .sketch .faces ,
195195 ),
196- path = from_trimmed_curve_to_grpc_trimmed_curve (data .path ),
197- guide = from_trimmed_curve_to_grpc_trimmed_curve (data .guide ),
198- tight_tolerance = data .tight_tolerance ,
196+ path = from_trimmed_curve_to_grpc_trimmed_curve (sweep_item .path ),
197+ guide = from_trimmed_curve_to_grpc_trimmed_curve (sweep_item .guide ),
198+ tight_tolerance = sweep_item .tight_tolerance ,
199199 )
200- for data in kwargs ["sweep_data" ]
200+ for sweep_item in kwargs ["sweep_data" ]
201201 ],
202202 )
203203
@@ -213,8 +213,8 @@ def sweep_with_guide(self, **kwargs) -> dict: # noqa: D102
213213 "master_id" : body .master_id ,
214214 "is_surface" : body .is_surface ,
215215 }
216+ for body in resp .bodies
216217 ]
217- for body in resp .bodies
218218 }
219219
220220 @protect_grpc
@@ -460,11 +460,13 @@ def get_vertices(self, **kwargs) -> dict: # noqa: D102
460460
461461 @protect_grpc
462462 def get_volume (self , ** kwargs ) -> dict : # noqa: D102
463+ from .conversions import from_grpc_volume_to_volume
464+
463465 # Call the gRPC service
464466 resp = self .stub .GetVolume (request = build_grpc_id (kwargs ["id" ]))
465467
466468 # Return the response - formatted as a dictionary
467- return {"volume" : pint . Quantity (resp .volume , DEFAULT_UNITS . SERVER_VOLUME )}
469+ return {"volume" : from_grpc_volume_to_volume (resp .volume )}
468470
469471 @protect_grpc
470472 def get_bounding_box (self , ** kwargs ) -> dict : # noqa: D102
@@ -796,8 +798,8 @@ def combine(self, **kwargs) -> dict: # noqa: D102
796798 transfer_named_selections = kwargs ["transfer_named_selections" ]
797799
798800 if type_bool_op == "intersect" :
799- body_ids = [build_grpc_id (body . id ) for body in other_bodies ]
800- target_ids = [build_grpc_id (target_body . id )]
801+ body_ids = [build_grpc_id (body ) for body in other_bodies ]
802+ target_ids = [build_grpc_id (target_body )]
801803 request = CombineIntersectBodiesRequest (
802804 target_selection = target_ids ,
803805 tool_selection = body_ids ,
@@ -807,8 +809,8 @@ def combine(self, **kwargs) -> dict: # noqa: D102
807809 )
808810 response = self .command_stub .CombineIntersectBodies (request )
809811 elif type_bool_op == "subtract" :
810- body_ids = [build_grpc_id (body . id ) for body in other_bodies ]
811- target_ids = [build_grpc_id (target_body . id )]
812+ body_ids = [build_grpc_id (body ) for body in other_bodies ]
813+ target_ids = [build_grpc_id (target_body )]
812814 request = CombineIntersectBodiesRequest (
813815 target_selection = target_ids ,
814816 tool_selection = body_ids ,
@@ -820,7 +822,7 @@ def combine(self, **kwargs) -> dict: # noqa: D102
820822 elif type_bool_op == "unite" :
821823 bodies = [target_body ]
822824 bodies .extend (other_bodies )
823- body_ids = [build_grpc_id (body . id ) for body in bodies ]
825+ body_ids = [build_grpc_id (body ) for body in bodies ]
824826 request = CombineMergeBodiesRequest (target_selection = body_ids )
825827 response = self .command_stub .CombineMergeBodies (request )
826828 else :
0 commit comments