Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
97eb31a
chore: update CHANGELOG for v0.9.0 (#1753)
pyansys-ci-bot Feb 17, 2025
1547839
Merge branch 'main' of https://github.com/ansys/pyansys-geometry
smereu Mar 10, 2025
5a48878
Merge branch 'main' of https://github.com/ansys/pyansys-geometry
smereu Mar 27, 2025
4109456
Merge branch 'main' of https://github.com/ansys/pyansys-geometry
smereu Apr 8, 2025
e00316b
Merge branch 'main' of https://github.com/ansys/pyansys-geometry
smereu May 20, 2025
1afa37a
Merge branch 'main' of https://github.com/ansys/pyansys-geometry
smereu Jun 11, 2025
7c595bb
Merge branch 'main' of https://github.com/ansys/pyansys-geometry
smereu Jun 24, 2025
6a23076
Merge branch 'main' of https://github.com/ansys/pyansys-geometry
smereu Jul 7, 2025
62ca792
Merge branch 'main' of https://github.com/ansys/pyansys-geometry
smereu Jul 9, 2025
40c19c1
Merge branch 'main' of https://github.com/ansys/pyansys-geometry
smereu Jul 28, 2025
40a13e2
Merge branch 'main' of https://github.com/ansys/pyansys-geometry
smereu Sep 3, 2025
269ec5b
Merge branch 'main' of https://github.com/ansys/pyansys-geometry
smereu Sep 22, 2025
6217f4a
Merge branch 'main' of https://github.com/ansys/pyansys-geometry
smereu Sep 24, 2025
7a728c4
Merge branch 'main' of https://github.com/ansys/pyansys-geometry
smereu Sep 25, 2025
6c462de
Merge branch 'main' of https://github.com/ansys/pyansys-geometry
smereu Sep 30, 2025
3611a99
Merge branch 'main' of https://github.com/ansys/pyansys-geometry
smereu Oct 8, 2025
c5a4e86
Merge branch 'main' of https://github.com/ansys/pyansys-geometry
smereu Oct 11, 2025
ecd7567
Merge branch 'main' of https://github.com/ansys/pyansys-geometry
smereu Oct 13, 2025
8b628a2
Merge branch 'main' of https://github.com/ansys/pyansys-geometry
smereu Nov 18, 2025
f55daa8
Merge branch 'main' of https://github.com/ansys/pyansys-geometry
smereu Nov 21, 2025
38324c1
Merge branch 'main' of https://github.com/ansys/pyansys-geometry
smereu Nov 24, 2025
18f6686
Merge branch 'main' of https://github.com/ansys/pyansys-geometry
smereu Nov 25, 2025
37d91fa
prepare_tools v1 implementation
smereu Nov 25, 2025
c81fdae
chore: auto fixes from pre-commit hooks
pre-commit-ci[bot] Nov 25, 2025
c076097
chore: adding changelog file 2417.maintenance.md [dependabot-skip]
pyansys-ci-bot Nov 25, 2025
2dfec80
clean-up of response
smereu Nov 26, 2025
207d448
Merge branch 'ci/prepare_tools_to_v1' of https://github.com/ansys/pya…
smereu Nov 26, 2025
336d1b9
Delete doc/changelog.d/1753.maintenance.md
RobPasMue Nov 26, 2025
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/2417.maintenance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Prepare tools to v1
39 changes: 39 additions & 0 deletions src/ansys/geometry/core/_grpc/_services/v1/conversions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1401,3 +1401,42 @@ def serialize_entity_identifier(entity):
for entity in getattr(response, "deleted_bodies", [])
],
}


def get_standard_tracker_response(response) -> dict:
"""Get a standard dictionary response from a TrackerCommandResponse gRPC object.

Parameters
----------
response : TrackerCommandResponse
The gRPC TrackerCommandResponse object.

Returns
-------
dict
A dictionary representing the standard tracker response
"""
return {
"success": response.command_response.success,
"tracker_response": serialize_tracker_command_response(response.tracked_changes),
}


def get_tracker_response_with_created_bodies(response) -> dict:
"""Get a dictionary response from a TrackerCommandResponse gRPC object including created bodies.

Parameters
----------
response : TrackerCommandResponse
The gRPC TrackerCommandResponse object.

Returns
-------
dict
A dictionary representing the tracker response with created bodies.
"""
serialized_response = get_standard_tracker_response(response)
serialized_response["created_bodies"] = serialized_response["tracker_response"].get(
"created_bodies", []
)
return serialized_response
299 changes: 284 additions & 15 deletions src/ansys/geometry/core/_grpc/_services/v1/prepare_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,15 @@

from ansys.geometry.core.errors import protect_grpc

from ..base.conversions import from_measurement_to_server_length
from ..base.prepare_tools import GRPCPrepareToolsService
from .conversions import (
build_grpc_id,
from_enclosure_options_to_grpc_enclosure_options,
get_standard_tracker_response,
get_tracker_response_with_created_bodies,
serialize_tracker_command_response,
)


class GRPCPrepareToolsServiceV1(GRPCPrepareToolsService): # pragma: no cover
Expand All @@ -43,54 +51,315 @@ class GRPCPrepareToolsServiceV1(GRPCPrepareToolsService): # pragma: no cover

@protect_grpc
def __init__(self, channel: grpc.Channel): # noqa: D102
from ansys.api.geometry.v1.preparetools_pb2_grpc import PrepareToolsStub
from ansys.api.discovery.v1.operations.prepare_pb2_grpc import PrepareStub

self.stub = PrepareToolsStub(channel)
self.stub = PrepareStub(channel)

@protect_grpc
def extract_volume_from_faces(self, **kwargs) -> dict: # noqa: D102
raise NotImplementedError
from ansys.api.discovery.v1.operations.prepare_pb2 import ExtractVolumeFromFacesRequest

# Create the request - assumes all inputs are valid and of the proper type
request = ExtractVolumeFromFacesRequest(
sealing_face_ids=[build_grpc_id(face) for face in kwargs["sealing_faces"]],
inside_face_ids=[build_grpc_id(face) for face in kwargs["inside_faces"]],
)

# Call the gRPC service
response = self.stub.ExtractVolumeFromFaces(request)

# Return the response - formatted as a dictionary
return get_tracker_response_with_created_bodies(response)

@protect_grpc
def extract_volume_from_edge_loops(self, **kwargs) -> dict: # noqa: D102
raise NotImplementedError
from ansys.api.discovery.v1.operations.prepare_pb2 import ExtractVolumeFromEdgeLoopsRequest

# Create the request - assumes all inputs are valid and of the proper type
request = ExtractVolumeFromEdgeLoopsRequest(
sealing_edge_ids=[build_grpc_id(edge) for edge in kwargs["sealing_edges"]],
inside_face_ids=[build_grpc_id(face) for face in kwargs["inside_faces"]],
)

# Call the gRPC service
response = self.stub.ExtractVolumeFromEdgeLoops(request)

# Return the response - formatted as a dictionary
return get_tracker_response_with_created_bodies(response)

@protect_grpc
def remove_rounds(self, **kwargs) -> dict: # noqa: D102
raise NotImplementedError
from ansys.api.discovery.v1.operations.prepare_pb2 import RemoveRoundsRequest
from google.protobuf.wrappers_pb2 import BoolValue

# Create the request - assumes all inputs are valid and of the proper type
request = RemoveRoundsRequest(
selection_ids=[build_grpc_id(round) for round in kwargs["rounds"]],
auto_shrink=BoolValue(value=kwargs["auto_shrink"]),
)

# Call the gRPC service
response = self.stub.RemoveRounds(request)

# Return the response - formatted as a dictionary
return get_standard_tracker_response(response)

@protect_grpc
def share_topology(self, **kwargs) -> dict: # noqa: D102
raise NotImplementedError
from ansys.api.discovery.v1.operations.prepare_pb2 import ShareTopologyRequest
from google.protobuf.wrappers_pb2 import BoolValue, DoubleValue

# Create the request - assumes all inputs are valid and of the proper type
request = ShareTopologyRequest(
selection_ids=[build_grpc_id(body) for body in kwargs["bodies"]],
tolerance=DoubleValue(value=from_measurement_to_server_length(kwargs["tolerance"])),
preserve_instances=BoolValue(value=kwargs["preserve_instances"]),
)

# Call the gRPC service
response = self.stub.ShareTopology(request)

# Return the response - formatted as a dictionary
return get_standard_tracker_response(response)

