Get Project Settings format size's width height values


#1

First I’m lost on how to reference the Project Settings node programatically?
So far I’m trying to get the app.outputFormat
I’m not sure how to debug from an expression editor. I’d like to inspect the object for what’s inside. (print console log? starting with keys of app possible. also don’t know where the documentation on variable extraction and inspection or an example would be)

Then if it’s just a string that’s not the width and height I’d like? Maybe I’d have to parse the string. Alas it seems difficult to understand how to debug efficiently from the Multi-line.

The editor says lots about some preset values but nothing about how a return values is set thisParam = something? maybe I use ‘return something’ when it’s multiline.

So this question asks more but how to get the desired project settings width for scaling seems like a pretty primary thing to do from the second node (first read then transform to best fit the project settings format ! really not sure why it’s not part of read and activated as a default).

Okay making some progress barely
ret = app.outputFormat.get()
returns 22 in my case which I suppose is an index to some array somewhere. Where are the formats?

I’ve found
http://natron.readthedocs.io/en/master/devel/PythonReference/NatronEngine/App.html
and
http://natron.readthedocs.io/en/master/devel/PythonReference/NatronEngine/Param.html

but still no luck I’m feeling disturbed to see an addFormat but no getFormat seems like an incomplete API to me.

I’ve discovered the Script Editor is a better way to probe objects for info as it can use print().
Can cut and paste from the output though. outputFormat is a NatronEngine.ChoiceParam so again just an index to an unknown array of formats hidden somewhere.

That in Parms is
http://natron.readthedocs.io/en/master/devel/PythonReference/NatronEngine/ChoiceParam.html#choiceparam
which gives a list of u’string’ if getOptions() or getOption(index) is called. Still not much of a width and height just string labels which are not encoded with the resolution and aspect ration.

Now I’ve tried to get the source code addFormat function to see if that shows where this array is.

github.com/MrKepzie/Natron/blob/1765e7108b0fc561bd29496cabe060586b2a3466/Engine/PyAppInstance.cpp

App::addFormat(const QString& formatSpec)
{
if ( !getInternalApp()->getProject()->addDefaultFormat( formatSpec.toStdString() ) ) {
getInternalApp()->appendToScriptEditor( formatSpec.toStdString() );
}
}

Calls dig deeper to addDefaultFormat and tryAddProjectFormat in turn?

Well that kind of ends things for me. It looks like Natron is missing a getFormat with label or index function to me.

Anyway if it’s a custom format named with the resolution one can try to manually parse the data from that via something like print(app.outputFormat.getOption(22).split(‘x’)[0]) shows in the “Script Editor” output.

width = int(app.outputFormat.getOption( app.outputFormat.get() ).split( ‘x’ )[0])
ret = width-(thisNode.getInput(0).getRegionOfDefinition(frame, view)).width()/2


#2

Now if I do this on Read1 just to be sure
print(Read1.getRegionOfDefinition(frame, view).height())
It doesn’t seem to give me the correct values for each frame.
Usually I do a low res previs and then render higher res later and expect to see the value of the resolution of the currently loaded frame.
It seems like I’m not getting that updated as the different frames load?! Maybe this is a bug as well or I’m not doing the right thing to get the resolution of the currently loaded frame?