Evaluate pdg-attributes in expressions with python script top fails

   3925   4   1
User Avatar
Member
37 posts
Joined: 3月 2014
Offline
Hey guys,

via a Python Script TOP I'm trying to query and evaluate several attributes on “normal”/non pdg-nodes that use pdg-attributes.
But when doing this with classic python hou module functions (Node.Parm.eval() etc.) it seems, the attribute values can't be evaluated.

Example:
Create Wedged Attributes in TOP Net
Reference them with @attribname on a Parameter of a classic Houdini Network Node (e.g.: an Outputpath that has the wegded values in it)
Try to grab the current value (per Work Item) of the Parameter with a Python Script TOP.

In most cases it returns nothing or 0.0 etc. depending on the Data Type.

Please find attached a simple mock up of my setup.

I know how to reference parameter values on current pdg node with
self["parmname"].evaluateString()
etc.. But what would be the right way to reference parameters containing expressions from external Nodes?

Cheers, Michael
Edited by gotchee - 2019年6月5日 06:11:17

Attachments:
pdg_python_eval_attrib_v001.hip (176.0 KB)

User Avatar
スタッフ
585 posts
Joined: 5月 2014
Offline
The best way to do that now would be to channel reference the desired parameter on your TOP node, and evaluate the TOp node parm using the PDG API. All parameters on the TOP node are directly accessible as PDG node parameter via the Python API.

PDG's evaluate method is what makes it possible for the @attributes to work in parameters, since it configures an evaluation context based on the work item you want to evaluate with. That said, it should be possible to provide a wrapper method that can be used to evaluate any parm, including an exteranl one. It's just a matter of exposing it in the API. I've logged an RFE for that issue.
User Avatar
Member
37 posts
Joined: 3月 2014
Offline
Alright…good to know!
Thanks for the workaround and the RFE!

Cheers
User Avatar
Member
3 posts
Joined: 12月 2016
Offline
Hi
Im new to PDG and I have a work%item attribute referenced in the parm using `@attribute_name`. I can see the value in houdini, but when I use the `self.evaluateString()` in a python script is appears to be blank (it only manages to read it if it is a direct value). What method should I use to get the @ expression value?
User Avatar
Member
3 posts
Joined: 12月 2016
Offline
...I found the issue, my predecessor forgot to pass the work_item, which I realised when I found the docs
  • Quick Links