Modify attributes via Python Script node

   1919   2   1
User Avatar
Member
22 posts
Joined: Feb. 2017
Offline
I can't figure out how to modify attributes in a top network via a python script node. I understand how to read this information but not how to write it back. See the example setup below.

I'm a complete pdg/TOPs noob and have only done very little with python in Houdini yet, so this is probably a completely obvious thing for others.

Any help would be much appreciated.

Attachments:
attribModify.png (56.5 KB)

User Avatar
Member
544 posts
Joined: Sept. 2012
Offline
Hi there,

You can just write something like:

work_item.data.setInt(“blueCorrect”, 1, 0)

You can get the PDG API if you search for “pdg” in the help. Note also the little drop down on the side, these are quite helpful - they contain some sample code for common operations.

Attachments:
pdg_forum_help_modify_workitem_from_pythonscript.png (58.6 KB)
pdg_modify_workitem_from_pythonscript.hip (77.6 KB)

- Ken Xu
User Avatar
Member
22 posts
Joined: Feb. 2017
Offline
Thank you very much for the input, I would never have found that myself (well, I already tried the whole day ). The drop down on the right only has 2 very short snippets, maybe it's worth adding more in the future.

The hint for the pdg api documentation is very useful. I looked specifically for python node related docs and didn't find any clue how to access data. I also, for some reason, didn't see the link to the “Python API” or didn't think it was related. Thanks again for the pointer!
  • Quick Links