Promoting multiparm breaks Python menu scripts

   1974   5   1
User Avatar
Member
183 posts
Joined: Dec. 2011
Offline
So I have a multiparm on an asset that contains menus that are generated via python with a script like this…

hou.pwd().hm().generateContextMenu(kwargs['parm'], hou.pwd())

However if I put the asset inside a subnet and then try to promote the multiparm by using the ‘from nodes’ tab, I get an error saying that no method called ‘generateContextMenu’ is found in the python module. Now if I try the same thing with an identical parameter on the asset that is not inside a multiparm everything works like a charm.

Is there a way around this issue? Am I doing something wrong.
User Avatar
Member
7733 posts
Joined: Sept. 2011
Offline
hou.pwd().hm() refers to this node's python module. If you promote it to another node, then it won't be called from the node with the module you want anymore.
User Avatar
Member
183 posts
Joined: Dec. 2011
Offline
Is there a way to make sure that the code points to the asset with the python module whether or not the parameter has been promoted?

Also your reasoning doesn't seem to explain why only parameters in a multiparm would have this issue.
User Avatar
Member
7733 posts
Joined: Sept. 2011
Offline
The path of evaluation could be different, I'm not really sure. But you can hard code the path to the node with the HDA module. Or instead of a path to a node, you can supply a node type with hou.nodeType(), and fetch the hdaModule from the NodeType object.
User Avatar
Member
183 posts
Joined: Dec. 2011
Offline
Okay, well for now I'll just have to rewrite the paths to point to the correct node after promoting the parameters I guess.
User Avatar
Member
183 posts
Joined: Dec. 2011
Offline
So after some more research on the topic of why this is happening, it seems jsmack's comments are incorrect according to the documentation.

hou.pwd() documentation [www.sidefx.com]

It seems that the parameter containing the call to .pwd is returned rather than the parameter of the node that references the original parameter in order to maintain relative referencing. Seems this might be an issue with multiparms after all.

The only solution I have found is to duplicate the code on the referencing parameter to point to the HOM of the node it is referencing. Ugly, but functional-ish.
Edited by NFX - Feb. 6, 2018 14:26:43
  • Quick Links