2525
2626from ansys .geometry .core .errors import protect_grpc
2727
28- from ..base .named_selection import GRPCPrepareToolsService
28+ from ..base .prepare_tools import GRPCPrepareToolsService
2929
3030
31- class GRPCPrepareToolsServiceV0 (GRPCPrepareToolsService ):
31+ class GRPCPrepareToolsServiceV0 (GRPCPrepareToolsService ):
32+ """Prepare tools service for gRPC communication with the Geometry server.
33+
34+ This class provides methods to interact with the Geometry server's
35+ Prepare Tools service. It is specifically designed for the v0 version
36+ of the Geometry API.
37+
38+ Parameters
39+ ----------
40+ channel : grpc.Channel
41+ The gRPC channel to the server.
42+ """
43+
44+ @protect_grpc
45+ def __init__ (self , channel : grpc .Channel ): # noqa: D102
46+ from ansys .api .geometry .v0 .preparetools_pb2_grpc import PrepareToolsStub
47+
48+ self .stub = PrepareToolsStub (channel )
49+
50+ @protect_grpc
51+ def extract_volume_from_faces (self , ** kwargs ) -> dict : # noqa: D102
52+ from ansys .api .dbu .v0 .dbumodels_pb2 import EntityIdentifier
53+ from ansys .api .geometry .v0 .preparetools_pb2 import ExtractVolumeFromFacesRequest
54+
55+ # Create the request - assumes all inputs are valid and of the proper type
56+ request = ExtractVolumeFromFacesRequest (
57+ sealing_faces = [EntityIdentifier (id = face .id ) for face in kwargs ["sealing_faces" ]],
58+ inside_faces = [EntityIdentifier (id = face .id ) for face in kwargs ["inside_faces" ]],
59+ )
60+
61+ # Call the gRPC service
62+ response = self .stub .ExtractVolumeFromFaces (request )
63+
64+ # Return the response - formatted as a dictionary
65+ return {
66+ "success" : response .success ,
67+ "created_bodies" : [body .id for body in response .created_bodies ],
68+ }
69+
70+
71+ @protect_grpc
72+ def extract_volume_from_edge_loops (self , ** kwargs ) -> dict : # noqa: D102
73+ from ansys .api .dbu .v0 .dbumodels_pb2 import EntityIdentifier
74+ from ansys .api .geometry .v0 .preparetools_pb2 import ExtractVolumeFromEdgeLoopsRequest
75+
76+ # Create the request - assumes all inputs are valid and of the proper type
77+ request = ExtractVolumeFromEdgeLoopsRequest (
78+ sealing_edges = [EntityIdentifier (id = face .id ) for face in kwargs ["sealing_edges" ]],
79+ inside_faces = [EntityIdentifier (id = face .id ) for face in kwargs ["inside_faces" ]],
80+ )
81+
82+ # Call the gRPC service
83+ response = self .stub .ExtractVolumeFromEdgeLoops (request )
84+
85+ # Return the response - formatted as a dictionary
86+ return {
87+ "success" : response .success ,
88+ "created_bodies" : [body .id for body in response .created_bodies ],
89+ }
90+
91+
92+ @protect_grpc
93+ def remove_rounds (self , ** kwargs ) -> dict : # noqa: D102
94+ from ansys .api .geometry .v0 .models_pb2 import Face
95+ from ansys .api .geometry .v0 .preparetools_pb2 import RemoveRoundsRequest
96+
97+ # Create the request - assumes all inputs are valid and of the proper type
98+ request = RemoveRoundsRequest (
99+ selection = [Face (id = round .id ) for round in kwargs ["rounds" ]],
100+ auto_shrink = kwargs ["auto_shrink" ],
101+ )
102+
103+ # Call the gRPC service
104+ response = self .stub .RemoveRounds (request )
105+
106+ # Return the response - formatted as a dictionary
107+ return {
108+ "success" : response .result ,
109+ }
110+
111+ @protect_grpc
112+ def share_topology (self , ** kwargs ) -> dict : # noqa: D102
113+ from ansys .api .geometry .v0 .models_pb2 import Body
114+ from ansys .api .geometry .v0 .preparetools_pb2 import ShareTopologyRequest
115+
116+ # Create the request - assumes all inputs are valid and of the proper type
117+ request = ShareTopologyRequest (
118+ selection = [Body (id = body .id ) for body in kwargs ["bodies" ]],
119+ tolerance = kwargs ["tolerance" ],
120+ preserve_instances = kwargs ["preserve_instances" ],
121+ )
122+
123+ # Call the gRPC service
124+ response = self .stub .ShareTopology (request )
125+
126+ # Return the response - formatted as a dictionary
127+ return {
128+ "success" : response .result ,
129+ }
130+
131+ @protect_grpc
132+ def enhanced_share_topology (self , ** kwargs ) -> dict : # noqa: D102
133+ from ansys .api .geometry .v0 .models_pb2 import Body
134+ from ansys .api .geometry .v0 .preparetools_pb2 import ShareTopologyRequest
135+
136+ # Create the request - assumes all inputs are valid and of the proper type
137+ request = ShareTopologyRequest (
138+ selection = [Body (id = body .id ) for body in kwargs ["bodies" ]],
139+ tolerance = kwargs ["tolerance" ],
140+ preserve_instances = kwargs ["preserve_instances" ],
141+ )
142+
143+ # Call the gRPC service
144+ response = self .stub .EnhancedShareTopology (request )
145+
146+ # Return the response - formatted as a dictionary
147+ return {
148+ "success" : response .success ,
149+ "found" : response .found ,
150+ "repaired" : response .repaired ,
151+ "created_bodies_monikers" : response .created_bodies_monikers ,
152+ "modified_bodies_monikers" : response .modified_bodies_monikers ,
153+ "deleted_bodies_monikers" : response .deleted_bodies_monikers ,
154+ }
155+
156+ @protect_grpc
157+ def find_logos (self , ** kwargs ) -> dict : # noqa: D102
158+ from ansys .api .dbu .v0 .dbumodels_pb2 import EntityIdentifier
159+ from ansys .api .geometry .v0 .models_pb2 import FindLogoOptions
160+ from ansys .api .geometry .v0 .preparetools_pb2 import FindLogosRequest
161+
162+ # Create the gRPC options object
163+ options = FindLogoOptions (
164+ min_height = kwargs ["min_height" ],
165+ max_height = kwargs ["max_height" ],
166+ )
167+
168+ # Create the request - assumes all inputs are valid and of the proper type
169+ request = FindLogosRequest (
170+ bodies = [EntityIdentifier (id = body .id ) for body in kwargs ["bodies" ]],
171+ options = options ,
172+ )
173+
174+ # Call the gRPC service
175+ response = self .stub .FindLogos (request )
176+
177+ # Return the response - formatted as a dictionary
178+ return {
179+ "id" : response .id ,
180+ "face_ids" : [face .id for face in response .logo_faces ],
181+ }
182+
183+ @protect_grpc
184+ def find_and_remove_logos (self , ** kwargs ) -> dict : # noqa: D102
185+ from ansys .api .dbu .v0 .dbumodels_pb2 import EntityIdentifier
186+ from ansys .api .geometry .v0 .models_pb2 import FindLogoOptions
187+ from ansys .api .geometry .v0 .preparetools_pb2 import FindLogosRequest
188+
189+ # Create the gRPC options object
190+ options = FindLogoOptions (
191+ min_height = kwargs ["min_height" ],
192+ max_height = kwargs ["max_height" ],
193+ )
194+
195+ # Create the request - assumes all inputs are valid and of the proper type
196+ request = FindLogosRequest (
197+ bodies = [EntityIdentifier (id = body .id ) for body in kwargs ["bodies" ]],
198+ options = options ,
199+ )
200+
201+ # Call the gRPC service
202+ response = self .stub .FindAndRemoveLogos (request )
203+
204+ # Return the response - formatted as a dictionary
205+ return {
206+ "success" : response .success
207+ }
0 commit comments