|
4 | 4 | """ |
5 | 5 |
|
6 | 6 | import numpy as np |
| 7 | +from ansys.dpf.core.check_version import version_requires |
7 | 8 | from ansys.dpf.core.common import natures, locations, _get_size_of_list |
8 | 9 | from ansys.dpf.core import scoping, dimensionality |
9 | 10 | from ansys.dpf.core.field_base import _FieldBase, _LocalFieldBase |
| 11 | +from ansys.dpf.core.check_version import meets_version |
| 12 | +from ansys.dpf.core.field_definition import FieldDefinition |
10 | 13 | from ansys.dpf.gate import ( |
11 | 14 | property_field_abstract_api, |
12 | 15 | property_field_capi, |
@@ -69,6 +72,9 @@ def __init__( |
69 | 72 | field=property_field, |
70 | 73 | server=server, |
71 | 74 | ) |
| 75 | + self._field_definition = None |
| 76 | + if meets_version(self._server.version, "8.1"): |
| 77 | + self._field_definition = self._load_field_definition() |
72 | 78 |
|
73 | 79 | @property |
74 | 80 | def _api(self) -> property_field_abstract_api.PropertyFieldAbstractAPI: |
@@ -101,6 +107,14 @@ def _field_create_internal_obj( |
101 | 107 | else: |
102 | 108 | return api.csproperty_field_new(nentities, nentities * dim.component_count) |
103 | 109 |
|
| 110 | + |
| 111 | + @version_requires("8.1") |
| 112 | + def _load_field_definition(self): |
| 113 | + """Attempt to load the field definition for this field.""" |
| 114 | + # try: |
| 115 | + out = self._api.csproperty_field_get_shared_field_definition(self) |
| 116 | + return FieldDefinition(out, self._server) |
| 117 | + |
104 | 118 | @property |
105 | 119 | def location(self): |
106 | 120 | """Location of the property field. |
@@ -299,6 +313,35 @@ def as_local_field(self): |
299 | 313 | """ |
300 | 314 | return _LocalPropertyField(self) |
301 | 315 |
|
| 316 | + @property |
| 317 | + @version_requires("8.1") |
| 318 | + def name(self): |
| 319 | + """Name of the property field. |
| 320 | +
|
| 321 | + ..note: |
| 322 | + Available starting with DPF 2024.2.pre1. |
| 323 | + """ |
| 324 | + if self._field_definition: |
| 325 | + return self._field_definition.name |
| 326 | + |
| 327 | + @name.setter |
| 328 | + @version_requires("8.1") |
| 329 | + def name(self, value): |
| 330 | + """Change the name of the property field |
| 331 | +
|
| 332 | + Parameters |
| 333 | + ---------- |
| 334 | + value : str |
| 335 | + Name of the property field. |
| 336 | +
|
| 337 | + ..note: |
| 338 | + Available starting with DPF 2024.2.pre1. |
| 339 | + """ |
| 340 | + if self._field_definition: |
| 341 | + self._field_definition._api.csfield_definition_set_name( |
| 342 | + self._field_definition, name=value |
| 343 | + ) |
| 344 | + |
302 | 345 |
|
303 | 346 | class _LocalPropertyField(_LocalFieldBase, PropertyField): |
304 | 347 | """Caches the internal data of a field so that it can be modified locally. |
|
0 commit comments