Scripting - How to access Inspector properties??

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

tejpal

  • Posts: 2
  • Joined: Thu Oct 28, 2021 5:40 am
  • Real Name: Tejpal Singh

Scripting - How to access Inspector properties??

PostThu Oct 28, 2021 5:49 am

How does one access Inspector properties via script in 17.4? (New feature as per press release)

Also dump(resolve:GetHelp('*')) only works for dump(resolve:GetHelp('ProjectManager')).

GetHelp returns nothing on the others e.g. Timeline, Timeline item, Project etc etc. So only one can't tell how to use new scripting features in new releases.

P.S.: Many congrats & thanks to BMD for an excellent piece of software.

Warm Regards,
Tej
Offline
User avatar

TheBloke

  • Posts: 1905
  • Joined: Sat Nov 02, 2019 11:49 pm
  • Location: UK
  • Real Name: Tom Jobbins

Re: Scripting - How to access Inspector properties??

PostThu Oct 28, 2021 7:26 am

From README.txt (Help menu -> Documentation -> Developer):

Code: Select all
TimelineItem
...
SetProperty(propertyKey, propertyValue)         --> Bool 
# Sets the value of property "propertyKey" to value "propertyValue"
# Refer to "Looking up Timeline item properties" for more information

GetProperty(propertyKey)                        --> int/[key:value]   
# returns the value of the specified key
# if no key is specified, the method returns a dictionary(python) or table(lua) for all supported keys
...

Looking up Timeline item properties
-----------------------------------
This section covers additional notes for the function "TimelineItem:SetProperty" and "TimelineItem:GetProperty". These functions are used to get and set properties mentioned.

The supported keys with their accepted values are:
  "Pan" : floating point values from -4.0*width to 4.0*width
  "Tilt" : floating point values from -4.0*height to 4.0*height
  "ZoomX" : floating point values from 0.0 to 100.0
  "ZoomY" : floating point values from 0.0 to 100.0
  "ZoomGang" : a boolean value
  "RotationAngle" : floating point values from -360.0 to 360.0
  "AnchorPointX" : floating point values from -4.0*width to 4.0*width
  "AnchorPointY" : floating point values from -4.0*height to 4.0*height
  "Pitch" : floating point values from -1.5 to 1.5
  "Yaw" : floating point values from -1.5 to 1.5
  "FlipX" : boolean value for flipping horizonally
  "FlipY" : boolean value for flipping vertically
  "CropLeft" : floating point values from 0.0 to width
  "CropRight" : floating point values from 0.0 to width
  "CropTop" : floating point values from 0.0 to height
  "CropBottom" : floating point values from 0.0 to height
  "CropSoftness" : floating point values from -100.0 to 100.0
  "CropRetain" : boolean value for "Retain Image Position" checkbox
  "DynamicZoomEase" : A value from the following constants
     - DYNAMIC_ZOOM_EASE_LINEAR = 0
     - DYNAMIC_ZOOM_EASE_IN
     - DYNAMIC_ZOOM_EASE_OUT
     - DYNAMIC_ZOOM_EASE_IN_AND_OUT
  "CompositeMode" : A value from the following constants
     - COMPOSITE_NORMAL = 0
     - COMPOSITE_ADD
     - COMPOSITE_SUBTRACT
     - COMPOSITE_DIFF
     - COMPOSITE_MULTIPLY
     - COMPOSITE_SCREEN
     - COMPOSITE_OVERLAY
     - COMPOSITE_HARDLIGHT
     - COMPOSITE_SOFTLIGHT
     - COMPOSITE_DARKEN
     - COMPOSITE_LIGHTEN
     - COMPOSITE_COLOR_DODGE
     - COMPOSITE_COLOR_BURN
     - COMPOSITE_HUE
     - COMPOSITE_SATURATE
     - COMPOSITE_COLORIZE
     - COMPOSITE_LUMA_MASK
     - COMPOSITE_DIVIDE
     - COMPOSITE_LINEAR_DODGE
     - COMPOSITE_LINEAR_BURN
     - COMPOSITE_LINEAR_LIGHT
     - COMPOSITE_VIVID_LIGHT
     - COMPOSITE_PIN_LIGHT
     - COMPOSITE_HARD_MIX
     - COMPOSITE_LIGHTER_COLOR
     - COMPOSITE_DARKER_COLOR
     - COMPOSITE_FOREGROUND
     - COMPOSITE_ALPHA
     - COMPOSITE_INVERTED_ALPHA
     - COMPOSITE_LUM
     - COMPOSITE_INVERTED_LUM
  "Opacity" : floating point value from 0.0 to 100.0
  "Distortion" : floating point value from -1.0 to 1.0
  "RetimeProcess" : A value from the following constants
     - RETIME_USE_PROJECT = 0
     - RETIME_NEAREST
     - RETIME_FRAME_BLEND
     - RETIME_OPTICAL_FLOW
  "MotionEstimation" : A value from the following constants
     - MOTION_EST_USE_PROJECT = 0
     - MOTION_EST_STANDARD_FASTER
     - MOTION_EST_STANDARD_BETTER
     - MOTION_EST_ENHANCED_FASTER
     - MOTION_EST_ENHANCED_BETTER
     - MOTION_EST_SPEED_WRAP
  "Scaling" : A value from the following constants
     - SCALE_USE_PRODUCT = 0
     - SCALE_CROP
     - SCALE_FIT
     - SCALE_FILL
     - SCALE_STRETCH
  "ResizeFilter" : A value from the following constants
     - RESIZE_FILTER_USE_FILTER = 0
     - RESIZE_FILTER_SHARPER
     - RESIZE_FILTER_SMOOTHER
     - RESIZE_FILTER_BICUBIC
     - RESIZE_FILTER_BILINEAR
     - RESIZE_FILTER_BESSEL
     - RESIZE_FILTER_BOX
     - RESIZE_FILTER_CATMULL_ROM
     - RESIZE_FILTER_CUBIC
     - RESIZE_FILTER_GAUSSIAN
     - RESIZE_FILTER_LANCZOS
     - RESIZE_FILTER_MITCHELL
     - RESIZE_FILTER_NEAREST_NEIGHBOR
     - RESIZE_FILTER_QUADRATIC
     - RESIZE_FILTER_SINC
     - RESIZE_FILTER_LINEAR
