Set spare parameters from Python Processor Node

   2323   4   0
User Avatar
Member
209 posts
Joined: Nov. 2010
Offline
Hi,

Is it possible to set spare parameters value from Python Processor or any other PDG Node?

Thanks
Ostap
Edited by Ostap - May 19, 2019 18:45:16
User Avatar
Staff
585 posts
Joined: May 2014
Offline
Yep, it's possible to add spare parms to any TOP node. For example, in Python Processor code you can evaluate any params on the node, including spare parms, like so:

# Evaluate a parameter with no work item
self['example'].evaluateInt()

# Evaluate at a specific index
self['example'].evaluateInt(2)

# Evaluate the parameter against a specific work item. This is needed if you want @attribute expressions to be evalauted.
new_item = itemholder.addWorkItem()
self['other_example'].evaluateString(new_item)

# Specified work item and index
self['other_example'].evaluateString(new_item, 1)
User Avatar
Member
209 posts
Joined: Nov. 2010
Offline
But how to set the values? I found only how to evaluate the parms.
User Avatar
Staff
585 posts
Joined: May 2014
Offline
The code in the Python Processor node executes during the cook, within a context that access to the underyling PDG node/API. You can look up the corresponding TOP and set parameters on it like so:

import hou

node_id = self.customId
top_node = hou.nodeBySessionId(node_id)
top_node.parm("newparameter").set("test")

However this isn't recommended, because it means that you'll be modifying the TOP node from PDG, during the cook. What are you trying to do that needs parms to modified during the cook?
User Avatar
Member
209 posts
Joined: Nov. 2010
Offline
In my case, it is for data visual representation without clicking on workitems.
I agree that we need to be careful with this possibility but anyway, nice that we have this option.
  • Quick Links