Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/changelog.d/2234.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Move geometry commands to versioned architecture
140 changes: 140 additions & 0 deletions src/ansys/geometry/core/_grpc/_services/_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@

from .._version import GeometryApiProtos, set_proto_version
from .base.admin import GRPCAdminService
from .base.assembly_controls import GRPCAssemblyControlsService
from .base.beams import GRPCBeamsService
from .base.bodies import GRPCBodyService
from .base.commands import GRPCCommandsService
from .base.coordinate_systems import GRPCCoordinateSystemService
from .base.dbuapplication import GRPCDbuApplicationService
from .base.designs import GRPCDesignsService
Expand All @@ -33,8 +36,10 @@
from .base.faces import GRPCFacesService
from .base.materials import GRPCMaterialsService
from .base.measurement_tools import GRPCMeasurementToolsService
from .base.model_tools import GRPCModelToolsService
from .base.named_selection import GRPCNamedSelectionService
from .base.parts import GRPCPartsService
from .base.patterns import GRPCPatternsService
from .base.prepare_tools import GRPCPrepareToolsService
from .base.repair_tools import GRPCRepairToolsService

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

# Lazy load all the services
self._admin = None
self._assembly_controls = None
self._beams = None
self._bodies = None
self._commands = None
self._coordinate_systems = None
self._dbu_application = None
self._designs = None
Expand All @@ -87,8 +95,10 @@ def __init__(self, channel: grpc.Channel, version: GeometryApiProtos | str | Non
self._faces = None
self._materials = None
self._measurement_tools = None
self._model_tools = None
self._named_selection = None
self._parts = None
self._patterns = None
self._prepare_tools = None
self._repair_tools = None

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

return self._admin

@property
def assembly_controls(self) -> GRPCAssemblyControlsService:
"""
Get the assembly controls service for the specified version.
Returns
-------
GRPCAssemblyControlsService
The assembly controls service for the specified version.
"""
if not self._assembly_controls:
# Import the appropriate assembly controls service based on the version
from .v0.assembly_controls import GRPCAssemblyControlsServiceV0
from .v1.assembly_controls import GRPCAssemblyControlsServiceV1

if self.version == GeometryApiProtos.V0:
self._assembly_controls = GRPCAssemblyControlsServiceV0(self.channel)
elif self.version == GeometryApiProtos.V1: # pragma: no cover
# V1 is not implemented yet
self._assembly_controls = GRPCAssemblyControlsServiceV1(self.channel)
else: # pragma: no cover
# This should never happen as the version is set in the constructor
raise ValueError(f"Unsupported version: {self.version}")

return self._assembly_controls

@property
def beams(self) -> GRPCBeamsService:
"""
Get the Beams service for the specified version.
Returns
-------
GRPCBeamsService
The Beams service for the specified version.
"""
if not self._beams:
# Import the appropriate Beams service based on the version
from .v0.beams import GRPCBeamsServiceV0
from .v1.beams import GRPCBeamsServiceV1

if self.version == GeometryApiProtos.V0:
self._beams = GRPCBeamsServiceV0(self.channel)
elif self.version == GeometryApiProtos.V1: # pragma: no cover
# V1 is not implemented yet
self._beams = GRPCBeamsServiceV1(self.channel)
else: # pragma: no cover
# This should never happen as the version is set in the constructor
raise ValueError(f"Unsupported version: {self.version}")

return self._beams

@property
def bodies(self) -> GRPCBodyService:
"""
Expand All @@ -144,6 +206,32 @@ def bodies(self) -> GRPCBodyService:

return self._bodies

@property
def commands(self) -> GRPCCommandsService:
"""
Get the commands service for the specified version.
Returns
-------
GRPCCommandsService
The commands service for the specified version.
"""
if not self._commands:
# Import the appropriate commands service based on the version
from .v0.commands import GRPCCommandsServiceV0
from .v1.commands import GRPCCommandsServiceV1

if self.version == GeometryApiProtos.V0:
self._commands = GRPCCommandsServiceV0(self.channel)
elif self.version == GeometryApiProtos.V1: # pragma: no cover
# V1 is not implemented yet
self._commands = GRPCCommandsServiceV1(self.channel)
else: # pragma: no cover
# This should never happen as the version is set in the constructor
raise ValueError(f"Unsupported version: {self.version}")

return self._commands

@property
def coordinate_systems(self) -> GRPCCoordinateSystemService:
"""
Expand Down Expand Up @@ -352,6 +440,32 @@ def measurement_tools(self) -> GRPCMeasurementToolsService:

return self._measurement_tools

@property
def model_tools(self) -> GRPCModelToolsService:
"""
Get the model tools service for the specified version.
Returns
-------
GRPCModelToolsService
The model tools service for the specified version.
"""
if not self._model_tools:
# Import the appropriate model tools service based on the version
from .v0.model_tools import GRPCModelToolsServiceV0
from .v1.model_tools import GRPCModelToolsServiceV1

if self.version == GeometryApiProtos.V0:
self._model_tools = GRPCModelToolsServiceV0(self.channel)
elif self.version == GeometryApiProtos.V1:
# V1 is not implemented yet
self._model_tools = GRPCModelToolsServiceV1(self.channel)
else: # pragma: no cover
# This should never happen as the version is set in the constructor
raise ValueError(f"Unsupported version: {self.version}")

return self._model_tools

@property
def named_selection(self) -> GRPCNamedSelectionService:
"""
Expand Down Expand Up @@ -404,6 +518,32 @@ def parts(self) -> GRPCPartsService:

return self._parts

@property
def patterns(self) -> GRPCPatternsService:
"""
Get the patterns service for the specified version.
Returns
-------
GRPCPatternsService
The patterns service for the specified version.
"""
if not self._patterns:
# Import the appropriate patterns service based on the version
from .v0.patterns import GRPCPatternsServiceV0
from .v1.patterns import GRPCPatternsServiceV1

if self.version == GeometryApiProtos.V0:
self._patterns = GRPCPatternsServiceV0(self.channel)
elif self.version == GeometryApiProtos.V1: # pragma: no cover
# V1 is not implemented yet
self._patterns = GRPCPatternsServiceV1(self.channel)
else:
# This should never happen as the version is set in the constructor
raise ValueError(f"Unsupported version: {self.version}")

return self._patterns

@property
def prepare_tools(self) -> GRPCPrepareToolsService:
"""
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Copyright (C) 2023 - 2025 ANSYS, Inc. and/or its affiliates.
# SPDX-License-Identifier: MIT
#
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
"""Module containing the assembly controls service implementation (abstraction layer)."""

from abc import ABC, abstractmethod

import grpc


class GRPCAssemblyControlsService(ABC): # pragma: no cover
"""Assembly controls service for gRPC communication with the Geometry server.
Parameters
----------
channel : grpc.Channel
The gRPC channel to the server.
"""

def __init__(self, channel: grpc.Channel):
"""Initialize the GRPCAssemblyControls class."""
pass

@abstractmethod
def create_align_condition(self, **kwargs) -> dict:
"""Create an align condition between two geometry objects."""
pass

@abstractmethod
def create_tangent_condition(self, **kwargs) -> dict:
"""Create a tangent condition between two geometry objects."""
pass

@abstractmethod
def create_orient_condition(self, **kwargs) -> dict:
"""Create an orient condition between two geometry objects."""
pass
55 changes: 55 additions & 0 deletions src/ansys/geometry/core/_grpc/_services/base/beams.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Copyright (C) 2023 - 2025 ANSYS, Inc. and/or its affiliates.
# SPDX-License-Identifier: MIT
#
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
"""Module containing the beams service implementation (abstraction layer)."""

from abc import ABC, abstractmethod

import grpc


class GRPCBeamsService(ABC): # pragma: no cover
"""Beams service for gRPC communication with the Geometry server.
Parameters
----------
channel : grpc.Channel
The gRPC channel to the server.
"""

def __init__(self, channel: grpc.Channel):
"""Initialize the GRPCBeamsService class."""
pass

@abstractmethod
def create_beam_segments(self, **kwargs) -> dict:
"""Create beam segments."""
pass

@abstractmethod
def create_descriptive_beam_segments(self, **kwargs) -> dict:
"""Create descriptive beam segments."""
pass

@abstractmethod
def delete_beam(self, **kwargs) -> dict:
"""Delete a beam."""
pass
5 changes: 5 additions & 0 deletions src/ansys/geometry/core/_grpc/_services/base/bodies.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,3 +218,8 @@ def get_tesellation_with_options(self, **kwargs) -> dict:
def boolean(self, **kwargs) -> dict:
"""Boolean operation."""
pass

@abstractmethod
def split_body(self, **kwargs) -> dict:
"""Split a body."""
pass
45 changes: 45 additions & 0 deletions src/ansys/geometry/core/_grpc/_services/base/commands.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Copyright (C) 2023 - 2025 ANSYS, Inc. and/or its affiliates.
# SPDX-License-Identifier: MIT
#
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
"""Module containing the commands service implementation (abstraction layer)."""

from abc import ABC, abstractmethod

import grpc


class GRPCCommandsService(ABC): # pragma: no cover
"""Commands service for gRPC communication with the Geometry server.
Parameters
----------
channel : grpc.Channel
The gRPC channel to the server.
"""

def __init__(self, channel: grpc.Channel):
"""Initialize the GRPCCommandsService class."""
pass

@abstractmethod
def set_name(self, **kwargs) -> dict:
"""Set the name of an object."""
pass
20 changes: 20 additions & 0 deletions src/ansys/geometry/core/_grpc/_services/base/edges.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,23 @@ def get_vertices(self, **kwargs) -> dict:
def get_bounding_box(self, **kwargs) -> dict:
"""Get the bounding box of the edge."""
pass

@abstractmethod
def extrude_edges(self, **kwargs) -> dict:
"""Extrude edges."""
pass

@abstractmethod
def extrude_edges_up_to(self, **kwargs) -> dict:
"""Extrude edges up to a face."""
pass

@abstractmethod
def move_imprint_edges(self, **kwargs) -> dict:
"""Move imprint edges."""
pass

@abstractmethod
def offset_edges(self, **kwargs) -> dict:
"""Offset edges."""
pass
Loading
Loading