This thread is dedicated to NATRON PYTHON SCRIPTING ONLY discussions.
Please use the tag natron-python when asking python based questions.
It will help to sort and search Natron python questions for all the users.
For startup Here is the Natron python API:
https://natron-docs.readthedocs.io/en/sphinx_rtd_theme/devel/index.html#developers-guide
Some discussions attached:
Adding :
app.getProjectParam(‘frameRange’).setValue(1, 25)
to init.py file doesn’t produce any result, nor any error message.
Note that every other parameter can be accessed and tweaked using the ‘getProjectParam’ function.
Hi,
I was wondering how curves work with python scripts. have you somes examples ? Even if i add somes animations on an effect, i don’t understand how i can edit curve, and i don’t see it in curve editor (ui).
Is it even possible ?
I’m trying to get the ‘diskCachePath’ setting.
I’ve tried using the ‘NatronEngine.AppSettings.getParams ()’ for the ‘AppSettings’ class.
But script returns an error saying ‘getParams ()’ needs an argument, although doc says it doesn’t require any.
If anyone has any clue on this.
Thanks.
Hi all,
So I’m learning how to navigate Natron with Python, and having trouble. What I’m trying to do is pick an output format in Natron settings. I’m under the impression that before I pick a format, maybe I need to see what formats there are first, therefore, I’m trying to read Natron’s settings via code. According to the docs, NatronEngine.AppSettings.getParams() “Returns a sequence with all Param composing the settings.”. Yet, when I run that function, I get the following error:
While exec…
The ‘DiskCache’ has its ‘Last Frame’ parameter to be named ‘LastFrame’ with a upper case ‘L’, instead of lower case.
Seems to me like a bug.
Hello
I try to automate Natron for our studio. But I have a problem with printing some message in ScriptEditor console:
[console_error]
how can I fixet this output? Is the onle way use loging for debug scripts
Thank you!
Hi, I tried to add menu to the left toolbar
Add to the top menu is a very simple
from NatronGui import *
NatronGui.natron.addMenuCommand("Custom/ReloadReaders", "initGui.reloadSelectedReaders", Qt.Key.Key_R, Qt.KeyboardModifier.ShiftModifier)
But I cann’t find how add menu to the toolbar?
Thank you
I want to merge images using python . I have merged images with merge node but to display that merged file output i need to connect merged node with viewer node . My code is given below
app = natron.getGuiInstance(0)
read = app.createNode(“net.sf.openfx.MergePlugin”)
reader = app.createReader(“C:\Users\Public\Pictures\Sample Pictures\Penguins.jpg”)
reader1 = app .createReader(“C:\Users\Public\Pictures\Sample Pictures\Tulips.jpg”)
reader2 = app.createReader(“C:\Users\Public\Pictures\Sample P…
Hi to all,
i explain the issue,I have installed Natron in Ubuntu 16.04, i upgraded Natron to 2.3.11 with NatronSetup, when i run Natron i get an error about boost version (boost 1.67 is required) so i downloaded the 1.67 boost package’ i compiled it and installed it. And this is fine. But when i run again Natron i get this error instead:
./Natron
Natron Version 2.3.11
Copyright (C) 2013-2018 INRIA and Alexandre Gauthier-Foichat
Use the --help or -h option to print usage.<<<
/home/walte…
Hi,
I’m having difficulties getting the app1/app global variable when running a custom python script.
I’m receiving this error:
NameError: global name ‘app1’ is not defined.
Note the script works when running in Natron’s interactive python shell it works.
I tried a few approaches, but none have worked so far:
I receive a different app instance, which has a subset of the functions app1 has.
import NatronGui
NatronGui.natron.getGuiInstance(0)
Returns a NatronEngine app instance, not gui…
Hi,
Try to use getFilenameDiaglog() to make user picking one exr file. However, I could not figure out how to set filters properly.
The documents shows that
NatronGui.GuiApp.getFilenameDialog(filters[, location=None])
filters – sequence
filters is a list of file extensions that should be displayed in the file dialog.
I’ve tried following in script editors but all failed.
app1.getFilenameDialog([‘exr’])
app1.getFilenameDialog((‘exr’))
what’s sequence datatype? how to set filters? in li…
I am looking for a way to reference existing node from python inside the GUI (script editor). From the examples/documentation, I extracted the following:
from NatronGui import *
app = natron.getInstance(0)
writer= app.createNode("fr.inria.openfx.WriteOIIO")
Nice! A node named “Write5” appears on the Node Graph, but when I try to get it later from another script…
app.render(app.Write5, 1,1, 1)
AttributeError: 'NatronEngine.App' object has no attribute 'Write5'
So this is the documented way, …
Hey there, simple question. As i am new to natron - is it possible to export a GUI-Node-Graph project as python-script for use on command line? Background is: i want to start an in natron with gui done project, but also with flexibility on give command line based parameters such as tell a text-node what text should be shown?
So for now I really only need command line without GUI. So I Do have my ntp file with a simple text which scales up about 5 percent. Is it with the natronrenderer out of th…
This expression is incorrect. Multi-line expressions look like this:
if frame < 150:
ret = frame * 10
else:
ret = 150 * 10
See the tooltip for the “Multi-line” button:
"When checked the Python expression will be interpreted as series of statement. The return value should be then assigned to the ret variable. When unchecked the expression must not contain any new line character and the result will be interpreted from the interpretation of the single line.
fabiof17
(Fabrice Fernandez)
June 18, 2019, 6:59pm
#5
Expression for the ‘Rotate’ parameter.
seed = 10
frequency = 0
amplitude = 0
offset = 10
intensity = 1
ret = (random(seed,frequency)*amplitude)+offset*intensity
Now you see that, by lowering the ‘intensity’ parameter, you lower the global random effect.
intensity = 0 : no rotation at all
intensity = 1 : full random rotation
That’s what i did in this Pyplug :
2 Likes
ninhenzo64
(Henry van der Beek)
July 20, 2022, 3:05pm
#7
is it possible to save the script editor contents? i find it really useful in nuke that when i write something in the script editor, it’s restored next time i launch nuke. i was wondering if anything like that’s possible in natron.
rodlie
(Ole-André)
July 20, 2022, 3:52pm
#8
Hi,
The content is not saved in any way I’m aware of. But, this is probably something we could add.
You could also make a small Python script that (re)store the content of the editor on exit/launch.
entu_sias
(entu sias)
August 3, 2023, 4:02am
#9
for some reason my first question in this forum got deleted after some server error last week or so… anyway, i’ve got another question about python scripting in natron… in Text Node, if i check the ‘Auto Size’, can i get an actual canvas size from python expression?