Skip to content

Commit eb80d83

Browse files
authored
Merge branch 'main' into dependabot/pip/ansys-api-geometry-0.4.69
2 parents 91198ea + b0225b1 commit eb80d83

File tree

6 files changed

+76
-5
lines changed

6 files changed

+76
-5
lines changed

doc/changelog.d/2148.added.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Set multiple export ids
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Bump matplotlib from 3.10.3 to 3.10.5
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Bump notebook from 7.4.4 to 7.4.5 in the docs-deps group

pyproject.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ tests = [
6464
"geomdl==5.4.0",
6565
"grpcio==1.71.0",
6666
"grpcio-health-checking==1.71.0",
67-
"matplotlib==3.10.3",
67+
"matplotlib==3.10.5",
6868
"numpy==2.2.6",
6969
"Pint==0.24.4",
7070
"protobuf==5.29.3",
@@ -98,11 +98,11 @@ doc = [
9898
"ipyvtklink==0.2.3",
9999
"jupyter_sphinx==0.5.3",
100100
"jupytext==1.17.2",
101-
"matplotlib==3.10.3",
101+
"matplotlib==3.10.5",
102102
"myst-parser==4.0.1",
103103
"nbconvert==7.16.6",
104104
"nbsphinx==0.9.6",
105-
"notebook==7.4.4",
105+
"notebook==7.4.5",
106106
"numpydoc==1.9.0",
107107
"numpy==2.2.6",
108108
"panel==1.7.5",

src/ansys/geometry/core/tools/unsupported.py

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,16 @@
2121
# SOFTWARE.
2222
"""Unsupported functions for the PyAnsys Geometry library."""
2323

24+
from dataclasses import dataclass
2425
from enum import Enum, unique
2526
from typing import TYPE_CHECKING
2627

2728
from ansys.api.dbu.v0.dbumodels_pb2 import EntityIdentifier
28-
from ansys.api.geometry.v0.unsupported_pb2 import ExportIdRequest, ImportIdRequest
29+
from ansys.api.geometry.v0.unsupported_pb2 import (
30+
ExportIdRequest,
31+
ImportIdRequest,
32+
SetExportIdsRequest,
33+
)
2934
from ansys.api.geometry.v0.unsupported_pb2_grpc import UnsupportedStub
3035
from ansys.geometry.core.connection import GrpcClient
3136
from ansys.geometry.core.errors import protect_grpc
@@ -49,6 +54,15 @@ class PersistentIdType(Enum):
4954
PRIME_ID = 700
5055

5156

57+
@dataclass
58+
class ExportIdData:
59+
"""Data for exporting persistent ids."""
60+
61+
moniker: str
62+
id_type: PersistentIdType
63+
value: str
64+
65+
5266
class UnsupportedCommands:
5367
"""Provides unsupported commands for PyAnsys Geometry.
5468
@@ -168,6 +182,38 @@ def set_export_id(self, moniker: str, id_type: PersistentIdType, value: str) ->
168182
self._unsupported_stub.SetExportId(request)
169183
self.__id_map = {}
170184

185+
@protect_grpc
186+
@min_backend_version(26, 1, 0)
187+
def set_multiple_export_ids(
188+
self,
189+
export_data: list[ExportIdData],
190+
) -> None:
191+
"""Set multiple persistent ids for the monikers.
192+
193+
Parameters
194+
----------
195+
export_data : list[ExportIdData]
196+
List of export data containing monikers, id types, and values.
197+
198+
Warnings
199+
--------
200+
This method is only available starting on Ansys release 26R1.
201+
"""
202+
request = SetExportIdsRequest(
203+
export_data=[
204+
ExportIdRequest(
205+
moniker=EntityIdentifier(id=data.moniker),
206+
id=data.value,
207+
type=data.id_type.value,
208+
)
209+
for data in export_data
210+
]
211+
)
212+
213+
# Call the gRPC service
214+
self._unsupported_stub.SetExportIds(request)
215+
self.__id_map = {}
216+
171217
def get_body_occurrences_from_import_id(
172218
self, import_id: str, id_type: PersistentIdType
173219
) -> list["Body"]:

tests/integration/test_design_import.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
from ansys.geometry.core.math import UNITVECTOR3D_Z, Plane, Point2D, Point3D, UnitVector3D, Vector3D
3535
from ansys.geometry.core.misc import UNITS, Distance
3636
from ansys.geometry.core.sketch import Sketch
37-
from ansys.geometry.core.tools.unsupported import PersistentIdType
37+
from ansys.geometry.core.tools.unsupported import ExportIdData, PersistentIdType
3838

3939
from .conftest import FILES_DIR, IMPORT_FILES_DIR
4040

@@ -212,6 +212,7 @@ def test_open_file(modeler: Modeler, tmp_path_factory: pytest.TempPathFactory):
212212
comp1.extrude_sketch("Top", sketch, 5)
213213

214214
if BackendType.is_core_service(modeler.client.backend_type):
215+
# Set single export ids and verify
215216
modeler.unsupported.set_export_id(base_body.id, PersistentIdType.PRIME_ID, "1")
216217
modeler.unsupported.set_export_id(wheel_body.id, PersistentIdType.PRIME_ID, "2")
217218

@@ -238,6 +239,27 @@ def test_open_file(modeler: Modeler, tmp_path_factory: pytest.TempPathFactory):
238239
assert base_body.faces[0].id in [f.id for f in faces]
239240
assert base_body.edges[0].id in [e.id for e in edges]
240241

242+
# Set multiple export ids at once and verify
243+
export_data = [
244+
ExportIdData(
245+
moniker=base_body.faces[1].id, id_type=PersistentIdType.PRIME_ID, value="5"
246+
),
247+
ExportIdData(
248+
moniker=base_body.edges[1].id, id_type=PersistentIdType.PRIME_ID, value="6"
249+
),
250+
]
251+
modeler.unsupported.set_multiple_export_ids(export_data)
252+
253+
faces2 = modeler.unsupported.get_face_occurrences_from_import_id(
254+
"5", PersistentIdType.PRIME_ID
255+
)
256+
edges2 = modeler.unsupported.get_edge_occurrences_from_import_id(
257+
"6", PersistentIdType.PRIME_ID
258+
)
259+
260+
assert base_body.faces[1].id in [b.id for b in faces2]
261+
assert base_body.edges[1].id in [b.id for b in edges2]
262+
241263
file = tmp_path_factory.mktemp("test_design_import") / "two_cars.scdocx"
242264
design.download(str(file))
243265

0 commit comments

Comments
 (0)