1+ # Copyright (C) 2023 - 2025 ANSYS, Inc. and/or its affiliates.
2+ # SPDX-License-Identifier: MIT
3+ #
4+ #
5+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6+ # of this software and associated documentation files (the "Software"), to deal
7+ # in the Software without restriction, including without limitation the rights
8+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+ # copies of the Software, and to permit persons to whom the Software is
10+ # furnished to do so, subject to the following conditions:
11+ #
12+ # The above copyright notice and this permission notice shall be included in all
13+ # copies or substantial portions of the Software.
14+ #
15+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+ # SOFTWARE.
22+ """Module containing the assembly condition service implementation for v1."""
23+
24+ import grpc
25+
26+ from ansys .geometry .core .errors import protect_grpc
27+
28+ from ..base .assembly_condition import GRPCAssemblyConditionService
29+ from .conversions import build_grpc_id
30+
31+
32+ class GRPCAssemblyConditionServiceV1 (GRPCAssemblyConditionService ):
33+ """Assembly condition service for gRPC communication with the Geometry server.
34+
35+ This class provides methods to interact with the Geometry server's
36+ assembly condition service. It is specifically designed for the v1 version of the
37+ Geometry API.
38+
39+ Parameters
40+ ----------
41+ channel : grpc.Channel
42+ The gRPC channel to the server.
43+ """
44+
45+ @protect_grpc
46+ def __init__ (self , channel : grpc .Channel ): # noqa: D102
47+ from ansys .api .discovery .v1 .design .relationships .assemblycondition_pb2_grpc import (
48+ AssemblyConditionStub ,
49+ )
50+
51+ self .stub = AssemblyConditionStub (channel )
52+
53+ @protect_grpc
54+ def create_align_condition (self , ** kwargs ) -> dict : # noqa: D102
55+ from ansys .api .discovery .v1 .design .relationships .assemblycondition_pb2 import (
56+ CreateAlignRequest ,
57+ CreateAlignRequestData ,
58+ )
59+
60+ # Create the request - assumes all inputs are valid and of the proper type
61+ request = CreateAlignRequest (
62+ request_data = [CreateAlignRequestData (
63+ parent = build_grpc_id (kwargs ["parent_id" ]),
64+ geometric_a = build_grpc_id (kwargs ["geometric_a_id" ]),
65+ geometric_b = build_grpc_id (kwargs ["geometric_b_id" ]),
66+ )]
67+ )
68+
69+ # Call the gRPC service
70+ resp = self .stub .CreateAlign (request ).response_data [0 ]
71+
72+ # Return the response - formatted as a dictionary
73+ return {
74+ "id" : resp .align_condition .condition .id ,
75+ "is_deleted" : resp .align_condition .condition .is_deleted ,
76+ "is_enabled" : resp .align_condition .condition .is_enabled ,
77+ "is_satisfied" : resp .align_condition .condition .is_satisfied ,
78+ "offset" : resp .align_condition .offset ,
79+ "is_reversed" : resp .align_condition .is_reversed ,
80+ "is_valid" : resp .align_condition .is_valid ,
81+ }
82+
83+ @protect_grpc
84+ def create_tangent_condition (self , ** kwargs ) -> dict : # noqa: D102
85+ from ansys .api .discovery .v1 .design .relationships .assemblycondition_pb2 import (
86+ CreateTangentRequest ,
87+ CreateTangentRequestData ,
88+ )
89+
90+ # Create the request - assumes all inputs are valid and of the proper type
91+ request = CreateTangentRequest (
92+ request_data = [CreateTangentRequestData (
93+ parent = build_grpc_id (kwargs ["parent_id" ]),
94+ geometric_a = build_grpc_id (kwargs ["geometric_a_id" ]),
95+ geometric_b = build_grpc_id (kwargs ["geometric_b_id" ]),
96+ )]
97+ )
98+
99+ # Call the gRPC service
100+ resp = self .stub .CreateTangent (request ).response_data [0 ]
101+
102+ # Return the response - formatted as a dictionary
103+ return {
104+ "id" : resp .tangent_condition .condition .id ,
105+ "is_deleted" : resp .tangent_condition .condition .is_deleted ,
106+ "is_enabled" : resp .tangent_condition .condition .is_enabled ,
107+ "is_satisfied" : resp .tangent_condition .condition .is_satisfied ,
108+ "offset" : resp .tangent_condition .offset ,
109+ "is_reversed" : resp .tangent_condition .is_reversed ,
110+ "is_valid" : resp .tangent_condition .is_valid ,
111+ }
112+
113+ @protect_grpc
114+ def create_orient_condition (self , ** kwargs ) -> dict : # noqa: D102
115+ from ansys .api .discovery .v1 .design .relationships .assemblycondition_pb2 import (
116+ CreateOrientRequest ,
117+ CreateOrientRequestData ,
118+ )
119+
120+ # Create the request - assumes all inputs are valid and of the proper type
121+ request = CreateOrientRequest (
122+ request_data = [CreateOrientRequestData (
123+ parent = build_grpc_id (kwargs ["parent_id" ]),
124+ geometric_a = build_grpc_id (kwargs ["geometric_a_id" ]),
125+ geometric_b = build_grpc_id (kwargs ["geometric_b_id" ]),
126+ )]
127+ )
128+
129+ # Call the gRPC service
130+ resp = self .stub .CreateOrient (request ).response_data [0 ]
131+
132+ # Return the response - formatted as a dictionary
133+ return {
134+ "id" : resp .orient_condition .condition .id ,
135+ "is_deleted" : resp .orient_condition .condition .is_deleted ,
136+ "is_enabled" : resp .orient_condition .condition .is_enabled ,
137+ "is_satisfied" : resp .orient_condition .condition .is_satisfied ,
138+ "offset" : resp .orient_condition .offset ,
139+ "is_reversed" : resp .orient_condition .is_reversed ,
140+ "is_valid" : resp .orient_condition .is_valid ,
141+ }
0 commit comments