Skip to content

sisoe24/nukeserversocket

Repository files navigation

1. nukeserversocket README

Main Build Pre Release Last commit license

issues pull-request Codacy Badge Codacy Badge

x x x

NukeTools

Important

You can now execute code for Houdini! See installation notes

A PySide2 plugin for executing Python/BlinkScript remotely in Nuke from any network client, supporting multiple connections. Compatible with both Nuke and Houdini.

1.1. Client applications

Client applications that use nukeserversocket:

1.1.1. Create a custom client

You can create a custom client in any programming language that supports socket communication. The client sends the code to the server, which then executes it in Nuke and sends back the result. For more information, see the wiki page

# ... your socket code
data = {
    "text": "print([n.name() for n in nuke.allNodes()])",
    "file" : "path/to/file.py",
    "formatText": "0"
}
s.sendall(bytearray(json.dumps(data), 'utf-8'))
data = s.recv(1024)
s.close()

nodes = json.loads(data.decode('utf-8').replace("'", '"'))
for node in nodes:
    print(node)

1.2. Installation

1.2.1. Nuke

1.2.1.1. Using NukeTools (Recommended)

If you use Nuke Tools, simply run the command Nuke: Add Packages to install.

1.2.1.2. Manual Installation

  1. Download from releases page or clone from GitHub
  2. Place in ~/.nuke or your preferred directory
  3. Add to your menu.py:
from nukeserversocket import nukeserversocket
nukeserversocket.install_nuke()

1.2.2. Houdini Installation

Note: These instructions assume NukeServerSocket was installed via NukeTools in $HOME/.nuke/NukeTools. If installed manually, adjust paths accordingly. Also, you dont need to have Nuke installed to make this work.

1.2.2.1. HOUDINI_PACKAGE_DIR

Add to your shell configuration:

Mac/Linux (.bashrc or .zshrc):

export HOUDINI_PACKAGE_DIR=$HOME/.nuke/NukeTools/nukeserversocket

Windows:

  • Add HOUDINI_PACKAGE_DIR to Environment Variables (start menu)
  • Set value to %USERPROFILE%\.nuke\NukeTools\nukeserversocket

Note

For CMD/PowerShell users, refer to Microsoft's documentation on environment variables for alternative setup methods.

1.2.2.2. Using Houdini Preferences

  1. Navigate to your Houdini packages directory:

    • Windows: C:/Users/YourName/Documents/houdiniXX.X/packages
    • Mac: ~/Library/Preferences/houdini/XX.X/packages
    • Linux: ~/houdiniXX.X/packages
  2. Create nukeserversocket.json:

{
    "hpath": [
        "$HOME/.nuke/NukeTools/nukeserversocket/nukeserversocket/controllers/houdini"
    ],
    "env": [
        {
            "PYTHONPATH": "$HOME/.nuke/NukeTools/nukeserversocket"
        }
    ]
}

1.2.3. Houdini Notes

The Houdini execution method differs from Nuke's. Nuke relies on its internal script editor, while Houdini uses Python's exec. The Nuke controller also used to rely on exec, but I removed that functionality because it didn't work in all scenarios. If you have better suggestions, let me know!

1.3. Usage

Execute Code

  1. Open the nukeserversocket panel inside Nuke, and start the server by clicking Connect.
  2. You can now send code from Visual Studio Code with Nuke Tools or any other method you prefer.

Note

If you receive a message: "Server did not initiate. Error: The bound address is already in use", change the port to a random number between 49152 and 65535 and try again.

1.4. Settings

Note

Only the server timeout setting applies to Houdini.

You can access the settings from the plugin toolbar.

  • Mirror To Script Editor: Allows mirroring the input/output code to the internal script editor.

  • Format Text: The script editor output window will receive a formatted version of the code result. The available placeholders are:

    • %d: Time
    • %t: The code result
    • %f: The full file path
    • %F: The file name
    • %n: A new line

    Format Text Example: %d - %t%n will output 12:00:00 - Hello World! in the script editor output window.

  • Clear Output: The script editor output window will clear the code after each execution.

  • Server Timeout: Set the Timeout when clicking the Connect button. The default value is 10 minutes.

1.5. Known Issues

  • Changing workspace with an active open connection makes Nuke load a new plugin instance with the default UI state. So it would look as if the previous connection has been closed, whereas in reality is still open and listening. To force close all of the listening connections, you can:
    • Restart the Nuke instance.
    • Wait for the connection timeout.

1.6. Compatibility

Should work everywhere PySide2 and Python 3 work.

1.7. Python2.7

If you are using Python 2.7, you can still use the previous version of the plugin <=0.6.2 from the releases page

1.8. Contributing

If you have any suggestions, bug reports, or questions, feel free to open an issue or a pull request. I am always open to new ideas and improvements. Occasionally, I pick something from the Projects tab, so feel free to check it out.