Jump to content
Sign in to follow this  

OpenPort and communicate via Python (Socket)

Recommended Posts

Hey guys,

I saw there is a hscript command ‘openport’, but I didn't find example on how to communicate with houdini via python.

Here's what I need to do:

1-Open a port, from localHost, within houdini session.
2-From an external python interpreter, execute houdini python commands, using local port.
IE: hou.node('/obj').createNode('geo')

Here's how I can do this in maya:

client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
client.connect(('', 7555))
c = ‘python(“cmds.polySphere()”);’

Does anyone know if it's possible to this in houdini?

Anyone has some examples?


Share this post

Link to post
Share on other sites

Exactly the same would be in Houdini:

def houdini_send(msg):
    import socket
    HOST = "localhost"
    PORT = 12100
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.connect((HOST, PORT))
    s.send(msg + '\n')
    res = s.recv(1024)
    return res


But consider using hrpyc instead for general interaction.


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this