Jump to content

OpenPort and communicate via Python (Socket)


jonathan.pgagne

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

Link to comment
Share on other sites

  • 1 month later...

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

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...