Skip to content

Commit

Permalink
gdc (#1460)
Browse files Browse the repository at this point in the history
(cherry picked from commit 09d508e)
  • Loading branch information
cbellot000 authored Mar 8, 2024
1 parent a2d17c3 commit 0332c3e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/ansys/dpf/core/generic_data_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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.
Expand Down
9 changes: 9 additions & 0 deletions src/ansys/dpf/gate/generic_data_container_grpcapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0332c3e

Please sign in to comment.