Skip to content

About

API to be able to use ComfyUI nodes within nuke, only using the ComfyUI server

Resources

Stars

0 stars

Watchers

0 watching

Forks

 
 

Repository files navigation

ComfyUI for Nuke — markitzeroo fork

API to use ComfyUI nodes inside Nuke, talking to a ComfyUI server.

This is a personal fork of vinavfx/ComfyUI-for-Nuke with a batch of fixes that make real-world workflows actually import and run, plus initial support for ComfyUI's v3 node API (COMFY_DYNAMICCOMBO_V3, COMFY_AUTOGROW_V3).

All fixes live on the fix/v3-api-and-import-robustness branch — main is intentionally kept identical to upstream so you can pull updates from vinavfx without conflicts.

What this fork fixes

  • Auto-connect during import is disabled. Upstream create_node interactively chains every new Group to whatever node Nuke had selected when it was created. During a workflow import this pollutes inputs and blocks the subsequent wire pass — JSON node order suddenly mattered, and some workflows imported broken while logically identical ones imported fine. A module-level disable_auto_connect flag held only for the duration of import_workflow neutralizes this.
  • force_output is stamped automatically during the wire pass, read from each link's source_slot in the JSON links array. Eliminates the "Connected to node with duplicate outputs, Connect now?" prompts for sources like ApplyAdvancedControlNet (positive+negative, both CONDITIONING) or ImageResizeKJ (width+height, both INT).
  • Stale node cache is cleared. update_menu.update() now wipes comfyui_nodes before refilling. Without this, nodes renamed or removed on the server kept their old templates in Nuke memory, and workflows referencing the old name spawned ghost groups from the stale template instead of falling to NoOp + "not installed" warning.
  • Node rename alias map. Workflows authored against legacy node names transparently retarget to the current type. Initial entry: OpenAIGPTImage2 → OpenAIGPTImageNodeV2. Extend update_menu.NODE_ALIASES as you hit more renames.
  • ComfyUI v3 node API support — COMFY_DYNAMICCOMBO_V3 and COMFY_AUTOGROW_V3:
    • DynamicCombo (e.g. OpenAIGPTImageNodeV2.model) is flattened into a plain COMBO over the option keys + the union of all per-option sub-inputs.
    • Autogrow lists (e.g. images → image_1..image_16) expose the first 4 template slots as optional inputs. Tune AUTOGROW_EXPOSE_COUNT in update_menu.py.
    • v3 nested ids use dots (model.images.image_1), which Nuke knob names can't contain — encoded as __ and translated back to . when building the prompt.
  • UTF-8 file IO in python_util/util.py. Workflow JSONs containing any non-ASCII byte (em-dashes in notes, accented model paths, emoji) no longer crash with UnicodeDecodeError on Windows where the default codec is cp1252.
  • Could not set knob X popup → stdout log. Schema mismatches no longer block import with a modal — they print to Script Editor as [c2n] could not set knob ... and the import continues.
  • mykey.txt API key injection. connection.py and run.py read a gitignored src/mykey.txt and pass it as api_key_comfy_org in extra_data for Partner / ComfyUI API nodes. Drop a one-line file with your key, never commit it.

Tested against

  • ComfyUI 0.21.1
  • Nuke 17.0v2 (Windows 11)
  • ComfyUI workflow format version: 0.4, frontendVersion: 1.42.x – 1.43.x

Should work on Nuke 11+ and any ComfyUI ≥ 0.3 in principle (the v3 schema flattening kicks in only when the server actually emits v3 types, so older nodes go through the original code path unchanged).

