tagosaku Posted July 16, 2019 Share Posted July 16, 2019 there are 2 nodes, and can we remotely execute a python script by another node, especially def too? For instance, there is a python_target null node. If I click its execute button, it writes C in result as I expect. Then I want to do same thing by a code of another python_remote_control null node. After succeeding controlling remotely, I also like to execute setA() remotely, too. Is that possible? Quote Link to comment Share on other sites More sharing options...
tagosaku Posted July 16, 2019 Author Share Posted July 16, 2019 I know I could write script directly in python_remote_control node import hou a = hou.node('/obj/pipeline/python_target') a.parm('result').set('C') but I would like to know how to control/execute the code of 'python_target' node indirectly Quote Link to comment Share on other sites More sharing options...
Stalkerx777 Posted July 16, 2019 Share Posted July 16, 2019 Nothing is impossible, but this is not a common way of working with Python in Houdini. For geometry manipulation use Python SOP, for sharing your Python code, put it a module, hou.session, or into HDA's Python module. See the docs To achieve exactly what you want: In your python_remote_control: code = hou.node('../target_python').evalParm('code') exec compile(code, "inline", "exec"), globals(), locals() setA() setB() 1 Quote Link to comment Share on other sites More sharing options...
tagosaku Posted July 16, 2019 Author Share Posted July 16, 2019 code = hou.node('../target_python').evalParm('code') exec (compile(code, "inline", "exec"), globals(), locals()) setA() setB() After adding an extra bracket, it worked for a test code now. From now I try to apply it for actual scripts. Thank you, Alex, R !! Quote Link to comment Share on other sites More sharing options...
tagosaku Posted July 16, 2019 Author Share Posted July 16, 2019 (edited) I am using kwargs["node"] or hou.node('.') in order to point out self node. When executing from 'target_python' node, it makes sense to be kwargs["node"] = target_pyhon. However, when executing from python_remote_control node, kwargs["node"] becomes 'python_remote_control node' and code does not work anymore. Do I need to write 2 code versions? In general, I guess python_remote_control node executes 'target_python's code as own self code. Then the code looks up not 'target_python''s parms but python_remote_control node's parameters ?!? Edited July 16, 2019 by tagosaku Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.