Page 1 of 1

Inspecting Resolve Objects with Python

PostPosted: Fri Sep 14, 2018 12:22 am
by nlhansen
The Resolve developer README outlines:

"The resolve object is the fundamental starting point for scripting via Resolve. As a native object, it can be inspected for further scriptable properties - using table iteration and `getmetatable` in Lua and dir, help etc in Python (among other methods)."

And inside the "Basic Resolve API" section, it says:

"Some commonly used API functions are described below (*). As with the resolve object, each object is inspectable for properties and functions."

The README suggest that the aforementioned "resolve object" is what is returned by dvr_script.scriptapp("Resolve"). For example.... resolve = dvr_script.scriptapp("Resolve").

However, in Python, "dir(resolve)" returns an empty list, which is highly unusual for any Python object, and certainly not the behaviour that the README describes. The same behaviour happens with every other object in the API documentation.

I'd love to get as much as I can out of this API. Blackmagic, are there any more exposed props/methods than what is in the "Basic Resolve API" section? The README suggests that there is more if we inspect these objects, but that doesn't seem to be working. Am I inspecting these incorrectly? Or have these instructions made it into the README a little prematurely, before any additional functionality has been added?

Please advise.

Re: Inspecting Resolve Objects with Python

PostPosted: Fri Sep 14, 2018 10:27 am
by Martin Schitter
nlhansen wrote:However, in Python, "dir(resolve)" returns an empty list, which is highly unusual for any Python object, and certainly not the behaviour that the README describes. The same behaviour happens with every other object in the API documentation.


is it perhaps a "None" object? :)

just test it with: type(resolve)

see also: viewtopic.php?f=21&t=77764

Re: Inspecting Resolve Objects with Python

PostPosted: Fri Sep 14, 2018 1:16 pm
by nlhansen
Thanks for the reply, Martin! It seems they are not None objects, they're some custom PyRemoteObject that doesn't have properly implemented magic methods. The result of dir(resolve) is just an empty list.

As a matter of fact, the PyRemoteObject is lacking even basic boolean functionality. Even when an instance refers to an object inside Resolve, and has working methods, it evaluates as False! This is incredibly inconvenient, as unsuccessful API calls usually return None. Therefore, it's rather difficult to know (without looking at the Resolve GUI) if an API call was successful.

As an amusing solution, I've actually implemented a check on all API calls that uses "dir()". The objects returned by the Resolve API are completely void of any attributes or methods, which happens with no other Python object, not even None. While this certainly makes them difficult to inspect, it means that if len(dir(resolve)) == 0, you know you have a resolve object, and not None.

Anyways, looking forward to the continued development of this API! Blackmagic, I hope you can still chime in about my original question.

Re: Inspecting Resolve Objects with Python

PostPosted: Sun May 12, 2019 7:48 pm
by SebastianOchmann
Hello,

I'm also currently trying to figure out which functions are available on either the Python or Lua objects. However, in both cases actually, the objects only seem to have quite generic properties exposed through the methods described in the scripting readme (getmetatable for Lua, dir or help for Python).

Did any of you find a way to get more information about the objects? Can maybe someone from BMD chime in and give us more information about the possibilities of the API?

Best regards
Sebastian

Re: Inspecting Resolve Objects with Python

PostPosted: Mon May 13, 2019 6:27 pm
by Igor Riđanović
You can run GetHelp() on an object. For example, assuming "resolve" is instantiated properly:
Code: Select all
GetHelp('resolve')

returns available methods for this object.

Re: Inspecting Resolve Objects with Python

PostPosted: Mon May 13, 2019 6:39 pm
by MarcusWolschon
Has any of this been fixed in Resolve 15.1.2, 15.2, 15.2.1, 15.2.2, 15.2.3, 15.2.4, 15.3, 15.3.1, 16 Beta 1 or 16 Beta 2?

Re: Inspecting Resolve Objects with Python

PostPosted: Tue May 14, 2019 7:13 pm
by SebastianOchmann
Igor Riđanović wrote:You can run GetHelp() on an object. For example, assuming "resolve" is instantiated properly:
Code: Select all
GetHelp('resolve')

returns available methods for this object.


Thanks Igor! In Python 2, I was able to get a list of base classes using resolve.GetHelp() once I have instantiated "resolve". Then I can dig deeper using, for instance, resolve.GetHelp("Timeline"). After a quick look, I wasn't able to find methods for performing cuts or adding transitions, which is what I would be interested in, but I'll have a closer look. The readme should really be adjusted accordingly, or it should just have a proper scripting documentation.

Thanks!

Re: Inspecting Resolve Objects with Python

PostPosted: Thu May 23, 2019 3:04 pm
by Elliott Balsley
I found that in Python 3 the syntax is slightly different.
print(resolve.GetHelp())

Re: Inspecting Resolve Objects with Python

PostPosted: Thu May 23, 2019 6:41 pm
by Igor Riđanović
That's correct. Or to keep Python 2 code more in line with Python 3 since EOL is near, you can use:

Code: Select all
from __future__ import print_function

print('Consistent with Py3')
print 'The Py2 way still works'

Re: Inspecting Resolve Objects with Python

PostPosted: Thu May 23, 2019 6:55 pm
by iddos-l
I’m having trouble importing the binaries in python 3.7

