Skip to content

Commit 61bc06f

Browse files
renaming
1 parent 2d092ff commit 61bc06f

File tree

4 files changed

+18
-66
lines changed

4 files changed

+18
-66
lines changed

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

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
from ansys.geometry.core.misc.checks import ensure_design_is_active, min_backend_version
8080
from ansys.geometry.core.misc.measurements import DEFAULT_UNITS, Distance
8181
from ansys.geometry.core.modeler import Modeler
82-
from ansys.geometry.core.parameters import driving_dimensions
82+
from ansys.geometry.core.parameters.driving_dimensions import DrivingDimension as DrivingDimension
8383
from ansys.geometry.core.typing import RealSequence
8484

8585

@@ -118,7 +118,7 @@ class Design(Component):
118118
_materials: list[Material]
119119
_named_selections: dict[str, NamedSelection]
120120
_beam_profiles: dict[str, BeamProfile]
121-
_driving_dimensions: list[driving_dimensions.DrivingDimension]
121+
_driving_dimensions: list[DrivingDimension]
122122

123123
@protect_grpc
124124
@check_input_types
@@ -132,7 +132,7 @@ def __init__(self, name: str, modeler: Modeler, read_existing_design: bool = Fal
132132
self._materials_stub = MaterialsStub(self._grpc_client.channel)
133133
self._named_selections_stub = NamedSelectionsStub(self._grpc_client.channel)
134134
self._parts_stub = PartsStub(self._grpc_client.channel)
135-
self._paremeters_stub = DrivingDimensionsStub(self._grpc_client.channel)
135+
self._parameters_stub = DrivingDimensionsStub(self._grpc_client.channel)
136136

137137
# Initialize needed instance variables
138138
self._materials = []
@@ -175,7 +175,7 @@ def beam_profiles(self) -> list[BeamProfile]:
175175
return list(self._beam_profiles.values())
176176

177177
@property
178-
def driving_dimensions(self) -> list[driving_dimensions.DrivingDimension]:
178+
def driving_dimensions(self) -> list[DrivingDimension]:
179179
"""List of driving dimensions available for the design."""
180180
return self.get_all_driving_dimensions()
181181

@@ -680,25 +680,19 @@ def get_all_driving_dimensions(self):
680680
List[DrivingDimension]
681681
List of driving dimensions for the design.
682682
"""
683-
response = self._paremeters_stub.GetAll(GetAllRequest())
684-
print(response)
683+
response = self._parameters_stub.GetAll(GetAllRequest())
685684
return [
686-
driving_dimensions.DrivingDimension._from_proto(dimension)
687-
for dimension in response.driving_dimensions
685+
DrivingDimension._from_proto(dimension) for dimension in response.driving_dimensions
688686
]
689687

690688
@protect_grpc
691689
@check_input_types
692690
@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.
691+
def set_driving_dimensions(self, dimension: DrivingDimension) -> bool:
692+
"""Update a driving dimension of the design.
697693
698694
Parameters
699695
----------
700-
body : Body
701-
Body to set driving dimensions.
702696
dimensions : List[DrivingDimension]
703697
List of driving dimensions to set.
704698
@@ -707,9 +701,9 @@ def set_driving_dimensions(
707701
bool
708702
True if driving dimensions were set successfully.
709703
"""
710-
request = UpdateRequest(driving_dimension=driving_dimension._to_proto())
711-
response = self._driving_dimensions_stub.Update(request)
712-
return response.success
704+
request = UpdateRequest(driving_dimension=DrivingDimension._to_proto(dimension))
705+
dimension = self._parameters_stub.Update(request)
706+
return dimension
713707

714708
@protect_grpc
715709
@check_input_types

src/ansys/geometry/core/modeler.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
from ansys.geometry.core.logger import LOG
4141
from ansys.geometry.core.misc.checks import check_type, min_backend_version
4242
from ansys.geometry.core.misc.options import ImportOptions
43-
from ansys.geometry.core.parameters import DrivingDimensions
4443
from ansys.geometry.core.tools.measurement_tools import MeasurementTools
4544
from ansys.geometry.core.tools.prepare_tools import PrepareTools
4645
from ansys.geometry.core.tools.repair_tools import RepairTools
@@ -125,13 +124,11 @@ def __init__(
125124
self._repair_tools = None
126125
self._prepare_tools = None
127126
self._measurement_tools = None
128-
self._driving_dimensions = None
129127
LOG.warning("Linux backend does not support repair or prepare tools.")
130128
else:
131129
self._repair_tools = RepairTools(self._grpc_client)
132130
self._prepare_tools = PrepareTools(self._grpc_client)
133131
self._measurement_tools = MeasurementTools(self._grpc_client)
134-
self._driving_dimensions = DrivingDimensions(self._grpc_client)
135132

136133
# Maintaining references to all designs within the modeler workspace
137134
self._designs: dict[str, "Design"] = {}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@
2121
# SOFTWARE.
2222
"""PyAnsys Geometry parameters subpackage."""
2323

24-
from ansys.geometry.core.parameters.driving_dimensions import DrivingDimensions
24+
from ansys.geometry.core.parameters.driving_dimensions import DrivingDimension

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

Lines changed: 6 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,10 @@
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 UpdateRequest
28-
from ansys.api.dbu.v0.drivingdimensions_pb2_grpc import DrivingDimensionsStub
29-
from beartype import beartype as check_input_types
30-
31-
from ansys.geometry.core.connection import GrpcClient
32-
from ansys.geometry.core.errors import protect_grpc
33-
from ansys.geometry.core.misc.checks import min_backend_version
3427

3528

3629
@unique
37-
class DrivingDimensionType(Enum):
30+
class ParameterType(Enum):
3831
"""Provides values for driving dimension types supported."""
3932

4033
DIMENSIONTYPE_UNKNOWN = 0
@@ -50,11 +43,11 @@ class DrivingDimensionType(Enum):
5043
DIMENSIONTYPE_UNITLESS = 10
5144

5245

53-
class DrivingDimension:
54-
"""Represents a driving dimension."""
46+
class Parameter:
47+
"""Represents a parameter."""
5548

56-
def __init__(self, id, name, dimension_type: DrivingDimensionType, dimension_value):
57-
"""Initialize Driving Dimension class."""
49+
def __init__(self, id, name, dimension_type: ParameterType, dimension_value):
50+
"""Initialize Parameter class."""
5851
self.id = id
5952
self._name = name
6053
self.dimension_type = dimension_type
@@ -66,7 +59,7 @@ def _from_proto(cls, proto):
6659
return cls(
6760
id=proto.id,
6861
name=proto.name,
69-
dimension_type=DrivingDimensionType(proto.dimension_type),
62+
dimension_type=ParameterType(proto.dimension_type),
7063
dimension_value=proto.dimension_value,
7164
)
7265

@@ -98,35 +91,3 @@ def _to_proto(self):
9891
dimension_type=self.dimension_type.value,
9992
dimension_value=self.dimension_value,
10093
)
101-
102-
103-
class DrivingDimensions:
104-
"""Represents Driving Dimensions."""
105-
106-
def __init__(self, grpc_client: GrpcClient):
107-
"""Initialize Driving Dimensions class."""
108-
self._grpc_client = grpc_client
109-
self._driving_dimensions_stub = DrivingDimensionsStub(self._grpc_client.channel)
110-
self.id = None
111-
112-
@protect_grpc
113-
@check_input_types
114-
@min_backend_version(25, 1, 0)
115-
def set_driving_dimensions(self, driving_dimension: DrivingDimension) -> bool:
116-
"""Set driving dimensions for a body.
117-
118-
Parameters
119-
----------
120-
body : Body
121-
Body to set driving dimensions.
122-
dimensions : List[DrivingDimension]
123-
List of driving dimensions to set.
124-
125-
Returns
126-
-------
127-
bool
128-
True if driving dimensions were set successfully.
129-
"""
130-
request = UpdateRequest(driving_dimension=driving_dimension._to_proto())
131-
response = self._driving_dimensions_stub.Update(request)
132-
return response.success

0 commit comments

Comments
 (0)