Jump to content
Sign in to follow this  
jonathan.pgagne

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:

1-cmds.commandPort(name='localhost:7555')
2-
client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
client.connect(('127.0.0.1', 7555))
c = ‘python(“cmds.polySphere()”);’
client.send(c)

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

Anyone has some examples?

Thanks
Jonathan

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)
    s.close()
    return res

 

But consider using hrpyc instead for general interaction.

http://www.sidefx.com/docs/houdini/hom/rpc

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  

×