2525from pathlib import Path
2626from typing import Union
2727
28- from ansys .api .dbu .v0 .dbumodels_pb2 import EntityIdentifier
29- from ansys .api .geometry .v0 .commands_pb2 import (
30- AssignMidSurfaceOffsetTypeRequest ,
31- AssignMidSurfaceThicknessRequest ,
32- CreateBeamCircularProfileRequest ,
33- )
3428from ansys .api .geometry .v0 .commands_pb2_grpc import CommandsStub
3529from beartype import beartype as check_input_types
36- from google .protobuf .empty_pb2 import Empty
3730import numpy as np
3831from pint import Quantity , UndefinedUnitError
3932
4033from ansys .geometry .core .connection .backend import BackendType
41- from ansys .geometry .core .connection .conversions import (
42- plane_to_grpc_plane ,
43- point3d_to_grpc_point ,
44- )
4534from ansys .geometry .core .designer .beam import (
4635 Beam ,
4736 BeamCircularProfile ,
@@ -330,9 +319,9 @@ def __export_and_download_legacy(self, format: DesignFileFormat) -> bytes:
330319 # Process response
331320 self ._grpc_client .log .debug (f"Requesting design download in { format } format." )
332321 if format is DesignFileFormat .SCDOCX :
333- response = self ._commands_stub . DownloadFile ( Empty () )
322+ response = self ._grpc_client . services . designs . download_file ( )
334323 received_bytes = bytes ()
335- received_bytes += response .data
324+ received_bytes += response .get ( " data" )
336325 elif format in [
337326 DesignFileFormat .PARASOLID_TEXT ,
338327 DesignFileFormat .PARASOLID_BIN ,
@@ -818,17 +807,16 @@ def add_beam_circular_profile(
818807 if not dir_x .is_perpendicular_to (dir_y ):
819808 raise ValueError ("Direction X and direction Y must be perpendicular." )
820809
821- request = CreateBeamCircularProfileRequest (
822- origin = point3d_to_grpc_point (center ),
810+ self ._grpc_client .log .debug (f"Creating a beam circular profile on { self .id } ..." )
811+
812+ response = self ._grpc_client ._services .designs .create_beam_circular_profile (
813+ center = center ,
823814 radius = radius .value .m_as (DEFAULT_UNITS .SERVER_LENGTH ),
824- plane = plane_to_grpc_plane ( Plane (center , dir_x , dir_y ) ),
815+ plane = Plane (center , dir_x , dir_y ),
825816 name = name ,
826817 )
827818
828- self ._grpc_client .log .debug (f"Creating a beam circular profile on { self .id } ..." )
829-
830- response = self ._commands_stub .CreateBeamCircularProfile (request )
831- profile = BeamCircularProfile (response .id , name , radius , center , dir_x , dir_y )
819+ profile = BeamCircularProfile (response .get ("id" ), name , radius , center , dir_x , dir_y )
832820 self ._beam_profiles [profile .name ] = profile
833821
834822 self ._grpc_client .log .debug (
@@ -912,10 +900,8 @@ def add_midsurface_thickness(self, thickness: Quantity, bodies: list[Body]) -> N
912900 )
913901
914902 # Assign mid-surface thickness
915- self ._commands_stub .AssignMidSurfaceThickness (
916- AssignMidSurfaceThicknessRequest (
917- bodies_or_faces = ids , thickness = thickness .m_as (DEFAULT_UNITS .SERVER_LENGTH )
918- )
903+ self ._grpc_client ._services .designs .assign_midsurface_thickness (
904+ bodies_or_faces = ids , thickness = thickness .m_as (DEFAULT_UNITS .SERVER_LENGTH )
919905 )
920906
921907 # Once the assignment has gone fine, store the values
@@ -952,8 +938,8 @@ def add_midsurface_offset(self, offset_type: MidSurfaceOffsetType, bodies: list[
952938 )
953939
954940 # Assign mid-surface offset type
955- self ._commands_stub . AssignMidSurfaceOffsetType (
956- AssignMidSurfaceOffsetTypeRequest ( bodies_or_faces = ids , offset_type = offset_type .value )
941+ self ._grpc_client . _services . designs . assign_midsurface_offset_type (
942+ bodies_or_faces = ids , offset_type = offset_type .value
957943 )
958944
959945 # Once the assignment has gone fine, store the values
@@ -976,7 +962,7 @@ def delete_beam_profile(self, beam_profile: BeamProfile | str) -> None:
976962 removal_obj = self ._beam_profiles .get (removal_name , None )
977963
978964 if removal_obj :
979- self ._commands_stub . DeleteBeamProfile ( EntityIdentifier ( id = removal_obj .id ) )
965+ self ._grpc_client . _services . designs . delete_beam_profile ( id = removal_obj .id )
980966 self ._beam_profiles .pop (removal_name )
981967 self ._grpc_client .log .debug (f"Beam profile { removal_name } successfully deleted." )
982968 else :
0 commit comments