lpjk
lpjk

Reputation: 33

Opening current Nuke script into NukeX using Python

What I am trying to do is to create a Python script that will allow me to create a custom UI tab into Nuke 10.0v3 which will allow me to click on it while I have a file up and it will open that file into NukeX. Below are the two Python scripts that I have created.

1.menu.py

import nuke
import os
import sys

toolbar = nuke.menu('Nuke')
BMenu = toolbar.addMenu('Nukex')

import switchtonukex
BMenu.addCommand('switchtonukex', 'switchtonukex.main()')

2.switchtonukex.py

import nuke
import os
from glob import glob

def main(node=False):
    if  nuke.message('Nothing selected. Select a node and try again.'):
        nuke.createNode('Blur')

    import subprocess
    nukeProcess = subprocess.Popen(["C:\ProgramFiles\Nuke10.0v3\Nuke10.0.exe", "--nukeassist", "filePath = nuke.getFilename('Set Output Directory')"])

Let's say I have vidfile1 opened up in NUKE Studio and once I click on a node, I will then click on the NukeX toolbar tab I created and this will then open up NukeX and open up the viffile1. However I don't want the code to be based on any specific file as I have many that require this process.

The result I get from my script is that when I have a Nuke script open in NUKE Studio, I am able to click on the NukeX tab (in UI) and it will open up NukeX. However it won't load the current onto it.

Upvotes: 2

Views: 1181

Answers (1)

Jacob Martinez
Jacob Martinez

Reputation: 11

In your example you are passing the --nukeassist arg. I think you should be passing the --nukex arg (list of args)

Also, if this script will be running from within nuke then you can just pass in nuke.root().name() which will return the path to the currently opened file(or "root" if unsaved).

nukeProcess = subprocess.Popen(["C:\Program Files\Nuke11.3v2\Nuke11.3.exe", "--nukex", nuke.root().name()])

Upvotes: 1

Related Questions