2626from ansys .geometry .core .errors import protect_grpc
2727
2828from ..base .patterns import GRPCPatternsService
29+ from .conversions import (
30+ build_grpc_id ,
31+ from_length_to_grpc_quantity ,
32+ from_angle_to_grpc_quantity ,
33+ )
2934
3035
3136class GRPCPatternsServiceV1 (GRPCPatternsService ): # pragma: no cover
@@ -43,30 +48,188 @@ class GRPCPatternsServiceV1(GRPCPatternsService): # pragma: no cover
4348
4449 @protect_grpc
4550 def __init__ (self , channel : grpc .Channel ): # noqa: D102
46- from ansys .api .geometry .v1 .patterns_pb2_grpc import PatternsStub
51+ from ansys .api .discovery .v1 .design . relationships . pattern_pb2_grpc import PatternStub
4752
48- self .stub = PatternsStub (channel )
53+ self .stub = PatternStub (channel )
4954
5055 @protect_grpc
5156 def create_linear_pattern (self , ** kwargs ) -> dict : # noqa: D102
52- raise NotImplementedError
57+ from ansys .api .discovery .v1 .design .relationships .pattern_pb2 import (
58+ LinearPatternCreationRequest ,
59+ LinearPatternCreationRequestData ,
60+ )
61+
62+ # Create the request - assumes all inputs are valid and of the proper type
63+ request = LinearPatternCreationRequest (
64+ request_data = [
65+ LinearPatternCreationRequestData (
66+ selection_ids = kwargs ["selection_ids" ],
67+ linear_direction_id = kwargs ["linear_direction_id" ],
68+ count_x = kwargs ["count_x" ],
69+ pitch_x = from_length_to_grpc_quantity (kwargs ["pitch_x" ]),
70+ two_dimensional = kwargs ["two_dimensional" ],
71+ count_y = kwargs ["count_y" ],
72+ pitch_y = (
73+ from_length_to_grpc_quantity (kwargs ["pitch_y" ])
74+ if kwargs ["pitch_y" ]
75+ else 0.0
76+ ),
77+ )
78+ ]
79+ )
80+
81+ # Call the gRPC service
82+ response = self .stub .CreateLinear (request )
83+
84+ # Return the response - formatted as a dictionary
85+ return {
86+ "success" : response .tracked_creation_response .creation_response .success ,
87+ }
5388
5489 @protect_grpc
5590 def modify_linear_pattern (self , ** kwargs ) -> dict : # noqa: D102
56- raise NotImplementedError
91+ from ansys .api .discovery .v1 .design .relationships .pattern_pb2 import (
92+ SetLinearPatternDataRequest ,
93+ SetLinearPatternDataRequestData ,
94+ )
95+
96+ # Create the request - assumes all inputs are valid and of the proper type
97+ request = SetLinearPatternDataRequest (
98+ request_data = [
99+ SetLinearPatternDataRequestData (
100+ selection_ids = [build_grpc_id (id ) for id in kwargs ["selection_ids" ]],
101+ count_x = kwargs ["count_x" ],
102+ pitch_x = from_length_to_grpc_quantity (kwargs ["pitch_x" ]),
103+ count_y = kwargs ["count_y" ],
104+ pitch_y = from_length_to_grpc_quantity (kwargs ["pitch_y" ]),
105+ new_seed_index = kwargs ["new_seed_index" ],
106+ old_seed_index = kwargs ["old_seed_index" ],
107+ )
108+ ]
109+ )
110+
111+ # Call the gRPC service
112+ response = self .stub .SetLinearData (request )
113+
114+ # Return the response - formatted as a dictionary
115+ return {
116+ "success" : response .tracked_set_response .set_response .success ,
117+ }
57118
58119 @protect_grpc
59120 def create_circular_pattern (self , ** kwargs ) -> dict : # noqa: D102
60- raise NotImplementedError
121+ from ansys .api .discovery .v1 .design .relationships .pattern_pb2 import (
122+ CircularPatternCreationRequest ,
123+ CircularPatternCreationRequestData ,
124+ )
125+
126+ from ansys .geometry .core .shapes .curves .line import Line
127+
128+ # Create direction if not None
129+ radial_direction = (
130+ from_unit_vector_to_grpc_direction (kwargs ["radial_direction" ])
131+ if kwargs ["radial_direction" ] is not None
132+ else None
133+ )
134+
135+ # Create linear pitch if not None
136+ linear_pitch = (
137+ from_length_to_grpc_quantity (kwargs ["linear_pitch" ])
138+ if kwargs ["linear_pitch" ]
139+ else None
140+ )
141+
142+ # Create line if axis is a line object
143+ circular_axis , axis = None , None
144+ if isinstance (kwargs ["circular_axis" ], Line ):
145+ axis = from_line_to_grpc_line (kwargs ["circular_axis" ])
146+ else :
147+ circular_axis = build_grpc_id (kwargs ["circular_axis" ])
148+
149+ # Create the request - assumes all inputs are valid and of the proper type
150+ request = CircularPatternCreationRequest (
151+ request_data = [
152+ CircularPatternCreationRequestData (
153+ selection_ids = [build_grpc_id (id ) for id in kwargs ["selection_ids" ]],
154+ circular_count = kwargs ["circular_count" ],
155+ circular_axis = circular_axis ,
156+ circular_angle = from_angle_to_grpc_quantity (kwargs ["circular_angle" ]),
157+ two_dimensional = kwargs ["two_dimensional" ],
158+ linear_count = kwargs ["linear_count" ],
159+ linear_pitch = linear_pitch ,
160+ radial_direction = radial_direction ,
161+ axis = axis ,
162+ )
163+ ]
164+ )
165+
166+ # Call the gRPC service
167+ response = self .stub .CreateCircularPattern (request )
168+
169+ # Return the response - formatted as a dictionary
170+ return {
171+ "success" : response .result .success ,
172+ }
61173
62174 @protect_grpc
63175 def modify_circular_pattern (self , ** kwargs ) -> dict : # noqa: D102
64- raise NotImplementedError
176+ # Create the request - assumes all inputs are valid and of the proper type
177+ request = ModifyCircularPatternRequest (
178+ selection = [build_grpc_id (id ) for id in kwargs ["selection_ids" ]],
179+ circular_count = kwargs ["circular_count" ],
180+ linear_count = kwargs ["linear_count" ],
181+ step_angle = from_angle_to_grpc_quantity (kwargs ["step_angle" ]),
182+ step_linear = from_angle_to_grpc_quantity (kwargs ["step_linear" ]),
183+ )
184+
185+ # Call the gRPC service
186+ response = self .stub .ModifyCircularPattern (request )
187+
188+ # Return the response - formatted as a dictionary
189+ return {
190+ "success" : response .result .success ,
191+ }
65192
66193 @protect_grpc
67194 def create_fill_pattern (self , ** kwargs ) -> dict : # noqa: D102
68- raise NotImplementedError
195+ from ansys .api .geometry .v0 .commands_pb2 import CreateFillPatternRequest
196+
197+ # Create the request - assumes all inputs are valid and of the proper type
198+ request = CreateFillPatternRequest (
199+ selection = [build_grpc_id (id ) for id in kwargs ["selection_ids" ]],
200+ linear_direction = build_grpc_id (kwargs ["linear_direction_id" ]),
201+ fill_pattern_type = kwargs ["fill_pattern_type" ].value ,
202+ margin = from_length_to_grpc_quantity (kwargs ["margin" ]),
203+ x_spacing = from_length_to_grpc_quantity (kwargs ["x_spacing" ]),
204+ y_spacing = from_length_to_grpc_quantity (kwargs ["y_spacing" ]),
205+ row_x_offset = from_length_to_grpc_quantity (kwargs ["row_x_offset" ]),
206+ row_y_offset = from_length_to_grpc_quantity (kwargs ["row_y_offset" ]),
207+ column_x_offset = from_length_to_grpc_quantity (kwargs ["column_x_offset" ]),
208+ column_y_offset = from_length_to_grpc_quantity (kwargs ["column_y_offset" ]),
209+ )
210+
211+ # Call the gRPC service
212+ response = self .stub .CreateFillPattern (request )
213+
214+ # Return the response - formatted as a dictionary
215+ return {
216+ "success" : response .result .success ,
217+ }
69218
70219 @protect_grpc
71220 def update_fill_pattern (self , ** kwargs ) -> dict : # noqa: D102
72- raise NotImplementedError
221+ from ansys .api .discovery .v1 .design .relationships .pattern_pb2 import UpdateFillRequest
222+
223+ # Create the request - assumes all inputs are valid and of the proper type
224+ request = UpdateFillRequest (
225+ ids = [build_grpc_id (id ) for id in kwargs ["selection_ids" ]],
226+ )
227+
228+ # Call the gRPC service
229+ response = self .stub .UpdateFillPattern (request )
230+
231+ # Return the response - formatted as a dictionary
232+ return {
233+ "success" : response .result .success ,
234+ }
235+
0 commit comments