Nested PDG graphs

   2875   9   4
User Avatar
Member
9 posts
Joined: Sept. 2016
Offline
Hi guys. I have a situation. I have a hda that has topnet inside of it, takes one asset as an input and spits out some geometry. Everything fine with it. Then there is another hda with a topnet inside of it as well. There I'm looping through bunch of different assets and I'm using pdgattributes() to get filepaths and folders as inputs for that first hda. But I when I'm trying to cook top-level graph I get a warning in the inside-level topnet ‘No work item to use when evaluating PDG attribute access’

So I'm wandering, is it even possible to use one topnet inside another one. Unfortunately I cant attach any files to show you my problem
User Avatar
Member
11 posts
Joined: April 2019
Offline
I'm having a similar situation – I've put together a TOP HDA, and I'm getting that same error. I have a parameter on the HDA set to `@attrib_name`, where attrib_name is a string attribute. I'm referencing that paramter on a Python script node inside the HDA, but I get the warning, and the attribute isn't evaluating.

Is this a bug, or a misunderstanding on how nested graphs should work in TOPs?
Brian Silva
Pipeline @ Locksmith Animation
FX / Lighting / LookDev Artist
User Avatar
Member
603 posts
Joined: Sept. 2016
Offline
I don't see a warning when I try to repro this setup. Can you attach your hip and hda here (or log a support question if you prefer).
Edited by chrisgreb - April 7, 2020 09:22:29
User Avatar
Member
11 posts
Joined: April 2019
Offline
Hey Chris,

I've attached a very simple setup to demonstrate.

I'd imagine it has something to do with the fact that the parameter on the subnet gets evaluated by a call in the Python script inside the subnet (subnet/py__subnet_foo).

Is this expected to work correctly? Or is there a better way to do it?

I'm on Houdini 18.0.416.

Thanks!

Attachments:
nested_TOP_graphs_issue.hip (71.3 KB)

Brian Silva
Pipeline @ Locksmith Animation
FX / Lighting / LookDev Artist
User Avatar
Staff
585 posts
Joined: May 2014
Offline
The issue is you're calling foo_val = hou.parm(“../value”).eval(). That parameter has an @attribute access in it so you need to tell the parameter which work item to evaluate that expression with:

with work_item.makeActive():
    foo_val = hou.parm("../value").eval()

Typically, parameters involved in PDG script code are evaluated using the PDG API not through HOM. All parameters on the TOP node itself are accessible through the underlying PDG node's API. For example, for a parameter on the Python Script node itself, you could do:

value = self['newparameter'].evaluate(work_item)

In a Python Script node, the self variable is an instance of this class: https://www.sidefx.com/docs/houdini/tops/pdg/Node.html [www.sidefx.com] and the work_item variable is an instance of this class: https://www.sidefx.com/docs/houdini/tops/pdg/WorkItem.html [www.sidefx.com]
Edited by tpetrick - April 9, 2020 11:18:07
User Avatar
Member
11 posts
Joined: April 2019
Offline
That's great info, thanks!

So, if I have all the parameters on the Python script node inside the subnet, and they channel-reference parameters on the subnet node, will those be evaluated first/correctly before the generation phase?

And then, even using the PDG API, it looks like I should still use the context manager, correct? i.e.:

with work_item.makeActive():
    value = self['parmname'].evaluate(work_item)
Brian Silva
Pipeline @ Locksmith Animation
FX / Lighting / LookDev Artist
User Avatar
Staff
585 posts
Joined: May 2014
Offline
You don't need the context manager in that case because the PDG API allows you to pass the work item directly to the parm evaluate call. The context manager exists so that you can evaluate a parm/list of parms using the HOM API, and still set the active work item for any expressions in those parms.
Edited by tpetrick - April 9, 2020 13:24:49
User Avatar
Member
11 posts
Joined: April 2019
Offline
Excellent, thank you!
Brian Silva
Pipeline @ Locksmith Animation
FX / Lighting / LookDev Artist
User Avatar
Member
11 posts
Joined: April 2019
Offline
Hello!

I'm still having a few little troubles with this. In the Python script I'm using the "self“ dictionary on the PDG node, as suggested. For the most part, this works fine. On the Python TOP node, I have spare parameters added, with a nested multiparm. These parms channel-reference to the containing TOP subnet HDA.

So, one of the parameters in the nested multiparm is called ”fieldname#_#". Whenever I open the scene fresh and try to generate or execute the TOP graph, I get this error:

Error on child node /obj/subnet_name/py_node:
subnet_name_py_node failed to run script: Traceback (most recent call last):
File “subnet_name_py_node”, line 53, in <module>
IndexError: Invalid port name: fieldname3_1

If I delete that multiparm item and re-add it, the graph then executes fine. Is this a case where I need to use the context manager and hou.parm references, or is this expected to work at generation time too?

Thanks!
Edited by bsilvaLS - April 28, 2020 10:25:41
Brian Silva
Pipeline @ Locksmith Animation
FX / Lighting / LookDev Artist
User Avatar
Member
603 posts
Joined: Sept. 2016
Offline
Could you please attach a repro here on in a support ticket so we could take a look ?
  • Quick Links