refactor get_avalon_container to get_or_create_avalon_container

Co-authored-by: Roy Nieterau <roy_nieterau@hotmail.com>
This commit is contained in:
Mustafa Taher 2024-06-20 16:04:40 +03:00 committed by GitHub
parent 336d38b218
commit 0ddfaa5b91
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -397,21 +397,16 @@ def on_new():
_enforce_start_frame()
def get_avalon_container():
path = AVALON_CONTAINERS
avalon_container = hou.node(path)
if not avalon_container:
# Let's create avalon container secretly
# but make sure the pipeline still is built the
# way we anticipate it was built, asserting it.
assert path == "/obj/AVALON_CONTAINERS"
def get_or_create_avalon_container() -> "hou.OpNode":
avalon_container = hou.node(AVALON_CONTAINERS)
if avalon_container:
return avalon_container
parent = hou.node("/obj")
avalon_container = parent.createNode(
"subnet", node_name="AVALON_CONTAINERS"
)
return avalon_container
parent_path, name = AVALON_CONTAINERS.rsplit("/", 1)
parent = hou.node(parent_path)
return parent.createNode(
"subnet", node_name=name
)
def _set_context_settings():