Skip to content

Commit

Permalink
Add use_ayon_entity_uri parm which force refreshes the path resolvi…
Browse files Browse the repository at this point in the history
…ng when toggled
  • Loading branch information
BigRoy committed Aug 27, 2024
1 parent b26e55e commit 8f631f4
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
7 changes: 5 additions & 2 deletions client/ayon_houdini/api/hda_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,14 +264,17 @@ def on_representation_id_changed(node):
set_representation(node, repre_id)


def on_representation_parms_changed(node):
def on_representation_parms_changed(node, force=False):
"""
Usually used as callback to the project, folder, product, version and
representation parms which on change - would result in a different
representation id to be resolved.
Args:
node (hou.Node): Node to update.
force (Optional[bool]): Whether to force the callback to retrigger
even if the representation id already matches. For example, when
needing to resolve the filepath in a different way.
"""
project_name = node.evalParm("project_name") or get_current_project_name()
representation_id = get_representation_id(
Expand All @@ -287,7 +290,7 @@ def on_representation_parms_changed(node):
else:
representation_id = str(representation_id)

if node.evalParm("representation") != representation_id:
if force or node.evalParm("representation") != representation_id:
node.parm("representation").set(representation_id)
node.parm("representation").pressButton() # trigger callback

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,15 @@
default { "" }
parmtag { "script_callback_language" "python" }
}
parm {
name "use_ayon_entity_uri"
label "Use AYON Entity URI"
help "When enabled, loads the filepath using the AYON Entity URI instead of the resolved filepath."
type toggle
default { "0" }
parmtag { "script_callback" "hou.phm().on_representation_parms_changed(kwargs['node'], force=True)" }
parmtag { "script_callback_language" "python" }
}
parm {
name "primpath1"
label "Primitive Root"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,15 @@
default { "" }
parmtag { "script_callback_language" "python" }
}
parm {
name "use_ayon_entity_uri"
label "Use AYON Entity URI"
help "When enabled, loads the filepath using the AYON Entity URI instead of the resolved filepath."
type toggle
default { "0" }
parmtag { "script_callback" "hou.phm().on_representation_parms_changed(kwargs['node'], force=True)" }
parmtag { "script_callback_language" "python" }
}
groupcollapsible {
name "extra_options"
label "Load Options"
Expand Down

0 comments on commit 8f631f4

Please sign in to comment.