diff --git a/src/ansys/dpf/core/generic_data_container.py b/src/ansys/dpf/core/generic_data_container.py index 39071e364d..1f53f85367 100644 --- a/src/ansys/dpf/core/generic_data_container.py +++ b/src/ansys/dpf/core/generic_data_container.py @@ -9,6 +9,9 @@ import warnings import builtins from typing import Union, TYPE_CHECKING + +from ansys.dpf.core.check_version import server_meet_version + if TYPE_CHECKING: # pragma: no cover from ansys.dpf.core import Field, Scoping, StringField, GenericDataContainer @@ -104,8 +107,11 @@ def set_property( Property object. """ - any_dpf = Any.new_from(prop, self._server) - self._api.generic_data_container_set_property_any(self, property_name, any_dpf) + if not isinstance(prop, (int, float, str)) and server_meet_version("8.1", self._server): + self._api.generic_data_container_set_property_dpf_type(self, property_name, prop) + else: + any_dpf = Any.new_from(prop, self._server) + self._api.generic_data_container_set_property_any(self, property_name, any_dpf) def get_property(self, property_name, output_type: Union[None, type, types] = None): """Get property with given name. diff --git a/src/ansys/dpf/gate/generic_data_container_grpcapi.py b/src/ansys/dpf/gate/generic_data_container_grpcapi.py index ae7bdd0491..6cca3899fc 100644 --- a/src/ansys/dpf/gate/generic_data_container_grpcapi.py +++ b/src/ansys/dpf/gate/generic_data_container_grpcapi.py @@ -41,6 +41,15 @@ def generic_data_container_set_property_any(container, name, any): request.any.add().CopyFrom(any._internal_obj) return _get_stub(container._server).SetProperty(request) + @staticmethod + def generic_data_container_set_property_dpf_type(container, name, any): + from ansys.grpc.dpf import generic_data_container_pb2 + request = generic_data_container_pb2.SetPropertyRequest() + request.gdc.CopyFrom(container._internal_obj) + request.property_name.extend([name]) + request.any.add().id.CopyFrom(any._internal_obj.id) + return _get_stub(container._server).SetProperty(request) + @staticmethod def generic_data_container_new_on_client(client): from ansys.grpc.dpf import generic_data_container_pb2, base_pb2