Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 37 additions & 17 deletions src/ansys/fluent/core/services/datamodel_se.py
Original file line number Diff line number Diff line change
Expand Up @@ -843,13 +843,14 @@ def __init__(
) -> None:
"""__init__ method of PyStateContainer class."""
super().__init__()
self.service: DatamodelService = service
self.rules = rules
if path is None:
self.path = []
else:
self.path = path
self.cached_attrs = {}
self.__dict__.update(
dict(
service=service,
rules=rules,
path=[] if path is None else path,
cached_attrs={},
)
)

def get_remote_state(self) -> Any:
"""Get state of the current object."""
Expand Down Expand Up @@ -1791,13 +1792,16 @@ def __init__(
parent_arg,
) -> None:
"""__init__ method of PyCommandArgumentsSubItem class."""
self.parent = parent
self.name = name

self.service = service
self.rules = rules
self.path = path
self.parent_arg = parent_arg
self.__dict__.update(
dict(
parent=parent,
name=name,
service=service,
rules=rules,
path=path,
parent_arg=parent_arg,
)
)

def get_state(self) -> Any:
"""Get state of the command argument."""
Expand Down Expand Up @@ -1834,6 +1838,12 @@ def help(self) -> None:
"""Get help."""
pass

def __setattr__(self, key, value):
if isinstance(value, PyCommandArgumentsSubItem):
super().__setattr__(key, value)
else:
getattr(self, key).set_state(value)


class PyCommandArguments(PyStateContainer):
"""Class representing command arguments in datamodel."""
Expand All @@ -1848,11 +1858,15 @@ def __init__(
static_info,
) -> None:
"""__init__ method of PyCommandArguments class."""
self.static_info = static_info
super().__init__(service, rules, path)
self.__dict__.update(
dict(
static_info=static_info,
command=command,
id=id,
)
)
self.path.append((command, id))
self.command = command
self.id = id

def __del__(self) -> None:
try:
Expand Down Expand Up @@ -1887,6 +1901,12 @@ def get_attr(self, attrib: str) -> Any:
"""
return self._get_remote_attr(attrib)

def __setattr__(self, key, value):
if isinstance(value, PyCommandArgumentsSubItem):
super().__setattr__(key, value)
else:
getattr(self, key).set_state(value)


class PyTextualCommandArgumentsSubItem(PyCommandArgumentsSubItem, PyTextual):
"""Class representing textual command argument in datamodel."""
Expand Down
16 changes: 16 additions & 0 deletions tests/test_datamodel_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -784,6 +784,22 @@ def test_on_affected_lifetime_with_delete_all_child_objects(new_solver_session):
assert "/test/affected/A:A1-1" not in solver._se_service.subscriptions


@pytest.mark.fluent_version(">=23.2")
def test_set_command_args_and_sub_args(new_meshing_session):
meshing = new_meshing_session
ig = meshing.meshing.ImportGeometry.create_instance()

# Command Arguments
assert ig.MeshUnit() == "m"
ig.MeshUnit = "mm"
assert ig.MeshUnit() == "mm"

# Command Arguments SubItem
assert ig.CadImportOptions.OneZonePer() == "body"
ig.CadImportOptions.OneZonePer = "face"
assert ig.CadImportOptions.OneZonePer() == "face"


@pytest.mark.fluent_version(">=24.1")
def test_dynamic_dependency(new_meshing_session):
meshing = new_meshing_session
Expand Down