Snippet VOP not working with ch() ?

   670   7   0
User Avatar
Member
339 posts
Joined: June 2013
Online
Hi
I tried to use ch() in a Snippet to reference a parameter, but its not working apparently. I know I can use backticks to force the ch to be the string evaluation of an hscript expression instead of VEX, but I'm curious why is the VEX ch not working itself, specially when following documentation guidelines. Scene attached.

Thanks

Image Not Found
Edited by probiner - March 4, 2024 19:36:26

Attachments:
PRB_Snippet_Parm.hip (115.2 KB)
houdinicore_EZ1urmY1ZR.mp4 (2.7 MB)

User Avatar
Member
339 posts
Joined: June 2013
Online
It seems that ch("parm") will reference `parm` parameter in Attribute VOP SOP container and not in the snippet node. This is something observed with Ramp VOP, etc, but given the documentation stating that I was wondering if there was a way to make the reference to the parameter relative to containing snippet VOP and not to the Attribute VOP SOP container...
User Avatar
Member
8554 posts
Joined: July 2007
Offline
it's relative to the node that's specified in Evaluation Node Path parameter on Attribute VOP

so while you can make it relative to your Snippet using that parm, you will not be able make it relative to 2+ snippets respectively in the same Attribute VOP at the same time

the reason is also that at the end all VOP nodes contribute to a single VEX code that gets compiled so really all controls should be on Attrib VOP or higher
as all ch() references in that VEX code will be evaluated relatively to just a single node and that's why that control is on the Attribute VOP itself

while technically VOP nodes exist and can hold parameters, historically they aren't supposed to be animated or even considered for placing your controls
nobody can stop you from placing spare parms directly on the snippet node and pointing any Attrib VOP/Wrangle to evaluate them relative to that, but I'd not advise doing that
Edited by tamte - March 5, 2024 02:38:44
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
339 posts
Joined: June 2013
Online
tamte
it's relative to the node that's specified in Evaluation Node Path parameter on Attribute VOP
Hmm right makes sense, similar annoyance with Ramp VOP.

tamte
nobody can stop you from placing spare parms directly on the snippet node and pointing any Attrib VOP/Wrangle to evaluate them relative to that, but I'd not advise doing that
Yeah for now I'll use backticks as a fix, feels hacky but works. Now... if I want access such evaluation path from a VOP with from python, that's not possible right?...

Thanks once again for clarifying things.
User Avatar
Member
8554 posts
Joined: July 2007
Offline
probiner
Yeah for now I'll use backticks as a fix, feels hacky but works.
just remember that injecting parameter values this way (using Hscript or Python below) can't evaluate animated parameters as it essentially hardcodes the value in the code before compilation

probiner
Now... if I want access such evaluation path from a VOP with from python, that's not possible right?...
if you mean replacing backtick Hscript expression that evaluates the parameter with Python
then the trick is to returning the whole snippet code string using Python expression and evaluate the parm values using ch() or hou.Parm.eval() and injecting that in the string before return
Edited by tamte - March 8, 2024 10:54:56
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
339 posts
Joined: June 2013
Online
tamte
probiner
Yeah for now I'll use backticks as a fix, feels hacky but works.
just remember that injecting parameter values this way (using Hscript or Python below) can't evaluate animated parameters as it essentially hardcodes the value in the code before compilation

probiner
Now... if I want access such evaluation path from a VOP with from python, that's not possible right?...
if you mean replacing backtick Hscript expression that evaluates the parameter with Python
then the trick is to returning the whole snippet code string using Python expression and evaluate the parm values using ch() or hou.Parm.eval() and injecting that in the string before return

Sorry for the very late reply tamte, been runnig and let this slide.

I meant to assess what is indeed that high level node that would be sourced from if used ch(). Like presented in this image:


But in Python... like doing node.parent() until it reaches to that higher context VOP SOP. Not sure if Python has a way to figure that out automatically regardless if the snippet is inside a Subnet or HDA.

I figured it in a skivy way with Python's hou.hscriptExpression('opsubpath(".") AND hou.hscriptExpression('opfullpath("."), which when intersected result in the vop full path! `/obj/geo1/attribvop1/`



I was just wondering if there was a more direct way of doing it with Python.
Thanks again for the help!
prb
Edited by probiner - April 21, 2024 18:03:12

Attachments:
houdini_VWvEGWk8nL.png (381.3 KB)
houdini_YD00nSRG9j.png (81.8 KB)

User Avatar
Member
442 posts
Joined: Aug. 2019
Offline
I was just wondering if there was a more direct way of doing it with Python.

node.creator(), which returns the closest parent that isn't in the same context with node.

creator() → Node

Returns the first parent of different type from this node. For simple networks this will be the same as parent(), but if the parent is the same node type, eg, both are SOPs, the process is repeated until a different type is found. This is useful for finding the container node, for example, the Object that a SOP is in, without having to worry about nested SOP networks. Note that SOPs do not always have Objects as parents, however!

But honestly I'd avoid to use Python/Hscript expression as Snippet VOP's code. This kind of "metaprogramming" is bad practice in most cases.
Edited by raincole - April 21, 2024 21:38:06
User Avatar
Member
339 posts
Joined: June 2013
Online
raincole
I was just wondering if there was a more direct way of doing it with Python.

node.creator(), which returns the closest parent that isn't in the same context with node.

creator() → Node

Returns the first parent of different type from this node. For simple networks this will be the same as parent(), but if the parent is the same node type, eg, both are SOPs, the process is repeated until a different type is found. This is useful for finding the container node, for example, the Object that a SOP is in, without having to worry about nested SOP networks. Note that SOPs do not always have Objects as parents, however!

But honestly I'd avoid to use Python/Hscript expression as Snippet VOP's code. This kind of "metaprogramming" is bad practice in most cases.

Thank you, I didn't know about this function. Nice!

Well, as bad as it may be, and I know it can break badly with signatures, there's no other way to reference the parent HDA parameter, right? Even native nodes used backticks for that. Check Import Point Attribute VOP.

Cheers
prb
Edited by probiner - April 24, 2024 09:55:35
  • Quick Links