|On this page|
Houdini does not open an RPC port by default. You must start the RPC server in Houdini before you can connect to it from another computer:
import hrpyc hrpyc.start_server()
By default, it listens on port
18811. To set the port number, call
The RPC server will run in a separate thread, waiting for RPC calls from other processes. If want the server to run in the main thread, call
Then, in a Python session in another process or on another computer (for example, in a Maya Python shell), connect to the RPC server:
connection, hou = hrpyc.import_remote_module()
connectionis an object representing the network connection. If this object is deleted or goes out of scope and is garbage collected, the connection will be closed, so you should keep a reference to it as long as you want the connection to stay open.
houis an object that acts like the
houpackage in Houdini. You use it as if you had imported
hythonor a Python shell in Houdini:
node = hou.node("/obj/sphere1") node.parm("scale").set(2.0)
Please read the notes below for important information.
hrpycis a very thin wrapper around the rpyc library. It is limited to the capabilities provided by the third-party library.
The library works by proxying objects and functions. When the remote side calls a function or method, the proxy object sends the request across the network and the Houdini side sends back the result.
rpycproxy object do not support Python operators (the library does not proxy special methods such as
__eq__). For example, you can’t compare two
hou.Nodeproxies on the remote side to see if they are the same node, because the proxies do not support the equality operator:
# This will fail node1 == node2
Instead you should rework your code so you compare plain Python results of function/method calls instead of the proxied objects themselves:
# This will work node1.path() == node2.path()
The RPC server does not do any authentication. If you want to use RPC, you should ensure your IT setup (for example, a firewall) prevents unauthorized access to the server port.