Skip to content

Commit 538ff14

Browse files
jacobrkerstetterpre-commit-ci[bot]pyansys-ci-botRobPasMue
authored
feat: move geometry commands to versioned architecture (#2234)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: pyansys-ci-bot <[email protected]> Co-authored-by: Roberto Pastor Muela <[email protected]>
1 parent b50e559 commit 538ff14

31 files changed

+2290
-475
lines changed

.github/workflows/ci_cd.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ env:
1717
ANSRV_GEO_PORT: 700
1818
ANSRV_GEO_LICENSE_SERVER: ${{ secrets.LICENSE_SERVER }}
1919
GEO_CONT_NAME: ans_geo
20-
RESET_IMAGE_CACHE: 6
20+
RESET_IMAGE_CACHE: 7
2121
IS_WORKFLOW_RUNNING: True
2222
ARTIFACTORY_VERSION: v261
2323

doc/changelog.d/2234.added.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Move geometry commands to versioned architecture

src/ansys/geometry/core/_grpc/_services/_service.py

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@
2424

2525
from .._version import GeometryApiProtos, set_proto_version
2626
from .base.admin import GRPCAdminService
27+
from .base.assembly_controls import GRPCAssemblyControlsService
28+
from .base.beams import GRPCBeamsService
2729
from .base.bodies import GRPCBodyService
30+
from .base.commands import GRPCCommandsService
2831
from .base.coordinate_systems import GRPCCoordinateSystemService
2932
from .base.dbuapplication import GRPCDbuApplicationService
3033
from .base.designs import GRPCDesignsService
@@ -33,8 +36,10 @@
3336
from .base.faces import GRPCFacesService
3437
from .base.materials import GRPCMaterialsService
3538
from .base.measurement_tools import GRPCMeasurementToolsService
39+
from .base.model_tools import GRPCModelToolsService
3640
from .base.named_selection import GRPCNamedSelectionService
3741
from .base.parts import GRPCPartsService
42+
from .base.patterns import GRPCPatternsService
3843
from .base.prepare_tools import GRPCPrepareToolsService
3944
from .base.repair_tools import GRPCRepairToolsService
4045

@@ -78,7 +83,10 @@ def __init__(self, channel: grpc.Channel, version: GeometryApiProtos | str | Non
7883

7984
# Lazy load all the services
8085
self._admin = None
86+
self._assembly_controls = None
87+
self._beams = None
8188
self._bodies = None
89+
self._commands = None
8290
self._coordinate_systems = None
8391
self._dbu_application = None
8492
self._designs = None
@@ -87,8 +95,10 @@ def __init__(self, channel: grpc.Channel, version: GeometryApiProtos | str | Non
8795
self._faces = None
8896
self._materials = None
8997
self._measurement_tools = None
98+
self._model_tools = None
9099
self._named_selection = None
91100
self._parts = None
101+
self._patterns = None
92102
self._prepare_tools = None
93103
self._repair_tools = None
94104

@@ -118,6 +128,58 @@ def admin(self) -> GRPCAdminService:
118128

119129
return self._admin
120130

131+
@property
132+
def assembly_controls(self) -> GRPCAssemblyControlsService:
133+
"""
134+
Get the assembly controls service for the specified version.
135+
136+
Returns
137+
-------
138+
GRPCAssemblyControlsService
139+
The assembly controls service for the specified version.
140+
"""
141+
if not self._assembly_controls:
142+
# Import the appropriate assembly controls service based on the version
143+
from .v0.assembly_controls import GRPCAssemblyControlsServiceV0
144+
from .v1.assembly_controls import GRPCAssemblyControlsServiceV1
145+
146+
if self.version == GeometryApiProtos.V0:
147+
self._assembly_controls = GRPCAssemblyControlsServiceV0(self.channel)
148+
elif self.version == GeometryApiProtos.V1: # pragma: no cover
149+
# V1 is not implemented yet
150+
self._assembly_controls = GRPCAssemblyControlsServiceV1(self.channel)
151+
else: # pragma: no cover
152+
# This should never happen as the version is set in the constructor
153+
raise ValueError(f"Unsupported version: {self.version}")
154+
155+
return self._assembly_controls
156+
157+
@property
158+
def beams(self) -> GRPCBeamsService:
159+
"""
160+
Get the Beams service for the specified version.
161+
162+
Returns
163+
-------
164+
GRPCBeamsService
165+
The Beams service for the specified version.
166+
"""
167+
if not self._beams:
168+
# Import the appropriate Beams service based on the version
169+
from .v0.beams import GRPCBeamsServiceV0
170+
from .v1.beams import GRPCBeamsServiceV1
171+
172+
if self.version == GeometryApiProtos.V0:
173+
self._beams = GRPCBeamsServiceV0(self.channel)
174+
elif self.version == GeometryApiProtos.V1: # pragma: no cover
175+
# V1 is not implemented yet
176+
self._beams = GRPCBeamsServiceV1(self.channel)
177+
else: # pragma: no cover
178+
# This should never happen as the version is set in the constructor
179+
raise ValueError(f"Unsupported version: {self.version}")
180+
181+
return self._beams
182+
121183
@property
122184
def bodies(self) -> GRPCBodyService:
123185
"""
@@ -144,6 +206,32 @@ def bodies(self) -> GRPCBodyService:
144206

145207
return self._bodies
146208

209+
@property
210+
def commands(self) -> GRPCCommandsService:
211+
"""
212+
Get the commands service for the specified version.
213+
214+
Returns
215+
-------
216+
GRPCCommandsService
217+
The commands service for the specified version.
218+
"""
219+
if not self._commands:
220+
# Import the appropriate commands service based on the version
221+
from .v0.commands import GRPCCommandsServiceV0
222+
from .v1.commands import GRPCCommandsServiceV1
223+
224+
if self.version == GeometryApiProtos.V0:
225+
self._commands = GRPCCommandsServiceV0(self.channel)
226+
elif self.version == GeometryApiProtos.V1: # pragma: no cover
227+
# V1 is not implemented yet
228+
self._commands = GRPCCommandsServiceV1(self.channel)
229+
else: # pragma: no cover
230+
# This should never happen as the version is set in the constructor
231+
raise ValueError(f"Unsupported version: {self.version}")
232+
233+
return self._commands
234+
147235
@property
148236
def coordinate_systems(self) -> GRPCCoordinateSystemService:
149237
"""
@@ -352,6 +440,32 @@ def measurement_tools(self) -> GRPCMeasurementToolsService:
352440

353441
return self._measurement_tools
354442

443+
@property
444+
def model_tools(self) -> GRPCModelToolsService:
445+
"""
446+
Get the model tools service for the specified version.
447+
448+
Returns
449+
-------
450+
GRPCModelToolsService
451+
The model tools service for the specified version.
452+
"""
453+
if not self._model_tools:
454+
# Import the appropriate model tools service based on the version
455+
from .v0.model_tools import GRPCModelToolsServiceV0
456+
from .v1.model_tools import GRPCModelToolsServiceV1
457+
458+
if self.version == GeometryApiProtos.V0:
459+
self._model_tools = GRPCModelToolsServiceV0(self.channel)
460+
elif self.version == GeometryApiProtos.V1:
461+
# V1 is not implemented yet
462+
self._model_tools = GRPCModelToolsServiceV1(self.channel)
463+
else: # pragma: no cover
464+
# This should never happen as the version is set in the constructor
465+
raise ValueError(f"Unsupported version: {self.version}")
466+
467+
return self._model_tools
468+
355469
@property
356470
def named_selection(self) -> GRPCNamedSelectionService:
357471
"""
@@ -404,6 +518,32 @@ def parts(self) -> GRPCPartsService:
404518

405519
return self._parts
406520

521+
@property
522+
def patterns(self) -> GRPCPatternsService:
523+
"""
524+
Get the patterns service for the specified version.
525+
526+
Returns
527+
-------
528+
GRPCPatternsService
529+
The patterns service for the specified version.
530+
"""
531+
if not self._patterns:
532+
# Import the appropriate patterns service based on the version
533+
from .v0.patterns import GRPCPatternsServiceV0
534+
from .v1.patterns import GRPCPatternsServiceV1
535+
536+
if self.version == GeometryApiProtos.V0:
537+
self._patterns = GRPCPatternsServiceV0(self.channel)
538+
elif self.version == GeometryApiProtos.V1: # pragma: no cover
539+
# V1 is not implemented yet
540+
self._patterns = GRPCPatternsServiceV1(self.channel)
541+
else:
542+
# This should never happen as the version is set in the constructor
543+
raise ValueError(f"Unsupported version: {self.version}")
544+
545+
return self._patterns
546+
407547
@property
408548
def prepare_tools(self) -> GRPCPrepareToolsService:
409549
"""
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
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 controls service implementation (abstraction layer)."""
23+
24+
from abc import ABC, abstractmethod
25+
26+
import grpc
27+
28+
29+
class GRPCAssemblyControlsService(ABC): # pragma: no cover
30+
"""Assembly controls service for gRPC communication with the Geometry server.
31+
32+
Parameters
33+
----------
34+
channel : grpc.Channel
35+
The gRPC channel to the server.
36+
"""
37+
38+
def __init__(self, channel: grpc.Channel):
39+
"""Initialize the GRPCAssemblyControls class."""
40+
pass
41+
42+
@abstractmethod
43+
def create_align_condition(self, **kwargs) -> dict:
44+
"""Create an align condition between two geometry objects."""
45+
pass
46+
47+
@abstractmethod
48+
def create_tangent_condition(self, **kwargs) -> dict:
49+
"""Create a tangent condition between two geometry objects."""
50+
pass
51+
52+
@abstractmethod
53+
def create_orient_condition(self, **kwargs) -> dict:
54+
"""Create an orient condition between two geometry objects."""
55+
pass
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
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 beams service implementation (abstraction layer)."""
23+
24+
from abc import ABC, abstractmethod
25+
26+
import grpc
27+
28+
29+
class GRPCBeamsService(ABC): # pragma: no cover
30+
"""Beams service for gRPC communication with the Geometry server.
31+
32+
Parameters
33+
----------
34+
channel : grpc.Channel
35+
The gRPC channel to the server.
36+
"""
37+
38+
def __init__(self, channel: grpc.Channel):
39+
"""Initialize the GRPCBeamsService class."""
40+
pass
41+
42+
@abstractmethod
43+
def create_beam_segments(self, **kwargs) -> dict:
44+
"""Create beam segments."""
45+
pass
46+
47+
@abstractmethod
48+
def create_descriptive_beam_segments(self, **kwargs) -> dict:
49+
"""Create descriptive beam segments."""
50+
pass
51+
52+
@abstractmethod
53+
def delete_beam(self, **kwargs) -> dict:
54+
"""Delete a beam."""
55+
pass

src/ansys/geometry/core/_grpc/_services/base/bodies.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,11 @@ def boolean(self, **kwargs) -> dict:
219219
"""Boolean operation."""
220220
pass
221221

222+
@abstractmethod
223+
def split_body(self, **kwargs) -> dict:
224+
"""Split a body."""
225+
pass
226+
222227
@abstractmethod
223228
def create_body_from_loft_profiles_with_guides(self, **kwargs) -> dict:
224229
"""Create a body from loft profiles with guides."""
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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 commands service implementation (abstraction layer)."""
23+
24+
from abc import ABC, abstractmethod
25+
26+
import grpc
27+
28+
29+
class GRPCCommandsService(ABC): # pragma: no cover
30+
"""Commands service for gRPC communication with the Geometry server.
31+
32+
Parameters
33+
----------
34+
channel : grpc.Channel
35+
The gRPC channel to the server.
36+
"""
37+
38+
def __init__(self, channel: grpc.Channel):
39+
"""Initialize the GRPCCommandsService class."""
40+
pass
41+
42+
@abstractmethod
43+
def set_name(self, **kwargs) -> dict:
44+
"""Set the name of an object."""
45+
pass

0 commit comments

Comments
 (0)