App, app1 and project


#1

When doing python scripting I find it confusing that there is app and also app1. I never know which to use.

Also when i have multiple natron projects open and running scripts, are the scripts contained to the project or can they accidentally cross into the other project?


Natron App instance
#2

app1, app2, app3 respectively indicates the opened projects (in order of opening).
app on the other hand is defined automatically by Natron prior to calling a script within an application instance


#3

numbered in order of opening is not useful, or at least I dont see how it would be useful in scripting.

maybe better if you could change that so it is something like
app.project.name

where
app = running natron instance,
project = open project by that instance,
name = the project file name

cheers


#4

They are mainly used to allow Natron itself to work internally when multiple projects are opened. You may forget all about app1, app2, etc… (in fact they should be removed from any doc).
I don’t see what app.project would bring, and app.project.name is already available via the corresponding parameters app.projectPath and app.projectName


#5

ah! perfect!

thanks for the explanation, yes best to update the doc.


#6

You may contribute to the doc and also report bugs if at some points the app variable does not work correctly.


#7

OK I will make that update to the doc soon and also add a couple more examples of basic scripting actions.
later you can correct if needed.


#8

I am updating the doc. Couple questions: how to retrieve the list of open project instances? and also could you overload getInstance to allow the project name as parameter instead of index?

curApp = NatronEngine.natron.getInstance(projectname)


#9

Call http://natron.readthedocs.io/en/master/devel/PythonReference/NatronEngine/PyCoreApplication.html#NatronEngine.NatronEngine.PyCoreApplication.getNumInstances

Then iterate on each instance using index:

http://natron.readthedocs.io/en/master/devel/PythonReference/NatronEngine/PyCoreApplication.html#NatronEngine.NatronEngine.PyCoreApplication.getInstance

We can add an overload by project name, of course


#10

I had a go at updating the doc but the app1 references are all through it. I dont feel in a position to make changes that big to the doc.