Skip to content

Instantly share code, notes, and snippets.

@JustinPedersen
Created February 4, 2022 08:36
Show Gist options
  • Save JustinPedersen/10af6b4a21eb522c1220f0229fe3149d to your computer and use it in GitHub Desktop.
Save JustinPedersen/10af6b4a21eb522c1220f0229fe3149d to your computer and use it in GitHub Desktop.
import socket
HOST = '127.0.0.1' # the local host
PORT = 54321 # The same port as used by the server
ADDR = (HOST, PORT)
def send_command():
client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
client.connect(ADDR)
command = 'cmds.polyCube()'
message = command
client.send(str.encode(message))
data = client.recv(1024) # receive the result info
client.close()
print(data)
if __name__ == '__main__':
# Run this within Maya to open the ports. The port can be any 5 digits
"""
import maya.cmds as cmds
cmds.commandPort(name=":54321", sourceType="python")
"""
send_command()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment