Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
f62b2e0
First push of designs v1 implementation
b-matteo Dec 1, 2025
dcb6aad
wip
jacobrkerstetter Dec 1, 2025
3f2be02
improvements to design import/export
jacobrkerstetter Dec 1, 2025
aaba488
Merge branch 'main' of https://github.com/ansys/pyansys-geometry into…
jacobrkerstetter Dec 2, 2025
561e913
fixing small issues in materials and points to get v1 tests running
jacobrkerstetter Dec 2, 2025
43e89d9
Update pyproject.toml
b-matteo Dec 3, 2025
b3f744d
open_file fully working, insert not working
jacobrkerstetter Dec 3, 2025
6e6be14
fixed frame conversion
jacobrkerstetter Dec 4, 2025
f36baf5
minor fixes in command_script
jacobrkerstetter Dec 4, 2025
cba23e2
fixing if statements to run correct versions
jacobrkerstetter Dec 4, 2025
dc431dc
Merge branch 'main' of https://github.com/ansys/pyansys-geometry into…
jacobrkerstetter Dec 4, 2025
320e501
chore: adding changelog file 2443.maintenance.md [dependabot-skip]
pyansys-ci-bot Dec 4, 2025
db9f0d4
chore: auto fixes from pre-commit hooks
pre-commit-ci[bot] Dec 4, 2025
e57731f
adding noqa to long line
jacobrkerstetter Dec 4, 2025
b092ca1
Merge branch 'chore/v1_implementation_of_file_stub' of https://github…
jacobrkerstetter Dec 4, 2025
7710d06
chore: auto fixes from pre-commit hooks
pre-commit-ci[bot] Dec 4, 2025
5cc2dc8
Merge branch 'main' into chore/v1_implementation_of_file_stub
jacobrkerstetter Dec 5, 2025
3a86f7d
removing redef of body facets function
jacobrkerstetter Dec 5, 2025
a4891d5
Merge branch 'chore/v1_implementation_of_file_stub' of https://github…
jacobrkerstetter Dec 5, 2025
1a47b70
Merge branch 'main' into chore/v1_implementation_of_file_stub
jacobrkerstetter Dec 5, 2025
ab86424
Merge branch 'main' of https://github.com/ansys/pyansys-geometry into…
jacobrkerstetter Dec 5, 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/2443.maintenance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Chore: v1 implementation of file/designs stub
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ class GRPCCommandsScriptServiceV1(GRPCCommandsScriptService): # pragma: no cove

@protect_grpc
def __init__(self, channel: grpc.Channel): # noqa: D102
from ansys.api.discovery.v1.commands.script_pb2 import ScriptStub
from ansys.api.discovery.v1.commands.script_pb2_grpc import ScriptStub

self.stub = ScriptStub(channel)

@protect_grpc
def run_script_file(self, **kwargs) -> dict: # noqa: D102
from aansys.api.discovery.v1.commands.script_pb2 import RunScriptFileRequest
from ansys.api.discovery.v1.commands.script_pb2 import RunScriptFileRequest

# Create the request - assumes all inputs are valid and of the proper type
request = RunScriptFileRequest(
Expand All @@ -63,7 +63,7 @@ def run_script_file(self, **kwargs) -> dict: # noqa: D102

# Return the response - formatted as a dictionary
return {
"success": response.success,
"message": response.message,
"success": response.command_response.success,
"message": response.command_response.message,
"values": None if not response.values else dict(response.values),
}
8 changes: 4 additions & 4 deletions src/ansys/geometry/core/_grpc/_services/v1/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
from ansys.geometry.core.errors import protect_grpc

from ..base.components import GRPCComponentsService
from ..base.conversions import from_measurement_to_server_angle
from .conversions import (
build_grpc_id,
from_angle_to_grpc_quantity,
from_grpc_matrix_to_matrix,
from_point3d_to_grpc_point,
from_unit_vector_to_grpc_direction,
Expand Down Expand Up @@ -80,7 +80,7 @@ def create(self, **kwargs) -> dict: # noqa: D102
# Note: response.components is a repeated field, we return the first one
component = response.components[0]
return {
"id": component.id,
"id": component.id.id,
"name": component.name,
"instance_name": component.instance_name,
"template": kwargs["template_id"], # template_id from input
Expand Down Expand Up @@ -132,7 +132,7 @@ def set_placement(self, **kwargs) -> dict: # noqa: D102
translation=translation,
rotation_axis_origin=origin,
rotation_axis_direction=direction,
rotation_angle=from_measurement_to_server_angle(kwargs["rotation_angle"]),
rotation_angle=from_angle_to_grpc_quantity(kwargs["rotation_angle"]),
)
],
)
Expand All @@ -143,7 +143,7 @@ def set_placement(self, **kwargs) -> dict: # noqa: D102
# Return the response - formatted as a dictionary
# Note: response.matrices is a map<string, Matrix>
# Get the matrix for our component ID
matrix_value = response.matrices.get(kwargs["id"].id)
matrix_value = response.matrices.get(kwargs["id"])
return {"matrix": from_grpc_matrix_to_matrix(matrix_value) if matrix_value else None}

