|
24 | 24 | from enum import Enum, unique |
25 | 25 | from pathlib import Path |
26 | 26 |
|
| 27 | +from ansys.api.dbu.v0.dbumodels_pb2 import EntityIdentifier, PartExportFormat |
| 28 | +from ansys.api.dbu.v0.designs_pb2 import NewRequest, SaveAsRequest |
| 29 | +from ansys.api.dbu.v0.designs_pb2_grpc import DesignsStub |
27 | 30 | from ansys.api.geometry.v0.commands_pb2 import ( |
28 | 31 | AssignMidSurfaceOffsetTypeRequest, |
29 | 32 | AssignMidSurfaceThicknessRequest, |
30 | 33 | CreateBeamCircularProfileRequest, |
31 | 34 | ) |
32 | 35 | from ansys.api.geometry.v0.commands_pb2_grpc import CommandsStub |
33 | | -from ansys.api.geometry.v0.designs_pb2 import ExportRequest, NewRequest, SaveAsRequest |
34 | | -from ansys.api.geometry.v0.designs_pb2_grpc import DesignsStub |
35 | 36 | from ansys.api.geometry.v0.materials_pb2 import AddToDocumentRequest |
36 | 37 | from ansys.api.geometry.v0.materials_pb2_grpc import MaterialsStub |
37 | | -from ansys.api.geometry.v0.models_pb2 import Empty, EntityIdentifier |
38 | 38 | from ansys.api.geometry.v0.models_pb2 import Material as GRPCMaterial |
39 | 39 | from ansys.api.geometry.v0.models_pb2 import MaterialProperty as GRPCMaterialProperty |
40 | | -from ansys.api.geometry.v0.models_pb2 import PartExportFormat |
41 | 40 | from ansys.api.geometry.v0.namedselections_pb2_grpc import NamedSelectionsStub |
| 41 | +from ansys.api.geometry.v0.parts_pb2 import ExportRequest |
| 42 | +from ansys.api.geometry.v0.parts_pb2_grpc import PartsStub |
42 | 43 | from beartype import beartype as check_input_types |
43 | 44 | from beartype.typing import Dict, List, Optional, Union |
| 45 | +from google.protobuf.empty_pb2 import Empty |
44 | 46 | import numpy as np |
45 | 47 | from pint import Quantity |
46 | 48 |
|
@@ -119,6 +121,7 @@ def __init__(self, name: str, grpc_client: GrpcClient, read_existing_design: boo |
119 | 121 | self._commands_stub = CommandsStub(self._grpc_client.channel) |
120 | 122 | self._materials_stub = MaterialsStub(self._grpc_client.channel) |
121 | 123 | self._named_selections_stub = NamedSelectionsStub(self._grpc_client.channel) |
| 124 | + self._parts_stub = PartsStub(self._grpc_client.channel) |
122 | 125 |
|
123 | 126 | # Initialize needed instance variables |
124 | 127 | self._materials = [] |
@@ -235,7 +238,7 @@ def download( |
235 | 238 | DesignFileFormat.IGES, |
236 | 239 | DesignFileFormat.PMDB, |
237 | 240 | ]: |
238 | | - response = self._design_stub.Export(ExportRequest(format=format.value[1])) |
| 241 | + response = self._parts_stub.Export(ExportRequest(format=format.value[1])) |
239 | 242 | received_bytes += response.data |
240 | 243 | else: |
241 | 244 | self._grpc_client.log.warning( |
@@ -585,9 +588,11 @@ def __read_existing_design(self) -> None: |
585 | 588 | raise RuntimeError("No existing design available at service level.") |
586 | 589 | else: |
587 | 590 | self._id = design.main_part.id |
588 | | - self._name = design.main_part.name |
| 591 | + # Here we may take the design's name instead of the main part's name. |
| 592 | + # Since they're the same in the backend. |
| 593 | + self._name = design.name |
589 | 594 |
|
590 | | - response = self._design_stub.GetAssembly(EntityIdentifier(id="")) |
| 595 | + response = self._commands_stub.GetAssembly(EntityIdentifier(id="")) |
591 | 596 |
|
592 | 597 | # Store created objects |
593 | 598 | created_parts = {p.id: Part(p.id, p.name, [], []) for p in response.parts} |
|
0 commit comments