@pdg_input only returns first input

   1664   6   0
User Avatar
Member
60 posts
Joined: 7月 2014
Offline
I'm trying to query my inputs that are coming from a partition sop. I have a partition that has 5 files in it, but when I run @pdg_input in a python expression top it only returns the first input. This seems like a bug to me?

I've tried programmatically getting the inputs, but I can't figure out the syntax to make it work?
User Avatar
スタッフ
600 posts
Joined: 5月 2014
Offline
@pdg_input is the same as @pdg_input.0, which is also the same as how it works for @attribs in SOPs.

You can use @pdg_input.2 to access the value at index=2, for example. Or, you can use the HScript function pdginput()[ which takes three arguments, one of which is the index: https://www.sidefx.com/docs/houdini/expressions/pdginput.html [www.sidefx.com]
Edited by tpetrick - 2023年11月10日 20:00:01
User Avatar
Member
60 posts
Joined: 7月 2014
Offline
Thanks for that clarification. What if I want to get a list of all the inputs, because they are changing so I don't always know how many there are?
User Avatar
スタッフ
600 posts
Joined: 5月 2014
Offline
In that case, pdginputvals(..) returns the list of all inputs as a space-separated string: https://www.sidefx.com/docs/houdini/expressions/pdginputvals.html [www.sidefx.com]

And, you can also use pdginputsize(..) to get the actual number of input files with a particular tag: https://www.sidefx.com/docs/houdini/expressions/pdginputsize.html [www.sidefx.com]
Edited by tpetrick - 2023年11月14日 12:51:09
User Avatar
Member
60 posts
Joined: 7月 2014
Offline
How do I run those in python?
User Avatar
スタッフ
600 posts
Joined: 5月 2014
Offline
If you're using Python, you can use the Python API instead of HScript. There's an equivalent function in Python for all of the things available in HScript, for example: https://www.sidefx.com/docs/houdini/tops/pdg/WorkItem.html#inputFilesForTag [www.sidefx.com]

So for example from a Python parameter expression, you can use pdg.workItem().inputFilesForTag("file") to get a list of all input files, or pdg.workItem().inputFilesForTag("file/image") for all input image files.

If you're using a Python Script node, which already has the work item stored to a work_item local variable, you can use: work_item.inputFilesForTag("file").
Edited by tpetrick - 2023年11月14日 13:36:18
User Avatar
Member
60 posts
Joined: 7月 2014
Offline
Amazing, that works perfectly. Thank you!
  • Quick Links