@protect_grpc
Expand Down
148 changes: 105 additions & 43 deletions src/ansys/geometry/core/_grpc/_services/v1/conversions.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@

from typing import TYPE_CHECKING

from ansys.api.discovery.v1.commands.file_pb2 import (
ImportOptionDefinition as GRPCImportOptionDefinition,
)
from ansys.api.discovery.v1.commonenums_pb2 import (
BackendType as GRPCBackendType,
FileFormat as GRPCFileFormat,
Expand All @@ -42,6 +45,7 @@
)
from ansys.api.discovery.v1.design.designmessages_pb2 import (
CurveGeometry as GRPCCurveGeometry,
DatumPointEntity as GRPCDesignPoint,
DrivingDimensionEntity as GRPCDrivingDimension,
EdgeTessellation as GRPCEdgeTessellation,
Geometries as GRPCGeometries,
Expand Down Expand Up @@ -89,7 +93,7 @@
from ansys.geometry.core.math.point import Point2D, Point3D
from ansys.geometry.core.math.vector import UnitVector3D
from ansys.geometry.core.misc.measurements import Measurement
from ansys.geometry.core.misc.options import TessellationOptions
from ansys.geometry.core.misc.options import ImportOptionsDefinitions, TessellationOptions
from ansys.geometry.core.parameters.parameter import (
Parameter,
ParameterUpdateStatus,
Expand Down Expand Up @@ -236,6 +240,42 @@ def from_point2d_to_grpc_point(plane: "Plane", point2d: "Point2D") -> GRPCPoint:
)


def from_point3d_to_grpc_design_point(point: "Point3D") -> GRPCDesignPoint:
"""Convert a ``Point3D`` class to a design point gRPC message.

Parameters
----------
point : Point3D
Source point data.

Returns
-------
GRPCDesignPoint
Geometry service gRPC design point message. The unit is meters.
"""
return GRPCDesignPoint(
position=from_point3d_to_grpc_point(point),
)


def from_point3d_to_grpc_design_point(point: "Point3D") -> GRPCDesignPoint:
"""Convert a ``Point3D`` class to a design point gRPC message.

Parameters
----------
point : Point3D
Source point data.

Returns
-------
GRPCDesignPoint
Geometry service gRPC design point message. The unit is meters.
"""
return GRPCDesignPoint(
position=from_point3d_to_grpc_point(point),
)


def from_unit_vector_to_grpc_direction(unit_vector: "UnitVector3D") -> GRPCDirection:
"""Convert a ``UnitVector3D`` class to a unit vector gRPC message.

Expand Down Expand Up @@ -375,9 +415,9 @@ def from_grpc_frame_to_frame(frame: GRPCFrame) -> "Frame":
return Frame(
Point3D(
input=[
frame.origin.x,
frame.origin.y,
frame.origin.z,
frame.origin.x.value_in_geometry_units,
frame.origin.y.value_in_geometry_units,
frame.origin.z.value_in_geometry_units,
],
unit=DEFAULT_UNITS.SERVER_LENGTH,
),
Expand Down Expand Up @@ -1270,6 +1310,45 @@ def from_grpc_update_status_to_parameter_update_status(
return status_mapping.get(update_status, ParameterUpdateStatus.UNKNOWN)


def from_design_file_format_to_grpc_file_export_format(
design_file_format: "DesignFileFormat",
) -> GRPCFileFormat:
"""Convert from a DesignFileFormat object to a gRPC FileExportFormat one.

Parameters
----------
design_file_format : DesignFileFormat
The file format desired

Returns
-------
GRPCFileExportFormat
Converted gRPC File format
"""
from ansys.geometry.core.designer.design import DesignFileFormat

if design_file_format == DesignFileFormat.SCDOCX:
return GRPCFileFormat.FILEFORMAT_SCDOCX
elif design_file_format == DesignFileFormat.PARASOLID_TEXT:
return GRPCFileFormat.FILEFORMAT_PARASOLID_TEXT
elif design_file_format == DesignFileFormat.PARASOLID_BIN:
return GRPCFileFormat.FILEFORMAT_PARASOLID_BINARY
elif design_file_format == DesignFileFormat.FMD:
return GRPCFileFormat.FILEFORMAT_FMD
elif design_file_format == DesignFileFormat.STEP:
return GRPCFileFormat.FILEFORMAT_STEP
elif design_file_format == DesignFileFormat.IGES:
return GRPCFileFormat.FILEFORMAT_IGES
elif design_file_format == DesignFileFormat.PMDB:
return GRPCFileFormat.FILEFORMAT_PMDB
elif design_file_format == DesignFileFormat.STRIDE:
return GRPCFileFormat.FILEFORMAT_STRIDE
elif design_file_format == DesignFileFormat.DISCO:
return GRPCFileFormat.FILEFORMAT_DISCO
else:
return None


def from_material_to_grpc_material(
material: "Material",
) -> GRPCMaterial:
Expand Down Expand Up @@ -1414,6 +1493,28 @@ def from_parameter_to_grpc_quantity(value: float) -> GRPCQuantity:
return GRPCQuantity(value_in_geometry_units=value)


def from_import_options_definitions_to_grpc_import_options_definition(
import_options_definitions: "ImportOptionsDefinitions",
) -> GRPCImportOptionDefinition:
"""Convert an ``ImportOptionsDefinitions`` to import options definition gRPC message.

Parameters
----------
import_options_definitions : ImportOptionsDefinitions
Definition of the import options.

Returns
-------
GRPCImportOptionDefinition
Geometry service gRPC import options definition message.
"""
definitions = {}
for key, definition in import_options_definitions.to_dict().items():
definitions[key] = GRPCImportOptionDefinition(string_option=str(definition))

return definitions


def _nurbs_curves_compatibility(backend_version: "semver.Version", grpc_geometries: GRPCGeometries):
"""Check if the backend version is compatible with NURBS curves in sketches.

Expand Down Expand Up @@ -1481,45 +1582,6 @@ def from_enclosure_options_to_grpc_enclosure_options(
)


def from_design_file_format_to_grpc_file_format(
design_file_format: "DesignFileFormat",
) -> GRPCFileFormat:
"""Convert from a ``DesignFileFormat`` object to a gRPC file format.

Parameters
----------
design_file_format : DesignFileFormat
The file format desired

Returns
-------
GRPCFileFormat
Converted gRPC FileFormat.
"""
from ansys.geometry.core.designer.design import DesignFileFormat

if design_file_format == DesignFileFormat.SCDOCX:
return GRPCFileFormat.FILEFORMAT_SCDOCX
elif design_file_format == DesignFileFormat.PARASOLID_TEXT:
return GRPCFileFormat.FILEFORMAT_PARASOLID_TEXT
elif design_file_format == DesignFileFormat.PARASOLID_BIN:
return GRPCFileFormat.FILEFORMAT_PARASOLID_BINARY
elif design_file_format == DesignFileFormat.FMD:
return GRPCFileFormat.FILEFORMAT_FMD
elif design_file_format == DesignFileFormat.STEP:
return GRPCFileFormat.FILEFORMAT_STEP
elif design_file_format == DesignFileFormat.IGES:
return GRPCFileFormat.FILEFORMAT_IGES
elif design_file_format == DesignFileFormat.PMDB:
return GRPCFileFormat.FILEFORMAT_PMDB
elif design_file_format == DesignFileFormat.STRIDE:
return GRPCFileFormat.FILEFORMAT_STRIDE
elif design_file_format == DesignFileFormat.DISCO:
return GRPCFileFormat.FILEFORMAT_DISCO
else:
return None


def serialize_tracked_command_response(response: GRPCTrackedCommandResponse) -> dict:
"""Serialize a TrackedCommandResponse object into a dictionary.

Expand Down
Loading
Loading