Skip to content

Commit 0332c3e

Browse files
authored
gdc (#1460)
(cherry picked from commit 09d508e)
1 parent a2d17c3 commit 0332c3e

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/ansys/dpf/core/generic_data_container.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
import warnings
1010
import builtins
1111
from typing import Union, TYPE_CHECKING
12+
13+
from ansys.dpf.core.check_version import server_meet_version
14+
1215
if TYPE_CHECKING: # pragma: no cover
1316
from ansys.dpf.core import Field, Scoping, StringField, GenericDataContainer
1417

@@ -104,8 +107,11 @@ def set_property(
104107
Property object.
105108
"""
106109

107-
any_dpf = Any.new_from(prop, self._server)
108-
self._api.generic_data_container_set_property_any(self, property_name, any_dpf)
110+
if not isinstance(prop, (int, float, str)) and server_meet_version("8.1", self._server):
111+
self._api.generic_data_container_set_property_dpf_type(self, property_name, prop)
112+
else:
113+
any_dpf = Any.new_from(prop, self._server)
114+
self._api.generic_data_container_set_property_any(self, property_name, any_dpf)
109115

110116
def get_property(self, property_name, output_type: Union[None, type, types] = None):
111117
"""Get property with given name.

src/ansys/dpf/gate/generic_data_container_grpcapi.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,15 @@ def generic_data_container_set_property_any(container, name, any):
4141
request.any.add().CopyFrom(any._internal_obj)
4242
return _get_stub(container._server).SetProperty(request)
4343

44+
@staticmethod
45+
def generic_data_container_set_property_dpf_type(container, name, any):
46+
from ansys.grpc.dpf import generic_data_container_pb2
47+
request = generic_data_container_pb2.SetPropertyRequest()
48+
request.gdc.CopyFrom(container._internal_obj)
49+
request.property_name.extend([name])
50+
request.any.add().id.CopyFrom(any._internal_obj.id)
51+
return _get_stub(container._server).SetProperty(request)
52+
4453
@staticmethod
4554
def generic_data_container_new_on_client(client):
4655
from ansys.grpc.dpf import generic_data_container_pb2, base_pb2

0 commit comments

Comments
 (0)