@@ -783,58 +783,52 @@ def boolean(self, **kwargs) -> dict: # noqa: D102
783783
784784 @protect_grpc
785785 def combine (self , ** kwargs ) -> dict : # noqa: D102
786- from ansys .api .geometry .v0 .bodies_pb2 import (
786+ from ansys .api .geometry .v0 .commands_pb2 import (
787787 CombineIntersectBodiesRequest ,
788788 CombineMergeBodiesRequest ,
789789 )
790790
791+ target_body = kwargs ["target" ]
791792 other_bodies = kwargs ["other" ]
792793 type_bool_op = kwargs ["type_bool_op" ]
793794 keep_other = kwargs ["keep_other" ]
794795
795796 if type_bool_op == "intersect" :
796- body_ids = [body ._grpc_id for body in other_bodies ]
797- target_ids = [self . _grpc_id ]
797+ body_ids = [build_grpc_id ( body .id ) for body in other_bodies ]
798+ target_ids = [build_grpc_id ( target_body . id ) ]
798799 request = CombineIntersectBodiesRequest (
799800 target_selection = target_ids ,
800801 tool_selection = body_ids ,
801802 subtract_from_target = False ,
802803 keep_cutter = keep_other ,
803804 )
804- response = self ._template . _commands_stub .CombineIntersectBodies (request )
805+ response = self .command_stub .CombineIntersectBodies (request )
805806 elif type_bool_op == "subtract" :
806- body_ids = [body ._grpc_id for body in other_bodies ]
807- target_ids = [self . _grpc_id ]
807+ body_ids = [build_grpc_id ( body .id ) for body in other_bodies ]
808+ target_ids = [build_grpc_id ( target_body . id ) ]
808809 request = CombineIntersectBodiesRequest (
809810 target_selection = target_ids ,
810811 tool_selection = body_ids ,
811812 subtract_from_target = True ,
812813 keep_cutter = keep_other ,
813814 )
814- response = self ._template . _commands_stub .CombineIntersectBodies (request )
815+ response = self .command_stub .CombineIntersectBodies (request )
815816 elif type_bool_op == "unite" :
816- bodies = [self ]
817+ bodies = [target_body ]
817818 bodies .extend (other_bodies )
818- body_ids = [body ._grpc_id for body in bodies ]
819+ body_ids = [build_grpc_id ( body .id ) for body in bodies ]
819820 request = CombineMergeBodiesRequest (target_selection = body_ids )
820- response = self ._template . _commands_stub .CombineMergeBodies (request )
821+ response = self .command_stub .CombineMergeBodies (request )
821822 else :
822823 raise ValueError ("Unknown operation requested" )
823824 if not response .success :
824825 raise ValueError (
825826 f"Operation of type '{ type_bool_op } ' failed: { kwargs ['err_msg' ]} .\n "
826- f"Involving bodies:{ self } , { other_bodies } "
827+ f"Involving bodies:{ target_body } , { other_bodies } "
827828 )
828829
829- if not keep_other :
830- for b in other_bodies :
831- b .parent_component .delete_body (b )
832-
833- tracker_response = response .result .complete_command_response
834- serialized_tracker_response = serialize_tracker_command_response (response = tracker_response )
835-
836830 # Return the response - formatted as a dictionary
837- return {"complete_command_response" : serialized_tracker_response }
831+ return {"complete_command_response" : serialize_tracker_command_response ( response = response ) }
838832
839833 @protect_grpc
840834 def split_body (self , ** kwargs ) -> dict : # noqa: D102
0 commit comments