KnobScripter v3.1
This location is for Registered Users Only.
Perhaps you need to login or register.
14.0, 13.2, 13.1, 13.0, 12.2, 12.1, 12.0, 11.3, 11 or later
Linux, Mac, Windows
KnobScripter v3.1 (or KS3) is a full script editor for Nuke that can script python on .py files and knobs as well as BlinkScript, with all the functionality from the default script editor in Nuke plus syntax helpers, predictions, snippets and other handy features.
KS3 is the next major step for this tool, and it features a greatly optimized code, Python 3 compatibility, BlinkScript mode, a Code Gallery and many other features and fixes.
KnobScripter was designed as a simple python script editor for Nuke, and its main goal is to let you interact with Nuke’s python API in a more pleasant way than Nuke’s default methods. It doesn’t intend to replace a fully featured IDE, but it proves enough for most common python tasks and quick work with snippets, basically anything that needs quick interaction with Nuke’s python console.
With this in mind, I focused its development in the aspects that I love about IDEs regarding efficiency (such as syntax helpers), in covering everything the default Script Editor in Nuke currently offers, and last but not least, in covering the python aspects of Nuke that are generally tedious, such as adding python or blink code to nodes/knobs.
Full scripting mode for .py files.
You can create, browse, modify or toggle between python files and folders.
Node editing mode.
In node mode, you can script directly on python buttons or callback knobs, as well as BlinkScript.
Snippets.
Snippets are short codes you can assign to longer pieces of code, so that by writing the short code and pressing tab you’ll get the long code.
You can also choose where you’ll want your cursor to appear with the convenient $$.
Code Gallery.
The Code Gallery is a new way to store and browse through codes that you might want to revisit many times as reference.
It includes a basic system of archiving. Then you can quickly browse and sort through the different codes you saved, while folding categories and reading descriptions.
Python output console.
Same as the one from Nuke’s default script editor, where you can execute any code and read the python output log.
Find-Replace.
A proper find-replace widget as you’d expect in a python editor.
Syntax highlighting, line numbers, auto-intending, auto-completer...
You can choose between two code highlighting styles (including one inspired by sublime’s popular Monokai theme).
Auto-completions on tab read from the available modules and the actual functions and variables in your script.
Installation:
A. Fresh install
- Copy the KnobScripter folder and paste it somewhere in your Nuke plugin path. For example, inside Users/YourUser/.nuke directory.
- Open with a text editor the file menu.py that lives next to your KnobScripter folder, or create one if it doesn’t exist.
- Add the following line:
import KnobScripter - Restart Nuke.
B. Updating KnobScripter
- Replace the KnobScripter folder with the updated one.
- Restart Nuke.
Update Log:
KnobScripter v3.1 - 15 Jan 2024
New features:
- Nuke 14 & 15 compatible.
- Ctrl + +/- to change font size on both editor and output console.
- Multi-line codes can be run on knobs as well (thanks pancho!)
Bug fixes and enhancements:
- Fixed character movement error (thanks itaki!)
- Removed python package ‘six’ (thanks itaki!)
- Esc behaviour limited to floating panels only (thanks pancho!)
- Other little bug fixes.
KnobScripter v3.0 - 25 April 2022
New features:
- Blinkscript mode.
- Compatible with python 2 and 3 (Nuke 13+) and Win/Mac/Lin.
- Code Gallery.
- Fully redesigned Snippets, with a new Snippet Editor, default snippets and a simplified workflow.
- Preferences Panel redone, and new settings added.
- Keyword Hotbox for double clicking on keywords and showing alternatives.
- Storing the knob and .py editor state, for quickly jumping back to your edit point on new KnobScripters.
- New code helpers such as Ctrl/Cmd + and Ctrl/Cmd - for changing font size.
- Method placeholders.
- Parentheses wrappers.
Bug fixes and enhancements:
- Whole code refactored, and improved py import scheme.
- Fixed predictor tab with custom words in Nuke 13.
- Fixed backspace crash on indented lines.
- Snippet behaviour improvements.
- Fixed syntax highlighting errors.
KnobScripter v2.4 - 7 December 2020
New features:
- Run in Context mode.
- “Grab current dimensions” button.
Bug fixes and enhancements:
- Improved modal window behavior (thanks Jed Smith!).
- Ctrl+Backspace now clears output log.
- Improved how Nuke’s Script Editor widgets are found (thanks Jed Smith!)
- Modified (*) property now shows properly on the knob dropdown.
- Picker (“change to Node”) crashing fixed.
- Unicode encoding works with both .py scripts and nodes now.
- Compatible with Nuke 12.2
- Add snippet button scrolls to top.
KnobScripter v2.3 - 12 December 2019
Bug fixes and enhancements:
- Fixed bracket and brace closing behaviour.
- Added QStringListModel compatibility on Nuke 12.
- Symlink error hidden on Windows.
KnobScripter v2.2 - 24 August 2019
Bug fixes and enhancements:
- Variable placeholders error fixed (bug introduced on v2.1).
- PySide import switch including Qt.
KnobScripter v2.1 - 10 August 2019
New features:
- New Sublime color style. You can now choose between sublime or Nuke style in the Preferences.
- Font selector in the Preferences, where you can set any available font.
- Option to display the knob labels too (and not only names) on the knob dropdown.
- Now accepting special characters (like accents or symbols) through utf-8 encoding.
- New Snippets functionality: A snippet containing “hello $$world$$” will write “hello world” and the word “world” will be selected straightaway.
- Auto-completer (when pressing tab) now also includes the functions, variables, classes etc live from the current script you’re writing.
Bug fixes and enhancements:
- Python syntax highlighting improved.
- Snippet editor now includes syntax highlighting.
- Parenthesis/brackets auto-closing behavior improved when written inside each other.
- Fixed error that prevented opening a new KnobScripter when a Blinkscript node properties were open too.
- Tested on Windows OS (Nuke 11.3) and a few minor bugs fixed.
- Improved auto-scroll to cursor behavior when duplicating, moving or unindenting lines.
I hope KS3 will help improve your scripting experience! Bugs and suggestions always appreciated :)
Comments
This is really useful, thanks for sharing this tool :)
Does anyone know something?
Many thanks!
It's now updated to PySide2 and should work in both Nuke 11 and previous versions Let me know if you experience any problems!
Adrian
Thanks a lot!
I have one feature request: I often add knobChanged code to nodes within a group, so that I can avoid having the knobChanged fire whenever the selection state or position of a gizmo changes. This improves performance especially in big nuke scripts.
Right now in the tool it is possible to select a node inside a group and press alt+z to load the editor, but it's not possible to press the "Change" button and switch to a node insideo a group. Would this be possible to add?
Let me know if you encounter any other weird behaviours!
Best Nuke 11 feature by far.
Foundry should pay maintenance fee to you Adrian!!!
one of my scripts giving this error when i click save and it won't able to save. (checked file permission)
Quote:
Quote: I'll run some proper test when I have the time and report back, but I wanted to leave a comment just in case somebody else is having the same issue. Let me know if I can do anything else to help.
Salud!
./charlie
P.S: As you already know we are a Windows shop.
Indeed, it's only been tested on Linux and Mac. I completely forgot testing it on Windows!
Will make it the highest priority fix and update this thread
Gracias!!
We did encounter an error loading the module in our studio though. Forcing PySide2 for nuke versions 11 and up resolved it though. We use the Qt shim mostly, but this worked:
try:
if nuke.NUKE_VERSI ON_MAJOR < 11:
from PySide import QtCore, QtGui, QtGui as QtWidgets
from PySide.QtCore import Qt
else:
from PySide2 import QtWidgets, QtGui, QtCore
from PySide2.QtCore import Qt
except ImportError:
from Qt import QtCore, QtGui, QtWidgets
Also, for those wondering how to change the font - find/replace "Courier" with "Monospace" (or your choice of font) in knob_scripter.p y. This really aught to get it's value from ScriptEditorFon t from preferences, but this workaround is sufficient.
Quoting Robin Dutta:
I had this planned for a long time but never did it. Will add it to the next version too, and update this thread. Thank you!
Thank you bro!!
Amazing Adrian!!
It's realy helpfull.
I'v just tested it in 11.2v4 [Win].
It works.
I hope that my personal wishes will be interesting for you:
1. Editor is loosing focus every time I save my script. I have a little professional deformation in a form of frequent uncontrolled pressing Cntrl+S. Loosing focus in editor window is realy trouble for me ))
2. I really don't like the feature with parenthesis. It's hard to describe it in words. I press '('. It grately creates '()'. I press another '(' and want to see '(())'. But no! It's '(()'. AHHHH! And it does not allow me to immideatly close. It skips every parenthesis till the end of block.
I meet this situation really often and it produces a lot of unexpected mistakes for me.
For example
tn.addKnob(nuke.XY_Knob('name')
https://gyazo.com/d7b8953d54eb9bf103c82e57c0878d23
3. Kind of cheeky wish ))
I realy need autocomplete.
https://gyazo.com/aae2bd73ccfc1ecaef47d0de04afb5fd
When KnobScripter learn it I'll replace Atom immediately.
Once again - thank you for this awesome tool
#1 for writing local knobChanged and onCreate!
1. Which version of Nuke and OS are you one? It doesn't do that for me on CentOS 6 and MacOS X.
2. Thanks for that!! Already fixed for the next update (in the next days).
3. There is already an autocomplete for modules and objects loaded before starting the instance of the knobscripter, via pressing tab. I am now working on also adding to that list any variables and functions defined on the text itself live. Will be up on the next release too, most probably.
Cheers!
Win 10, NukeX 11.2v4
Quoting Adrian Pueyo:
Thanks ) You rock!
It works.
Thank you )
Can you show how to install the autocomplete in Atom?
Thanks!
Hello, Marco.
1. Install autocoplete package
https://atom.io/packages/atom-autocomplete-python
2. Go into settings of that package and change Python Executable Path to the python installed with Nuke.
For example C:\Program Files\Nuke11.2v 4\python.exe
3. It would not work if you donn't have nuke_i license installed.
In that case you can set Python Executable Path to the python 2.7 installed in your system ( If you have not one you need to install it with pip, anaconda, etc)
Then download dummy nuke and nukescript packages here
https://community.foundry.com/discuss/post/1107065
and set it to Extra Paths For Packages in autocomplete settings.
It should work now.
Sorry for clumsy reply.
Let me know if there will be any troubles.
Hey Den! Sorry for the (super) late response! I've managed to install Python on my mac and download the dummy nuke and nukescript packages. I've set the Extra Paths for Packages to point that folder but Atom is autocompleting only regular python definitions and not nuke ones. Any idea? Thanks a lot!
Marco
1. Copy the KnobScripter folder and paste it inside your .nuke directory.
2. Open the file menu.py inside your .nuke folder with a text editor, or create it if it
doesn’t exist.
3. Add the following line: import KnobScripter
4. Restart nuke.
Let me know if you have any problems!
(https://www.surveymonkey.co.uk/r/Nuke2019)
I am about to install 2.2 so apologies if any of these are already addressed, but here are some features I have added myself, or would like to see. I've added my mods to this fork of your git:
http://bit.ly/2V3JGAw
Added:
Bugs/Wishlist:
Now, if you would only rewrite the Manage User Knob interface
· Ctrl+S save shortcut not working: works for me in some machines and doesn't in others, will check what can be causing that...
· Add "Remove Custom" option to clean up the Script pulldown: you mean delete .py files from the dropdown?
· Alt+Backspace in Script Edit pane to clear output: nice one :) For now it also works it you simply click the output window and press backspace.
Sort of. I keep adding more and more custom script directories, that the first list is getting really long. You already have a delete feature in the .py file menu, but no way to remove the directories.
Unfortunately I received this error when trying to add a custom path to open existing sripts:
knob_scripter.py, line 1075, in folderDropdownChanged
os.symlink(folder_path, os.path.join(self.scripts_dir,aliasName))
OSError: [Errno 5] Input/output error
I tried this in a windows and linux env and got this each time. This was the linux output however in Windows it said that the os.symlink module did not exist.
Any help is appreciated!
Thanks.
--------------------
Traceback (most recent call last):
File "C:/Program Files/Nuke12.0v 2/plugins\nukes cripts\panels.p y", line 153, in makeUI
self.widget = self.widgetClas s()
File "C:/Users/aaaaa aaa/.nuke\KnobS cripter\knob_sc ripter.py", line 1649, in __init__
super(KnobScrip terPane, self).__init__( )
File "C:/Users/aaaaa aaa/.nuke\KnobS cripter\knob_sc ripter.py", line 123, in __init__
self.initUI()
File "C:/Users/aaaaa aaa/.nuke\KnobS cripter\knob_sc ripter.py", line 357, in initUI
self.script_edi tor = KnobScripterTex tEditMain(self, self.script_out put)
File "C:/Users/aaaaa aaa/.nuke\KnobS cripter\knob_sc ripter.py", line 2756, in __init__
self.nukeCompleter.setModel(QtGui.QStringListModel())
AttributeError: 'module' object has no attribute 'QStringListMod el'
Just replace QtGui.QStringLi stModel() with QtCore.QStringL istModel() in the knob_scripter.p y
Quote: to
Quote: This way it should work on both 11 and 12.
(Just posting it here for newbies)
Quote: to
Quote: This way it should work on both 11 and 12.
(Just posting it here for newbies)
Could you try importing it in your menu.py instead? That way it will happen after Nuke's UI has been set up. Hope that works.
But there is a problem that when you ever install pw_MultiScriptE ditor,the knobscripter doesn work.
it seems this two plugin doesn work together
But i am getting type error when i try to get into node mode.
When i click the button i get this:
.nuke\KnobScripter\knob_scripter.py", line 1375, in changeClicked
if newNode != "" and nuke.exists(newNode):
TypeError: exists() argument 1 must be string, not bool
I am on Nuke 12.0v3
If you open the file and go to the line 1375
yo can add the folowwing lines
if not newNode:
newNode = ""
if newNode != "" and nuke.exists(new Node):
selection = [newNode]
I just add two lines before the line with the error, it works
I hop ethis helps you
Cheers
thank you very much for sharing this tool of yours. It is really helpful and so we had included it into our workflow in https://pype.club. I had fork the github and presume we could start contribute. If you are having any milestones for next features you wish to share let me know.
Regarding to `kire timov` comment I agree that the TypeError is starting already on 12.0v1.
Traceback (most recent call last):
File "/Users/user/.n uke/python/Knob Scripter/knob_s cripter.py", line 3917, in showKnobScripte r
pan = KnobScripter()
File "/Users/user/.n uke/python/Knob Scripter/knob_s cripter.py", line 99, in __init__
self.nukeSEOutp ut = self.findSEOutp ut(self.nukeSE)
File "/Users/user/.n uke/python/Knob Scripter/knob_s cripter.py", line 1643, in findSEOutput
return se.children()[-1].children()[1]
IndexError: list index out of range
Traceback (most recent call last):
File "/Applications/ Nuke12.0v3/Nuke 12.0v3.app/Cont ents/MacOS/plug ins/nukescripts /panels.py", line 153, in makeUI
self.widget = self.widgetClas s()
File "/Users/user/.n uke/python/Knob Scripter/knob_s cripter.py", line 1664, in __init__
super(KnobScrip terPane, self).__init__( )
File "/Users/user/.n uke/python/Knob Scripter/knob_s cripter.py", line 99, in __init__
self.nukeSEOutp ut = self.findSEOutp ut(self.nukeSE)
File "/Users/user/.n uke/python/Knob Scripter/knob_s cripter.py", line 1643, in findSEOutput
return se.children()[-1].children()[1]
IndexError: list index out of range
I made an issue on the github page: https://github.com/adrianpueyo/KnobScripter/issues/6
It looks like it's related to the `ScriptEditorHi story.xml` existing in the user's home directory. I have successfully worked around this issue by removing that file and disabling 'save and restore script editor history' in my nuke preferences. Not ideal but it works.
https://github.com/adrianpueyo/KnobScripter/pull/7
It works well for my Nuke11.3v6, but Nuke12.2v3 throws an error, when selecting a node:
"knob_scripter.py", line 1375, in changeClicked
if newNode != "" and nuke.exists(newNode):
TypeError: exists() argument 1 must be string, not bool
Happy to report that this issue is now resolved when you switched to Qt.
Salud!
./charlie
Quoting Carlos Trijueque:
This is the error I encounter:
TypeError: cannot concatenate 'str' and 'QVariant' objects
This is cause by our studio pipeline for sure, but as none of the pipeline guys have any time available for a non-needed tool I was hoping maybe someone already knows a quick fix around this issue?
Hi Adrian,
I've installed v3.0 from scratch and I'm getting the same Error Tim was reporting.
File "C:/Users/dann. tarmy/.nuke\Kno bScripter\knob_ scripter.py", line 1215, in updateScriptsDr opdown
logging.debug(" current folder:" + self.current_folder)
TypeError: cannot concatenate 'str' and 'QVariant' objects
This is using Nuke 12.2v8 with python 2.7.16 on Windows10.
Any thoughts on a fix, a workaround, or maybe something it might be in conflict with?
A couple of things:
In the readme.md file it describes how to add the needed line(s) into our menu.py file.
But the instruction includes "python" as the first line. This causes an error on start up. It should just be the import knobscripter line.
---------------------
Is knobscripter expected to work inside groups?
I have a group, and when I'm trying to view a node inside the group, knobscripter only shows me the scripts for the group node. Even if I've deselected it in the main node view, and only have the node I want selected.
Thanks for this amazing script ! love it all the way, until... Nuke 13 !
It does not run on 13 :(
#1 I solved a Bug in the tool:
In knob_scripter.p y -> line 3464 to 3470. Line 3468 should be = 'return 4' instead of 'return 2'
def tabSpaceValue(s elf):
if self.tabSpace2. isChecked():
return 2
elif self.tabSpace4. isChecked():
return 2
else:
return 0
#2 Foldable functions and comments, so to be able to fold large
blocks of code lines for a better readability of the code
#3 Easy customization of highlight colors for code readability. Set color of variables, python inbuilts, nuke functions, created functions, modules, comments, etc
But I'm getting an error in the shell when I create a Knobscripter panel as a docked tab.
See below the line of ========
At one point it was working, even thought it was displaying the error. But now the panel is blank... Its very odd.
Thanks,
Norman
=============================================
Traceback (most recent call last):
File "/soft/app/foun dry/Nuke12.2v3/ plugins/nukescr ipts/panels.py" , line 153, in makeUI
self.widget = self.widgetClas s()
File "/net_home/norm an.cates/.nuke/ KnobScripter/kn ob_scripter.py" , line 1661, in __init__
super(KnobScrip terPane, self).__init__( isPane=True, _parent=QtWidge ts.QApplication .activeWindow() )
File "/net_home/norm an.cates/.nuke/ KnobScripter/kn ob_scripter.py" , line 144, in __init__
self.initUI()
File "/net_home/norm an.cates/.nuke/ KnobScripter/kn ob_scripter.py" , line 430, in initUI
self.exitNodeMo de()
File "/net_home/norm an.cates/.nuke/ KnobScripter/kn ob_scripter.py" , line 1436, in exitNodeMode
self.loadScript State()
File "/net_home/norm an.cates/.nuke/ KnobScripter/kn ob_scripter.py" , line 1248, in loadScriptState
self.state_dict = json.load(f)
File "/soft/app/foun dry/Nuke12.2v3/ lib/python2.7/j son/__init__.py ", line 291, in load
**kw)
File "/soft/app/foun dry/Nuke12.2v3/ lib/python2.7/j son/__init__.py ", line 339, in loads
return _default_decode r.decode(s)
File "/soft/app/foun dry/Nuke12.2v3/ lib/python2.7/j son/decoder.py" , line 364, in decode
obj, end = self.raw_decode (s, idx=_w(s, 0).end())
File "/soft/app/foun dry/Nuke12.2v3/ lib/python2.7/j son/decoder.py" , line 382, in raw_decode
raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded
Excellent that it is now directly working with the BlinkScript node. Will you also add direct access to the particle BlinkScipt node?
It works fine in 13.0 and 13.1, but it's an insta nuke crash for me in 13.2. Nothing even in the terminal!
I am seeing an warning thought that I thought I would notify you about.
/nuke/KnobScripter/ksscripteditor.py:73: DeprecationWarn ing: QFontMetrics.wi dth(const QString & arg__1, int len) const is deprecated
space = 7 + self.fontMetric s().width('9') * digits
However, if you change line 73 in ksscripteditor. py from
space = 7 + self.fontMetric s().horizontal( '9') * digits
to
space = 7 + self.fontMetric s().horizontalA dvance('9') * digits
It stops spamming the output.
space = 7 + self.fontMetric s().width('9') * digits
to
space = 7 + self.fontMetric s().horizontalA dvance('9') * digits
line 393 in knob_scripter.p y from
config.prefs["se_tab_spaces"] * QtGui.QFontMetr ics(config.scri pt_editor_font) .width(' '))
to
config.prefs["se_tab_spaces"] * QtGui.QFontMetr ics(config.scri pt_editor_font) .horizontalAdva nce(' '))
Autocompleter. For example when I write "nuke." I would like to see after pressing TAB all the method of nuke module It would really speed up code. And it should work for anything. Maybe it might be done by using "dir" wrapper. For example "dir(nuke)" gives list of all of it methods
Also really need to have a function to delete code from code gallery
AttributeError: 'KnobScripterPa ne' object has no attribute 'updateValue'
Any ideas on how to fix this?
It looks as though the only thing affected was the 'string' function, so I removed the function and tidied up all the places that uses it.
There was also an used function called 'string_chk' that I assume was used at one time for troubleshooting the string issues but I don't think it is still needed so I removed that on as well.
I created a pull request on github but in the mean time you can also download it from my repository at https://github.com/itaki/KnobScripter
Thanks again @Adrian for this amazing tool.
I've downloaded this folder: https://github.com/itaki/KnobScripter/tree/master/KnobScripter
But I still have the same problems as with the original version. Should I be downloading something else from your repository?
Thanks again
Thanks so much for continuing to share this with the community. It's an incredibly useful tool.
Testing in Nuke14.0v5...se ems to work without issue, but I did see this warning in the script editor when first loading:
AttributeError: 'KnobScripterPa ne' object has no attribute 'updateValue'
I'm just running up against a problem where KnobScripter isn't reading the contents of a Python Custom knob thats been added in a user tab.
Ironically perhaps, the problem is happening in the DummyCamera gizmo, written by Adrian.
http://www.nukepedia.com/gizmos/3d/dummycam
I can't see the contents of the the_cam and the_frame Python Custom knob using KnobScripter.
Interestingly, they don't show the script boxes in the Manage User Knobs interface either.
This is Knobscripter 3.1. And DummyCam 1.3.
In Nuke 13.2 v6, on Linux.
I don't see any errors in the error consoles, nor in the shell.
Those 2 knobs are actually simple multiline string knobs. They are holding multiline TCL code but it's not executed by itself, just referenced as part of actual TCL expressions in the numerical projection knobs of the camera (aperture, fstop and so on).
If you wish to read/edit the contents, probably the easiest way is to make them visible and then edit them normally. It's TCL code so the KnobScripter v3 highlighting wouldn't be great either (just works with Python and Blink).
Hope this helps!
RSS feed for comments to this post