Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add 'create' to Graphics and Plot containers. #3403

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,11 @@ class SurfaceDefn(GraphicsDefn):

PLURAL = "Surfaces"

@property
def name(self) -> str:
"""Return name of the created surface."""
return self._name

class show_edges(metaclass=PyLocalPropertyMeta):
"""Show edges for surface."""

Expand Down
21 changes: 20 additions & 1 deletion src/ansys/fluent/core/post_objects/post_objects_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,29 @@ def _init_module(self, obj, mod, post_api_helper):
if cls.__class__.__name__ in (
"PyLocalNamedObjectMetaAbstract",
) and not inspect.isabstract(cls):
cont = PyLocalContainer(self, cls, post_api_helper, cls.PLURAL)

def _add_create(py_cont):
def _create(**kwargs):
new_object = py_cont.__getitem__(
py_cont._get_unique_chid_name()
)
unexpected_args = list(set(kwargs) - set(new_object()))
if unexpected_args:
raise TypeError(
f"create() got an unexpected keyword argument '{unexpected_args[0]}'."
)
for key, value in kwargs.items():
new_object.__setattr__(key, value)
return new_object

return _create

setattr(cont, "create", _add_create(cont))
setattr(
obj,
cls.PLURAL,
PyLocalContainer(self, cls, post_api_helper, cls.PLURAL),
cont,
)


Expand Down
Loading