Communicating with Mari

Mari uses connection ports to communicate with Nuke as well as other programs. Once the command port is set up in the Mari Preferences dialog, described in the Connection Setup section, you can connect to the port and send commands to control Mari.

The way to communicate with Mari is to:

1.   Open the Mari Preferences dialog by navigating to Edit > Preferences.
2.   Select the Scripts tab and set Mari to use port 6100.
3.   Open a python session, for instance, write 'python' in the terminal.
4.   Set up the connection by typing the following:

>>> import telnetlib >>> HOST = "localhost" >>> PORT = 6100 >>> tn = telnetlib.Telnet(HOST,PORT)

Note:  Mari does not execute the commands immediately. Instead, Mari buffers these commands until you send an EOT (end-of-transmission) character.

5.   Send the EOT character by writing the following:

>>> tn.write("\x04")

For example, to create a Perlin noise node in the Node Graph, write the following:

>>> tn.write("ng = mari.geo.current().nodeGraph()\n") >>> tn.write("perlin = ng.createNode('Procedural/Noise/Perlin')\n") >>> tn.write("\x04”)