Skip to content

Commit 2d092ff

Browse files
contn
1 parent f0445bd commit 2d092ff

File tree

3 files changed

+57
-28
lines changed

3 files changed

+57
-28
lines changed

src/ansys/geometry/core/designer/design.py

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,14 @@
2525
from pathlib import Path
2626
from typing import Union
2727

28-
from ansys.api.dbu.v0.dbumodels_pb2 import EntityIdentifier, PartExportFormat
28+
from ansys.api.dbu.v0.dbumodels_pb2 import (
29+
EntityIdentifier,
30+
PartExportFormat,
31+
)
2932
from ansys.api.dbu.v0.designs_pb2 import InsertRequest, NewRequest, SaveAsRequest
3033
from ansys.api.dbu.v0.designs_pb2_grpc import DesignsStub
34+
from ansys.api.dbu.v0.drivingdimensions_pb2 import GetAllRequest, UpdateRequest
35+
from ansys.api.dbu.v0.drivingdimensions_pb2_grpc import DrivingDimensionsStub
3136
from ansys.api.geometry.v0.commands_pb2 import (
3237
AssignMidSurfaceOffsetTypeRequest,
3338
AssignMidSurfaceThicknessRequest,
@@ -74,6 +79,7 @@
7479
from ansys.geometry.core.misc.checks import ensure_design_is_active, min_backend_version
7580
from ansys.geometry.core.misc.measurements import DEFAULT_UNITS, Distance
7681
from ansys.geometry.core.modeler import Modeler
82+
from ansys.geometry.core.parameters import driving_dimensions
7783
from ansys.geometry.core.typing import RealSequence
7884

7985

@@ -112,6 +118,7 @@ class Design(Component):
112118
_materials: list[Material]
113119
_named_selections: dict[str, NamedSelection]
114120
_beam_profiles: dict[str, BeamProfile]
121+
_driving_dimensions: list[driving_dimensions.DrivingDimension]
115122

116123
@protect_grpc
117124
@check_input_types
@@ -125,6 +132,7 @@ def __init__(self, name: str, modeler: Modeler, read_existing_design: bool = Fal
125132
self._materials_stub = MaterialsStub(self._grpc_client.channel)
126133
self._named_selections_stub = NamedSelectionsStub(self._grpc_client.channel)
127134
self._parts_stub = PartsStub(self._grpc_client.channel)
135+
self._paremeters_stub = DrivingDimensionsStub(self._grpc_client.channel)
128136

129137
# Initialize needed instance variables
130138
self._materials = []
@@ -133,6 +141,7 @@ def __init__(self, name: str, modeler: Modeler, read_existing_design: bool = Fal
133141
self._design_id = ""
134142
self._is_active = False
135143
self._modeler = modeler
144+
self._driving_dimensions = []
136145

137146
# Check whether we want to process an existing design or create a new one.
138147
if read_existing_design:
@@ -165,6 +174,11 @@ def beam_profiles(self) -> list[BeamProfile]:
165174
"""List of beam profile available for the design."""
166175
return list(self._beam_profiles.values())
167176

177+
@property
178+
def driving_dimensions(self) -> list[driving_dimensions.DrivingDimension]:
179+
"""List of driving dimensions available for the design."""
180+
return self.get_all_driving_dimensions()
181+
168182
@property
169183
def is_active(self) -> bool:
170184
"""Whether the design is currently active."""
@@ -656,6 +670,47 @@ def add_beam_circular_profile(
656670

657671
return self._beam_profiles[profile.name]
658672

673+
@protect_grpc
674+
@min_backend_version(25, 1, 0)
675+
def get_all_driving_dimensions(self):
676+
"""Get driving dimensions for the design.
677+
678+
Returns
679+
-------
680+
List[DrivingDimension]
681+
List of driving dimensions for the design.
682+
"""
683+
response = self._paremeters_stub.GetAll(GetAllRequest())
684+
print(response)
685+
return [
686+
driving_dimensions.DrivingDimension._from_proto(dimension)
687+
for dimension in response.driving_dimensions
688+
]
689+
690+
@protect_grpc
691+
@check_input_types
692+
@min_backend_version(25, 1, 0)
693+
def set_driving_dimensions(
694+
self, driving_dimension: driving_dimensions.DrivingDimension
695+
) -> bool:
696+
"""Set driving dimensions for a body.
697+
698+
Parameters
699+
----------
700+
body : Body
701+
Body to set driving dimensions.
702+
dimensions : List[DrivingDimension]
703+
List of driving dimensions to set.
704+
705+
Returns
706+
-------
707+
bool
708+
True if driving dimensions were set successfully.
709+
"""
710+
request = UpdateRequest(driving_dimension=driving_dimension._to_proto())
711+
response = self._driving_dimensions_stub.Update(request)
712+
return response.success
713+
659714
@protect_grpc
660715
@check_input_types
661716
@ensure_design_is_active

src/ansys/geometry/core/modeler.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -422,11 +422,6 @@ def prepare_tools(self) -> PrepareTools:
422422
"""Access to prepare tools."""
423423
return self._prepare_tools
424424

425-
@property
426-
def driving_dimensions(self) -> DrivingDimensions:
427-
"""Access to parameters."""
428-
return self._driving_dimensions
429-
430425
@property
431426
@min_backend_version(24, 2, 0)
432427
def measurement_tools(self) -> MeasurementTools:

src/ansys/geometry/core/parameters/driving_dimensions.py

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
from enum import Enum, unique
2525

2626
from ansys.api.dbu.v0.dbumodels_pb2 import DrivingDimension as DrivingDimensionProto
27-
from ansys.api.dbu.v0.drivingdimensions_pb2 import GetAllRequest, UpdateRequest
27+
from ansys.api.dbu.v0.drivingdimensions_pb2 import UpdateRequest
2828
from ansys.api.dbu.v0.drivingdimensions_pb2_grpc import DrivingDimensionsStub
2929
from beartype import beartype as check_input_types
3030

@@ -109,27 +109,6 @@ def __init__(self, grpc_client: GrpcClient):
109109
self._driving_dimensions_stub = DrivingDimensionsStub(self._grpc_client.channel)
110110
self.id = None
111111

112-
@protect_grpc
113-
@min_backend_version(25, 1, 0)
114-
def get_all_driving_dimensions(self):
115-
"""Get driving dimensions for a body.
116-
117-
Parameters
118-
----------
119-
body : Body
120-
Body to get driving dimensions.
121-
122-
Returns
123-
-------
124-
List[DrivingDimension]
125-
List of driving dimensions for the body.
126-
"""
127-
response = self._driving_dimensions_stub.GetAll(GetAllRequest())
128-
print(response)
129-
return [
130-
DrivingDimension._from_proto(dimension) for dimension in response.driving_dimensions
131-
]
132-
133112
@protect_grpc
134113
@check_input_types
135114
@min_backend_version(25, 1, 0)

0 commit comments

Comments
 (0)