How can I use app instance and use it in importing code [solved]

(Mikhail) #1

Hi I trying to get access to

in some automation for my working those options:
nn = natron.getActiveInstance()
ID = nn.getAppID()
app = natron.getGuiInstance(ID)
selectedNodes = app.getSelectedNodes()
app = natron.getGuiInstance(0)

In general I think that first varian better
But when I trying to do same thing with like this
if app.projectName.getValue() == “Untitled.ntp”:
print app.projectName.getValue()

I am trying to check some information about project like (name and scene information ) I resived - Error about … func is not a property of object … Ok
main program is singelton and we need to get instance … But in deferent places it’s working correctly?

if I use in script editor string like this
all well done

My variant is creating “project” node and setup correct paths for scene in it.

But how can use this function projectName.getValue() stable from script to script?

Thank you!

(Mikhail) #2

I find a simple way for 100% guarantee have instance of natronGUI
for this i used to global variable:
def init(app_in):
global app
app = []

def natron_app():
return app[0]
def Project_Callback(app):
app = conf.natron_app()
print app.projectPath.getValue()
print app.projectName.getValue()

It is solution is not very beautiful, but for my it stable working