@protect_grpc
def enhanced_share_topology(self, **kwargs) -> dict: # noqa: D102
raise NotImplementedError
from ansys.api.discovery.v1.operations.prepare_pb2 import ShareTopologyRequest
from google.protobuf.wrappers_pb2 import BoolValue, DoubleValue

# Create the request - assumes all inputs are valid and of the proper type
request = ShareTopologyRequest(
selection_ids=[build_grpc_id(body) for body in kwargs["bodies"]],
tolerance=DoubleValue(value=from_measurement_to_server_length(kwargs["tolerance"])),
preserve_instances=BoolValue(value=kwargs["preserve_instances"]),
)

# Call the gRPC service
response = self.stub.EnhancedShareTopology(request)

# Return the response - formatted as a dictionary
return {
"success": response.success,
"found": response.found,
"repaired": response.repaired,
"tracker_response": serialize_tracker_command_response(response.tracked_changes),
"created_bodies_monikers": [
created_body.id
for created_body in response.tracked_changes.get("created_bodies", [])
],
"modified_bodies_monikers": [
modified_body.id
for modified_body in response.tracked_changes.get("modified_bodies", [])
],
}

@protect_grpc
def find_logos(self, **kwargs) -> dict: # noqa: D102
raise NotImplementedError
from ansys.api.discovery.v1.operations.prepare_pb2 import FindLogoOptions, FindLogosRequest

# Check height objects
min_height = (
from_measurement_to_server_length(kwargs["min_height"])
if kwargs["min_height"] is not None
else None
)
max_height = (
from_measurement_to_server_length(kwargs["max_height"])
if kwargs["max_height"] is not None
else None
)

# Create the request - assumes all inputs are valid and of the proper type
request = FindLogosRequest(
body_ids=[build_grpc_id(body) for body in kwargs["bodies"]],
options=FindLogoOptions(
min_height=min_height,
max_height=max_height,
),
)

# Call the gRPC service
response = self.stub.FindLogos(request)

# Return the response - formatted as a dictionary
return {
"id": response.id,
"face_ids": [face.id for face in response.logo_faces],
}

@protect_grpc
def find_and_remove_logos(self, **kwargs) -> dict: # noqa: D102
raise NotImplementedError
from ansys.api.discovery.v1.operations.prepare_pb2 import FindLogoOptions, FindLogosRequest

# Check height objects
min_height = (
from_measurement_to_server_length(kwargs["min_height"])
if kwargs["min_height"] is not None
else None
)
max_height = (
from_measurement_to_server_length(kwargs["max_height"])
if kwargs["max_height"] is not None
else None
)

# Create the request - assumes all inputs are valid and of the proper type
request = FindLogosRequest(
body_ids=[build_grpc_id(body) for body in kwargs["bodies"]],
options=FindLogoOptions(
min_height=min_height,
max_height=max_height,
),
)

# Call the gRPC service
response = self.stub.FindAndRemoveLogos(request)

# Return the response - formatted as a dictionary
return get_standard_tracker_response(response)

@protect_grpc
def remove_logo(self, **kwargs) -> dict: # noqa: D102
raise NotImplementedError
def remove_logo(self, **kwargs): # noqa: D102
from ansys.api.discovery.v1.operations.prepare_pb2 import RemoveLogoRequest

# Create the request - assumes all inputs are valid and of the proper type
request = RemoveLogoRequest(
face_ids=[build_grpc_id(id) for id in kwargs["face_ids"]],
)

# Call the gRPC service
response = self.stub.RemoveLogo(request)

# Return the response - formatted as a dictionary
return get_standard_tracker_response(response)

@protect_grpc
def detect_helixes(self, **kwargs) -> dict: # noqa: D102
raise NotImplementedError
from ansys.api.discovery.v1.operations.prepare_pb2 import (
FindHelixesOptions,
)

from ansys.geometry.core.shapes.parameterization import Interval

from ..base.conversions import (
from_measurement_to_server_length,
to_distance,
)
from .conversions import (
from_grpc_curve_to_curve,
from_grpc_point_to_point3d,
)