Requirements

  • Nuke 11 or higher.
  • websocket-client Python library (installed into Nuke's Python — see step 3 below).
  • A running ComfyUI server (local or remote).
  • ComfyUI-VideoHelperSuite custom node (needed to load images and sequences).
  • ComfyUI-HQ-Image-Save custom node (if you want to work in EXR).

Installation

1. Clone the fork into your Nuke folder

⚠️ The repo uses git submodules (python_util, nuke_util). git clone alone leaves those folders empty and the plugin will fail to import. You must init submodules, or use --recurse-submodules.

⚠️ GitHub's "Download ZIP" button does not include submodule contents — don't use it. Clone with git.

cd ~/.nuke                           # Linux/Mac
cd "C:\Users\<username>\.nuke"        # Windows

git clone --recurse-submodules -b fix/v3-api-and-import-robustness \
  https://github.com/markitzeroo/ComfyUI-for-Nuke.git comfyui2nuke

If you already cloned without --recurse-submodules or are switching to the fix branch from main:

cd comfyui2nuke
git checkout fix/v3-api-and-import-robustness
git submodule update --init --recursive

The python_util submodule points to markitzeroo/python_util on its fix/utf8-encoding branch — the recorded commit pointer pulls the right code automatically once submodules are initialized.

2. Install websocket-client into Nuke's Python

Adjust the Nuke version to whatever you have installed:

# Linux/Mac
/usr/local/Nuke17.0v2/python3 -m pip install websocket-client

# Windows (Run cmd as Administrator)
"C:\Program Files\Nuke17.0v2\python.exe" -m pip install websocket-client

If you installed websocket-client as a non-root user (in ~/.local/...), add this to your Nuke menu.py before the comfyui import block so Nuke can find it:

import os, sys, nuke
nuke.pluginAddPath('{}/.local/lib/python{}.{}/site-packages'.format(
    os.path.expanduser('~'), sys.version_info.major, sys.version_info.minor))

3. Wire the plugin into menu.py

Add these two lines to your Nuke menu.py:

import comfyui2nuke as comfyui
comfyui.setup()

4. Configure ComfyUI location

Open settings.py and set:

COMFYUI_DIR = 'C:/ComfyUI/ComfyUI/'      # absolute path to ComfyUI install
URL         = 'localhost:8188'            # or 'host:port' of remote server

Or set the env vars NUKE_COMFYUI_DIR and NUKE_COMFYUI_URL before launching Nuke and leave settings.py alone.

5. (Optional) API key for Partner / ComfyUI API nodes

If you use Partner nodes (OpenAI, Anthropic, Veo, Sora, Kling, etc.) that need a api_key_comfy_org:

  1. Create the file src/mykey.txt inside the plugin folder.
  2. Put your API key on a single line, save.
  3. That's it — connection.py reads it on every prompt submission and injects it into extra_data.

The file is gitignored, will never end up in commits.

6. Start the ComfyUI server

cd C:/ComfyUI/ComfyUI
python main.py

Open Nuke. You should see a ComfyUI menu in the Nodes menu. First time around it will populate from the server's object_info. From then on you can import workflows via Nodes → ComfyUI → Import Workflow.

Updating

Pull upstream changes from vinavfx into your fork

git fetch upstream
git checkout main
git merge upstream/main              # main stays identical to upstream
git push origin main

Then rebase the fix branch on the new main if you want:

git checkout fix/v3-api-and-import-robustness
git rebase main
git push --force-with-lease origin fix/v3-api-and-import-robustness

Refresh node templates after updating a ComfyUI custom node

In Nuke: Nodes → ComfyUI → 🔄 Update all ComfyUI. This clears the cache and re-reads object_info from the server. Restart Nuke if a menu item still feels stuck.

Tips (preserved from upstream)

  1. When connecting any image or roto from Nuke, the FrameRange of the output is the batch size that ComfyUI receives.
  2. To work with pixel values >1 or <0, set the SaveEXR node's tonemap knob to linear.
  3. Latent operations only accept dimensions that are multiples of 8. Insert the MultipleOf node before the latent stage, and use its "create restore node" button to undo the resize after inference.
  4. To load every ComfyUI node at Nuke startup, set UPDATE_MENU_AT_START = True in settings.py.
  5. For static branching inside a ComfyUI graph use SwitchAny; otherwise use ComfyUI's own switches.
  6. To run ComfyUI on a different machine, share the install directory over the network and set COMFYUI_DIR to the mapped path.

Troubleshooting

Symptom Likely cause Fix
ImportError: cannot import name 'jread' at startup Submodules not initialized git submodule update --init --recursive
Workflow imports with broken / missing connections Old version of the plugin (no disable_auto_connect) Make sure you're on the fix/v3-api-and-import-robustness branch
Imported node has only a fraction of expected knobs (model, n, seed and nothing else for OpenAIGPTImageNodeV2) Server's object_info is stale Restart ComfyUI server, then 🔄 Update all ComfyUI in Nuke
Could not set the knob 'X' value for this node 'Y' ! popup Pre-fork build — fork routes this to stdout instead Ensure you're on the fix branch
'NoneType' object has no attribute 'shape' from KSampler at runtime ControlNet image branch is empty / wrong ControlNet model Check ControlNet model is the ProMax variant; verify image chain reaches ApplyAdvancedControlNet.image
OpenAIGPTImage2.execute() got an unexpected keyword argument 'model.image_1' Plugin built with old (incomplete) v3 prefix path Ensure you're on the fix branch (3-level prefix model.images.image_1)

Credits

About

API to be able to use ComfyUI nodes within nuke, only using the ComfyUI server

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages