Inspecting Resolve Objects with Python

Get answers to your questions about color grading, editing and finishing with DaVinci Resolve.
  • Author
  • Message
Offline

nlhansen

  • Posts: 3
  • Joined: Mon Aug 20, 2018 12:30 am
  • Real Name: Neil Hansen

Inspecting Resolve Objects with Python

PostFri Sep 14, 2018 12:22 am

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.
Offline

Martin Schitter

  • Posts: 899
  • Joined: Tue Apr 28, 2015 10:41 pm

Re: Inspecting Resolve Objects with Python

PostFri Sep 14, 2018 10:27 am

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
Offline

nlhansen

  • Posts: 3
  • Joined: Mon Aug 20, 2018 12:30 am
  • Real Name: Neil Hansen

Re: Inspecting Resolve Objects with Python

PostFri Sep 14, 2018 1:16 pm

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.
Offline

SebastianOchmann

  • Posts: 11
  • Joined: Wed Dec 26, 2018 5:53 pm
  • Real Name: Sebastian Ochmann

Re: Inspecting Resolve Objects with Python

PostSun May 12, 2019 7:48 pm

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
Offline
User avatar

Igor Riđanović

  • Posts: 1656
  • Joined: Thu Jul 02, 2015 5:11 am
  • Location: Los Angeles, Calif.

Re: Inspecting Resolve Objects with Python

PostMon May 13, 2019 6:27 pm

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.
www.metafide.com - DaVinci Resolve™ Apps
Offline

MarcusWolschon

  • Posts: 807
  • Joined: Sun Apr 14, 2013 6:59 pm

Re: Inspecting Resolve Objects with Python

PostMon May 13, 2019 6:39 pm

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?
Offline

SebastianOchmann

  • Posts: 11
  • Joined: Wed Dec 26, 2018 5:53 pm
  • Real Name: Sebastian Ochmann

Re: Inspecting Resolve Objects with Python

PostTue May 14, 2019 7:13 pm

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!
Offline
User avatar

Elliott Balsley

  • Posts: 618
  • Joined: Sat Oct 13, 2012 5:45 pm
  • Location: Southern California

Re: Inspecting Resolve Objects with Python

PostThu May 23, 2019 3:04 pm

I found that in Python 3 the syntax is slightly different.
print(resolve.GetHelp())
Offline
User avatar

Igor Riđanović

  • Posts: 1656
  • Joined: Thu Jul 02, 2015 5:11 am
  • Location: Los Angeles, Calif.

Re: Inspecting Resolve Objects with Python

PostThu May 23, 2019 6:41 pm

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'
www.metafide.com - DaVinci Resolve™ Apps
Offline
User avatar

iddos-l

  • Posts: 803
  • Joined: Sat Mar 30, 2019 7:55 pm
  • Real Name: iddo lahman

Re: Inspecting Resolve Objects with Python

PostThu May 23, 2019 6:55 pm

I’m having trouble importing the binaries in python 3.7

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

Elliott Balsley

  • Posts: 618
  • Joined: Sat Oct 13, 2012 5:45 pm
  • Location: Southern California

Re: Inspecting Resolve Objects with Python

PostFri May 24, 2019 2:24 am

I think it only supports python 2.7 and 3.6
Elliott C. Balsley
DIT, Colorist, Cinematographer
www.llamafilm.com
Offline
User avatar

robozb

  • Posts: 436
  • Joined: Wed Apr 17, 2019 6:48 am
  • Location: Hungary
  • Real Name: Roboz Bela Tamas

Re: Inspecting Resolve Objects with Python

PostSun Aug 25, 2019 9:25 am

It seems the resolve scripting is incerdible basic and underdocumented, is good for only playing.
Offline
User avatar

robozb

  • Posts: 436
  • Joined: Wed Apr 17, 2019 6:48 am
  • Location: Hungary
  • Real Name: Roboz Bela Tamas

Re: Inspecting Resolve Objects with Python

PostSun Aug 25, 2019 9:41 am

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
Offline

MarcusWolschon

  • Posts: 807
  • Joined: Sun Apr 14, 2013 6:59 pm

Re: Inspecting Resolve Objects with Python

PostSun Aug 25, 2019 10:29 am

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.)
Offline
User avatar

robozb

  • Posts: 436
  • Joined: Wed Apr 17, 2019 6:48 am
  • Location: Hungary
  • Real Name: Roboz Bela Tamas

Re: Inspecting Resolve Objects with Python

PostSun Aug 25, 2019 10:59 am

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 :)
Offline
User avatar

robozb

  • Posts: 436
  • Joined: Wed Apr 17, 2019 6:48 am
  • Location: Hungary
  • Real Name: Roboz Bela Tamas

Re: Inspecting Resolve Objects with Python

PostSun Aug 25, 2019 11:01 am

In the readme file: As with the resolve object, each object is inspectable for properties and functions.

OK, great, but please help us: HOW!
Offline

Brendan Dower

Blackmagic Design

  • Posts: 66
  • Joined: Thu Oct 10, 2019 5:56 am
  • Real Name: Brendan Dower

Re: Inspecting Resolve Objects with Python

PostTue Aug 31, 2021 6:50 am

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.
Brendan Dower
Blackmagic Design Developer Support
Offline

MarcusWolschon

  • Posts: 807
  • Joined: Sun Apr 14, 2013 6:59 pm

Re: Inspecting Resolve Objects with Python

PostTue Aug 31, 2021 6:54 am

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?
Online
User avatar

roger.magnusson

  • Posts: 3876
  • Joined: Wed Sep 23, 2015 4:58 pm

Re: Inspecting Resolve Objects with Python

PostTue Aug 31, 2021 9:09 am

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.

Return to DaVinci Resolve

Who is online

Users browsing this forum: panos_mts and 424 guests