Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 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
a34e91d
Merge branch 'main' of https://github.com/ansys/pyansys-geometry
smereu Oct 15, 2025
f1511b3
complete migration of design class to mediator pattern for version ha…
smereu Oct 15, 2025
3d5eb60
chore: auto fixes from pre-commit hooks
pre-commit-ci[bot] Oct 15, 2025
d8c95c2
chore: adding changelog file 2323.added.md [dependabot-skip]
pyansys-ci-bot Oct 15, 2025
5f421f2
code style change from pre-commit
smereu Oct 15, 2025
986bc9d
Merge branch 'feat/finalize-version-for-design-class' of https://gith…
smereu Oct 15, 2025
dfb6131
fixes from pre-commit
smereu Oct 15, 2025
cb7d000
remove spurious file additions
smereu Oct 15, 2025
c8b99ff
chore: adding changelog file 2323.added.md [dependabot-skip]
pyansys-ci-bot Oct 15, 2025
4993a6f
second pass at removing version from design class
smereu Oct 16, 2025
d308e3f
Merge branch 'feat/finalize-version-for-design-class' of https://gith…
smereu Oct 16, 2025
3729232
chore: auto fixes from pre-commit hooks
pre-commit-ci[bot] Oct 16, 2025
dc5aa45
reformat file
smereu Oct 16, 2025
9bf24ea
Merge branch 'feat/finalize-version-for-design-class' of https://gith…
smereu Oct 16, 2025
7844654
Merge branch 'main' into feat/finalize-version-for-design-class
RobPasMue Oct 16, 2025
e470260
fix thickness for design Api
smereu Oct 16, 2025
d9e1b04
Merge branch 'feat/finalize-version-for-design-class' of https://gith…
smereu Oct 17, 2025
550a901
Merge branch 'main' into feat/finalize-version-for-design-class
RobPasMue Oct 17, 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/2323.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Finalize version handling for design class
10 changes: 10 additions & 0 deletions src/ansys/geometry/core/_grpc/_services/base/beams.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,13 @@ def create_descriptive_beam_segments(self, **kwargs) -> dict:
def delete_beam(self, **kwargs) -> dict:
"""Delete a beam."""
pass

@abstractmethod
def delete_beam_profile(self, **kwargs) -> dict:
"""Remove a beam profile on the active geometry server instance."""
pass

@abstractmethod
def create_beam_circular_profile(self, **kwargs) -> dict:
"""Add a new beam circular profile under the design for creating beams."""
pass
5 changes: 5 additions & 0 deletions src/ansys/geometry/core/_grpc/_services/base/designs.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,8 @@ def upload_file_stream(self, **kwargs) -> dict:
def stream_design_tessellation(self, **kwargs) -> dict:
"""Stream the tessellation of a design."""
pass

@abstractmethod
def download_file(self, **kwargs) -> dict:
"""Download the design from the server."""
pass
39 changes: 34 additions & 5 deletions src/ansys/geometry/core/_grpc/_services/v0/beams.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,20 @@
# SOFTWARE.
"""Module containing the beams service implementation for v0."""

from ansys.api.geometry.v0.commands_pb2 import CreateBeamCircularProfileRequest
import grpc

from ansys.geometry.core.errors import protect_grpc

from ..base.beams import GRPCBeamsService
from ..base.conversions import to_distance
from ..base.conversions import from_measurement_to_server_length, to_distance
from .conversions import (
build_grpc_id,
from_grpc_curve_to_curve,
from_grpc_frame_to_frame,
from_grpc_material_to_material,
from_grpc_point_to_point3d,
from_plane_to_grpc_plane,
from_point3d_to_grpc_point,
)

Expand All @@ -54,7 +56,7 @@ class GRPCBeamsServiceV0(GRPCBeamsService):
def __init__(self, channel: grpc.Channel): # noqa: D102
from ansys.api.geometry.v0.commands_pb2_grpc import CommandsStub

self.stub = CommandsStub(channel)
self.commands_stub = CommandsStub(channel)

@protect_grpc
def create_beam_segments(self, **kwargs) -> dict: # noqa: D102
Expand All @@ -79,7 +81,7 @@ def create_beam_segments(self, **kwargs) -> dict: # noqa: D102
)

# Call the gRPC service
resp = self.stub.CreateBeamSegments(request)
resp = self.commands_stub.CreateBeamSegments(request)

# Return the response - formatted as a dictionary
return {
Expand Down Expand Up @@ -111,7 +113,7 @@ def create_descriptive_beam_segments(self, **kwargs) -> dict: # noqa: D102
)

# Call the gRPC service
resp = self.stub.CreateDescriptiveBeamSegments(request)
resp = self.commands_stub.CreateDescriptiveBeamSegments(request)