Values beyond the range will be clipped
width and height are same as the UI max limits

The arguments can be passed as a key and value pair or they can be grouped together into a dictionary (for python) or table (for lua) and passed
as a single argument.

Getting the values for the keys that uses constants will return the number which is in the constant.
Example:
Code: Select all
Lua> resolve = Resolve()
ms = resolve:GetMediaStorage()
projman = resolve:GetProjectManager()
proj = projman:GetCurrentProject()
mp = proj:GetMediaPool()
root = mp:GetRootFolder()
timeline = proj:GetCurrentTimeline()
videoitem = timeline:GetItemListInTrack("Video", 1)[1]

==videoitem:GetProperty()
table: 0x02b92b7818
   Pan = 0
   Tilt = 0
   ZoomX = 0.90000009536743
   ZoomY = 0.90000009536743
   ZoomGang = true
   RotationAngle = 0
   AnchorPointX = 0
   AnchorPointY = 0
   Pitch = 0
   Yaw = 0
   CropLeft = 0
   CropRight = 0
   CropTop = 0
   CropBottom = 0
   CropSoftness = 0
   CropRetain = false
   DynamicZoomEase = 0
   CompositeMode = 0
   Distortion = 0
   RetimeProcess = 0
   MotionEstimation = 0
   FlipY = false
   Opacity = 100
   FlipX = false
   ResizeFilter = 0
   Scaling = 0
==videoitem:GetProperty("ZoomX")
0.90000009536743
Lua> videoitem:SetProperty("ZoomX", 0.5)
Lua> ==videoitem:GetProperty("ZoomX")
0.5
Regarding Resolve's in-app scripting documentation, it's pretty limited, but for a better look at it, check out Roger Magnusson's script Class Browser: viewtopic.php?t=108048

It provides a nice UI for the in-built documentation, although it can only show descriptions if Resolve provides them, and for most of the Resolve API (as opposed to the Fusion API), it does not:
Image

There's also a community site that formats the documents in a nicer way, however it doesn't seem to have been updated recently: https://deric.github.io/DaVinciResolve-API-Docs/

There's also a pinned thread in this forum "Formatted Resolve Python API Docs", though it too hasn't yet been updated to 17.4: viewtopic.php?f=21&t=99270
Resolve Studio 17.4.3 and Fusion Studio 17.4.3 on macOS 11.6.1

Hackintosh:: X299, Intel i9-10980XE, 128GB DDR4, AMD 6900XT 16GB
Monitors: 1 x 3840x2160 & 3 x 1920x1200
Disk: 2TB NVMe + 4TB RAID0 NVMe; NAS: 36TB RAID6
BMD Speed Editor
Offline

tejpal

  • Posts: 2
  • Joined: Thu Oct 28, 2021 5:40 am
  • Real Name: Tejpal Singh

Re: Scripting - How to access Inspector properties??

PostThu Oct 28, 2021 7:31 am

Wow.. thank you so much!!! I was looking for this since the update came out.

Made my day!!

Regards,
Tej

Return to DaVinci Resolve

Who is online

Users browsing this forum: Bing [Bot], Dave Shortman, Google [Bot], panos_mts, Peter Chamberlain and 142 guests