How to access current cook value of an attribute in Python?

   808   3   0
User Avatar
Member
20 posts
Joined: Aug. 2017
Offline
I would like to check current cook value of a wedge attribute in a Python expression.

The same way that we use `@pdg_index` in string parameters etc. but this time we'd like to grab that value in a script. How can I do that?
User Avatar
Member
874 posts
Joined: Oct. 2008
Offline
There's got to be an easier way but you can always make a parm and read it from there.
--
Jobless
User Avatar
Staff
596 posts
Joined: May 2014
Offline
You can access the active work item using pdg.WorkItem() in a Python Expression, and use that to look up the index, attribute values, etc. There's an example in the documentation for the PDG Python module: https://www.sidefx.com/docs/houdini/tops/pdg/index.html#functions [www.sidefx.com]

The next release also has a top-level pdg.attrib(..) function that mirrors the HScript equivalent.
User Avatar
Member
20 posts
Joined: Aug. 2017
Offline
@tpetrick Amazing! Thank you! Just a small correction: the actual function is pdg.workItem() (lowercase 'w'), I got stuck for a while before I realized. Thanks for linking the docs.

For every solution with a spare parameter there's always another secret one that's much cleaner.
  • Quick Links