# Return the response - formatted as a dictionary
return {
Expand Down Expand Up @@ -174,7 +176,34 @@ def delete_beam(self, **kwargs) -> dict: # noqa: D102
request = build_grpc_id(kwargs["beam_id"])

# Call the gRPC service
_ = self.stub.DeleteBeam(request)
_ = self.commands_stub.DeleteBeam(request)

# Return the response - formatted as a dictionary
return {}

@protect_grpc
def delete_beam_profile(self, **kwargs) -> dict: # noqa: D102
# Create the request - assumes all inputs are valid and of the proper type
request = build_grpc_id(id=kwargs["id"])

# Call the gRPC service
_ = self.commands_stub.DeleteBeamProfile(request)

# Return the response - formatted as a dictionary
return {}

@protect_grpc
def create_beam_circular_profile(self, **kwargs) -> dict: # noqa: D102
# Create the request - assumes all inputs are valid and of the proper type
request = CreateBeamCircularProfileRequest(
origin=from_point3d_to_grpc_point(kwargs["center"]),
radius=from_measurement_to_server_length(kwargs["radius"]),
plane=from_plane_to_grpc_plane(kwargs["plane"]),
name=kwargs["name"],
)

# Call the gRPC service
response = self.commands_stub.CreateBeamCircularProfile(request)

# Return the response - formatted as a dictionary
return {"id": response.id}
9 changes: 9 additions & 0 deletions src/ansys/geometry/core/_grpc/_services/v0/designs.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
# SOFTWARE.
"""Module containing the designs service implementation for v0."""

from google.protobuf.empty_pb2 import Empty
import grpc

from ansys.geometry.core.errors import protect_grpc
Expand Down Expand Up @@ -481,3 +482,11 @@ def stream_design_tessellation(self, **kwargs) -> dict: # noqa: D102
return {
"tessellation": tess_map,
}

@protect_grpc
def download_file(self, **kwargs) -> dict: # noqa: D102
# Call the gRPC service
response = self.commands_stub.DownloadFile(Empty())

# Return the response - formatted as a dictionary
return {"data": response.data}
8 changes: 8 additions & 0 deletions src/ansys/geometry/core/_grpc/_services/v1/beams.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,11 @@ def create_descriptive_beam_segments(self, **kwargs) -> dict: # noqa: D102
@protect_grpc
def delete_beam(self, **kwargs) -> dict: # noqa: D102
raise NotImplementedError

@protect_grpc
def delete_beam_profile(self, **kwargs) -> dict: # noqa: D102
raise NotImplementedError

@protect_grpc
def create_beam_circular_profile(self, **kwargs) -> dict: # noqa: D102
raise NotImplementedError
4 changes: 4 additions & 0 deletions src/ansys/geometry/core/_grpc/_services/v1/designs.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,7 @@ def upload_file_stream(self, **kwargs) -> dict: # noqa: D102
@protect_grpc
def stream_design_tessellation(self, **kwargs) -> dict: # noqa: D102
raise NotImplementedError

@protect_grpc
def download_file(self, **kwargs) -> dict: # noqa: D102
raise NotImplementedError
53 changes: 20 additions & 33 deletions src/ansys/geometry/core/designer/design.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,12 @@
from pathlib import Path
from typing import Union

from ansys.api.dbu.v0.dbumodels_pb2 import EntityIdentifier
from ansys.api.geometry.v0.commands_pb2 import (
AssignMidSurfaceOffsetTypeRequest,
AssignMidSurfaceThicknessRequest,
CreateBeamCircularProfileRequest,
)
from ansys.api.geometry.v0.commands_pb2_grpc import CommandsStub
from beartype import beartype as check_input_types
from google.protobuf.empty_pb2 import Empty
import numpy as np
from pint import Quantity, UndefinedUnitError

from ansys.geometry.core.connection.backend import BackendType
from ansys.geometry.core.connection.conversions import (
plane_to_grpc_plane,
point3d_to_grpc_point,
)
from ansys.geometry.core.designer.beam import (
Beam,
BeamCircularProfile,
Expand Down Expand Up @@ -70,13 +59,13 @@
ensure_design_is_active,
min_backend_version,
)
from ansys.geometry.core.misc.measurements import DEFAULT_UNITS, Distance
from ansys.geometry.core.misc.measurements import Distance
from ansys.geometry.core.misc.options import ImportOptions, TessellationOptions
from ansys.geometry.core.modeler import Modeler
from ansys.geometry.core.parameters.parameter import Parameter, ParameterUpdateStatus
from ansys.geometry.core.shapes.curves.trimmed_curve import TrimmedCurve
from ansys.geometry.core.shapes.parameterization import Interval, ParamUV
from ansys.geometry.core.typing import RealSequence
from ansys.geometry.core.typing import Real, RealSequence


@unique
Expand Down Expand Up @@ -330,9 +319,9 @@ def __export_and_download_legacy(self, format: DesignFileFormat) -> bytes:
# Process response
self._grpc_client.log.debug(f"Requesting design download in {format} format.")
if format is DesignFileFormat.SCDOCX:
response = self._commands_stub.DownloadFile(Empty())
response = self._grpc_client.services.designs.download_file()
received_bytes = bytes()
received_bytes += response.data
received_bytes += response.get("data")
elif format in [
DesignFileFormat.PARASOLID_TEXT,
DesignFileFormat.PARASOLID_BIN,
Expand Down Expand Up @@ -818,17 +807,16 @@ def add_beam_circular_profile(
if not dir_x.is_perpendicular_to(dir_y):
raise ValueError("Direction X and direction Y must be perpendicular.")

request = CreateBeamCircularProfileRequest(
origin=point3d_to_grpc_point(center),
radius=radius.value.m_as(DEFAULT_UNITS.SERVER_LENGTH),
plane=plane_to_grpc_plane(Plane(center, dir_x, dir_y)),
self._grpc_client.log.debug(f"Creating a beam circular profile on {self.id}...")

response = self._grpc_client._services.beams.create_beam_circular_profile(
center=center,
radius=radius,
plane=Plane(center, dir_x, dir_y),
name=name,
)

self._grpc_client.log.debug(f"Creating a beam circular profile on {self.id}...")

response = self._commands_stub.CreateBeamCircularProfile(request)
profile = BeamCircularProfile(response.id, name, radius, center, dir_x, dir_y)
profile = BeamCircularProfile(response.get("id"), name, radius, center, dir_x, dir_y)
self._beam_profiles[profile.name] = profile

self._grpc_client.log.debug(
Expand Down Expand Up @@ -885,7 +873,9 @@ def set_parameter(self, dimension: Parameter) -> ParameterUpdateStatus:
@protect_grpc
@check_input_types
@ensure_design_is_active
def add_midsurface_thickness(self, thickness: Quantity, bodies: list[Body]) -> None:
def add_midsurface_thickness(
self, thickness: Distance | Quantity | Real, bodies: list[Body]
) -> None:
"""Add a mid-surface thickness to a list of bodies.

Parameters
Expand All @@ -899,6 +889,7 @@ def add_midsurface_thickness(self, thickness: Quantity, bodies: list[Body]) -> N
-----
Only surface bodies will be eligible for mid-surface thickness assignment.
"""
thickness = thickness if isinstance(thickness, Distance) else Distance(thickness)
# Store only assignable ids
ids: list[str] = []
ids_bodies: list[Body] = []
Expand All @@ -912,15 +903,11 @@ def add_midsurface_thickness(self, thickness: Quantity, bodies: list[Body]) -> N
)

# Assign mid-surface thickness
self._commands_stub.AssignMidSurfaceThickness(
AssignMidSurfaceThicknessRequest(
bodies_or_faces=ids, thickness=thickness.m_as(DEFAULT_UNITS.SERVER_LENGTH)
)
)
self._grpc_client._services.bodies.assign_midsurface_thickness(ids=ids, thickness=thickness)

# Once the assignment has gone fine, store the values
for body in ids_bodies:
body._surface_thickness = thickness
body._surface_thickness = thickness.value

@protect_grpc
@check_input_types
Expand Down Expand Up @@ -952,8 +939,8 @@ def add_midsurface_offset(self, offset_type: MidSurfaceOffsetType, bodies: list[
)

# Assign mid-surface offset type
self._commands_stub.AssignMidSurfaceOffsetType(
AssignMidSurfaceOffsetTypeRequest(bodies_or_faces=ids, offset_type=offset_type.value)
self._grpc_client._services.bodies.assign_midsurface_offset(
ids=ids, offset_type=offset_type
)

# Once the assignment has gone fine, store the values
Expand All @@ -976,7 +963,7 @@ def delete_beam_profile(self, beam_profile: BeamProfile | str) -> None:
removal_obj = self._beam_profiles.get(removal_name, None)

if removal_obj:
self._commands_stub.DeleteBeamProfile(EntityIdentifier(id=removal_obj.id))
self._grpc_client._services.beams.delete_beam_profile(id=removal_obj.id)
self._beam_profiles.pop(removal_name)
self._grpc_client.log.debug(f"Beam profile {removal_name} successfully deleted.")
else:
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/test_design.py
Original file line number Diff line number Diff line change
Expand Up @@ -1695,7 +1695,7 @@ def test_midsurface_properties(modeler: Modeler):
assert "Exists : True" in surf_repr
assert "Parent component : MidSurfaceProperties" in surf_repr
assert "Surface body : True" in surf_repr
assert "Surface thickness : 10 millimeter" in surf_repr
assert "Surface thickness : 10.0 millimeter" in surf_repr
assert "Surface offset : MidSurfaceOffsetType.TOP" in surf_repr
assert f"Color : {DEFAULT_COLOR}" in surf_repr

Expand Down Expand Up @@ -1726,7 +1726,7 @@ def test_midsurface_properties(modeler: Modeler):
assert "Exists : True" in surf_repr
assert "Parent component : MidSurfaceProperties" in surf_repr
assert "Surface body : True" in surf_repr
assert "Surface thickness : 30 millimeter" in surf_repr
assert "Surface thickness : 30.0 millimeter" in surf_repr
assert "Surface offset : MidSurfaceOffsetType.BOTTOM" in surf_repr
assert f"Color : {DEFAULT_COLOR}" in surf_repr
except GeometryExitedError:
Expand Down
Loading