Module imp is not supported in 3.7.
Anyone had different results?

Re: Inspecting Resolve Objects with Python

PostPosted: Fri May 24, 2019 2:24 am
by Elliott Balsley
I think it only supports python 2.7 and 3.6

Re: Inspecting Resolve Objects with Python

PostPosted: Sun Aug 25, 2019 9:25 am
by robozb
It seems the resolve scripting is incerdible basic and underdocumented, is good for only playing.

Re: Inspecting Resolve Objects with Python

PostPosted: Sun Aug 25, 2019 9:41 am
by robozb
Dear Igor,

Do you have any idea more how to inspect PyRemoteObject-s to get infos about (undocumented)callable functions?

Actually I'd like to reach clips on timelines to get theirs markers and to set/add other ones, marker copying at timeline clip level.

Thanks: Bela

Re: Inspecting Resolve Objects with Python

PostPosted: Sun Aug 25, 2019 10:29 am
by MarcusWolschon
Same here.

I'd like to get and set the transformation parameters of clips on a timeline
to build video walls for editing-reviews via a script.
(In case anyone from Blackmagic is reading and making notes.)

Re: Inspecting Resolve Objects with Python

PostPosted: Sun Aug 25, 2019 10:59 am
by robozb
In the "documentation", readme file:

...it can be inspected for further scriptable properties... ...dir, help etc in Python (among other methods)...

What I see: the refered functions is good for nothing, for example:

help(project)
Help on PyRemoteObject object:

class PyRemoteObject(object)
| Methods defined here:
|
| __call__(...)
| x.__call__(...) <==> x(...)
|
| __delitem__(...)
| x.__delitem__(y) <==> del x[y]
|
| __getitem__(...)
| x.__getitem__(y) <==> x[y]
|
| __setitem__(...)
| x.__setitem__(i, y) <==> x[i]=y
|
| __str__(...)
| x.__str__() <==> str(x)

Good for nothing, this is not a function list what is in the "docs".

Or:

>>> dir(project)
[]

Or what is this:

>>> project.GetHelp()
'\nClasses:\n PolylineMask\n Loader\n QueueManager\n RenderJob\n RenderSlave\n FloatLUTMacroFrame\n Parameter\n SourceOperator\n Operator\n PlainOutput\n Link\n PlainInput\n SplineEditorView\n TimelineView\n FloatViewFrame\n FuView\n FuFrame\n Preview\n GLImageViewer\n GL3DViewer\n GLViewer\n GLView\n GLPreview\n TimeRegion\n Object - The root class of all objects in FusionScript\n List\n FlowView\n TransformMatrix\n LUT\n LookUpTable\n Image\n Gradient\n BezierSpline\n IOClass\n UITimer\n UIFont\n UITabBar\n UITreeItem\n UITree\n UIDoubleSpinBox\n UISpinBox\n UITextEdit\n UILineEdit\n UICheckBox\n UIComboBox\n UIColorPicker\n UISlider\n UILabel\n UIButton\n UIStack\n UIDialog\n UIWindow\n UIWidget\n UIItem\n UIManager\n UIActionTree\n UIActionStrip\n Event\n ActionMode\n Action\n ConfigItem\n ActionManager\n PlaybackManager\n BinManager\n BinItem\n Registry - Represents a type of object within Fusion\n MailMessage\n ImageCacheManager\n HotkeyManager\n Composition\n FontList\n Fairlight\n ChildGroup\n ChildFrame\n FusionUI\n Fusion\n ResolveScriptable\n Timeline item\n Folder\n Timeline\n MediaPool\n Project\n Media pool item\n ProjectManager\n MediaStorage\n Resolve\n ScriptServer\n'

How can I figure out which one is a callable function, or what else? This scripting possibility seems like a joke, half work :)

Re: Inspecting Resolve Objects with Python

PostPosted: Sun Aug 25, 2019 11:01 am
by robozb
In the readme file: As with the resolve object, each object is inspectable for properties and functions.

OK, great, but please help us: HOW!

Re: Inspecting Resolve Objects with Python

PostPosted: Tue Aug 31, 2021 6:50 am
by Brendan Dower
Hi Roboz,
I realise that your question was asked a long time ago, but for anyone who is looking for the answer, simply query GetHelp() with the property that you are wanting to inspect.

For instance: project.GetHelp('UITimer') will print out all of the properties and functions of the UITimer class.

Re: Inspecting Resolve Objects with Python

PostPosted: Tue Aug 31, 2021 6:54 am
by MarcusWolschon
Brendan Dower wrote:Hi Roboz,
I realise that your question was asked a long time ago, but for anyone who is looking for the answer, simply query GetHelp() with the property that you are wanting to inspect.

For instance: project.GetHelp('UITimer') will print out all of the properties and functions of the UITimer class.


Could that be added to the README of the API?

Re: Inspecting Resolve Objects with Python

PostPosted: Tue Aug 31, 2021 9:09 am
by roger.magnusson
For anyone who wants a list of everything that GetHelp() contains, check out my Class Browser for Resolve/Fusion.

Brendan, it would be really great if the Resolve function parameters and descriptions could be added to the help system in addition to the function names, like it's done in the Fusion objects. As it is today GetHelp() for Resolve objects is only populated with the function names.