2626from ansys .geometry .core .errors import protect_grpc
2727
2828from ..base .materials import GRPCMaterialsService
29+ from .conversions import from_material_to_grpc_material
2930
3031
31- class GRPCMaterialsServiceV1 (GRPCMaterialsService ): # pragma: no cover
32+ class GRPCMaterialsServiceV1 (GRPCMaterialsService ):
3233 """Materials service for gRPC communication with the Geometry server.
3334
3435 This class provides methods to interact with the Geometry server's
@@ -43,14 +44,36 @@ class GRPCMaterialsServiceV1(GRPCMaterialsService): # pragma: no cover
4344
4445 @protect_grpc
4546 def __init__ (self , channel : grpc .Channel ): # noqa: D102
46- from ansys .api .geometry .v1 .materials_pb2_grpc import MaterialsStub
47+ from ansys .api .discovery .v1 .design . data . cadmaterial_pb2_grpc import MaterialsStub
4748
4849 self .stub = MaterialsStub (channel )
4950
5051 @protect_grpc
5152 def add_material (self , ** kwargs ) -> dict : # noqa: D102
52- raise NotImplementedError
53+ from ansys .api .discovery .v1 .design .data .cadmaterial_pb2_grpc import CreateRequest
54+
55+ # Create the request - assumes all inputs are valid and of the proper type
56+ request = CreateRequest (
57+ request_data = from_material_to_grpc_material (kwargs ["material" ]),
58+ )
59+
60+ # Call the gRPC service
61+ _ = self .stub .Create (request = request )
62+
63+ # Convert the response to a dictionary
64+ return {}
5365
5466 @protect_grpc
5567 def remove_material (self , ** kwargs ) -> dict : # noqa: D102
56- raise NotImplementedError
68+ from ansys .api .discovery .v1 .design .data .cadmaterial_pb2_grpc import DeleteRequest
69+
70+ # Create the request - assumes all inputs are valid and of the proper type
71+ request = DeleteRequest (
72+ request_data = [from_material_to_grpc_material (mat ) for mat in kwargs ["materials" ]]
73+ )
74+
75+ # Call the gRPC service
76+ _ = self .stub .Delete (request = request )
77+
78+ # Convert the response to a dictionary
79+ return {}
0 commit comments