# Create the request - assumes all inputs are valid and of the proper type
request = FindHelixesOptions(
body_ids=[build_grpc_id(body) for body in kwargs["bodies"]],
options=FindHelixesOptions(
min_radius=from_measurement_to_server_length(kwargs["min_radius"]),
max_radius=from_measurement_to_server_length(kwargs["max_radius"]),
fit_radius_error=from_measurement_to_server_length(kwargs["fit_radius_error"]),
),
)

# Call the gRPC service
response = self.stub.FindHelixes(request)

# If no helixes, return empty dictionary
if len(response.helixes) == 0:
return {"helixes": []}

# Return the response - formatted as a dictionary
return {
"helixes": [
{
"trimmed_curve": {
"geometry": from_grpc_curve_to_curve(helix.trimmed_curve.curve),
"start": from_grpc_point_to_point3d(helix.trimmed_curve.start),
"end": from_grpc_point_to_point3d(helix.trimmed_curve.end),
"interval": Interval(
helix.trimmed_curve.interval_start, helix.trimmed_curve.interval_end
),
"length": to_distance(helix.trimmed_curve.length).value,
},
"edges": [
{
"id": edge.id,
"parent_id": edge.parent.id,
"curve_type": edge.curve_type,
"is_reversed": edge.is_reversed,
}
for edge in helix.edges
],
}
for helix in response.helixes
]
}

@protect_grpc
def create_box_enclosure(self, **kwargs) -> dict: # noqa: D102
raise NotImplementedError
from ansys.api.discovery.v1.operations.prepare_pb2 import CreateEnclosureBoxRequest

grpc_enclosure_options = from_enclosure_options_to_grpc_enclosure_options(
kwargs["enclosure_options"]
)

# Create the request - assumes all inputs are valid and of the proper type
request = CreateEnclosureBoxRequest(
body_ids=[build_grpc_id(body.id) for body in kwargs["bodies"]],
x_low=from_measurement_to_server_length(kwargs["x_low"]),
x_high=from_measurement_to_server_length(kwargs["x_high"]),
y_low=from_measurement_to_server_length(kwargs["y_low"]),
y_high=from_measurement_to_server_length(kwargs["y_high"]),
z_low=from_measurement_to_server_length(kwargs["z_low"]),
z_high=from_measurement_to_server_length(kwargs["z_high"]),
enclosure_options=grpc_enclosure_options,
)

# Call the gRPC service
response = self.stub.CreateEnclosureBox(request)

# Return the response - formatted as a dictionary
return get_tracker_response_with_created_bodies(response)

@protect_grpc
def create_cylinder_enclosure(self, **kwargs) -> dict: # noqa: D102
raise NotImplementedError
from ansys.api.discovery.v1.operations.prepare_pb2 import CreateEnclosureCylinderRequest

grpc_enclosure_options = from_enclosure_options_to_grpc_enclosure_options(
kwargs["enclosure_options"]
)

# Create the request - assumes all inputs are valid and of the proper type
request = CreateEnclosureCylinderRequest(
body_ids=[build_grpc_id(body.id) for body in kwargs["bodies"]],
axial_distance_low=from_measurement_to_server_length(kwargs["axial_distance_low"]),
axial_distance_high=from_measurement_to_server_length(kwargs["axial_distance_high"]),
radial_distance=from_measurement_to_server_length(kwargs["radial_distance"]),
enclosure_options=grpc_enclosure_options,
)

# Call the gRPC service
response = self.stub.CreateEnclosureCylinder(request)

# Return the response - formatted as a dictionary
return get_tracker_response_with_created_bodies(response)

@protect_grpc
def create_sphere_enclosure(self, **kwargs) -> dict: # noqa: D102
raise NotImplementedError
from ansys.api.discovery.v1.operations.prepare_pb2 import CreateEnclosureSphereRequest

grpc_enclosure_options = from_enclosure_options_to_grpc_enclosure_options(
kwargs["enclosure_options"]
)

# Create the request - assumes all inputs are valid and of the proper type
request = CreateEnclosureSphereRequest(
body_ids=[build_grpc_id(body.id) for body in kwargs["bodies"]],
radial_distance=from_measurement_to_server_length(kwargs["radial_distance"]),
enclosure_options=grpc_enclosure_options,
)

# Call the gRPC service
response = self.stub.CreateEnclosureSphere(request)

# Return the response - formatted as a dictionary
return get_tracker_response_with_created_bodies(response)
Loading
Loading