Resolve Scripting Essentials

User avatar
Greg Bovine
Double M
Posts: 129
Joined: Fri Feb 02, 2018 6:07 am
Location: Oslo, Norway
Been thanked: 1 time
Contact:

Resolve Scripting Essentials

#1

Post by Greg Bovine » Mon Apr 02, 2018 12:00 pm

resolve-15-startup-splash-screen.png
Resolve 15 has added a new Fusion page to the video editing package. As part of this update Resolve also inherited Fusion's fuscript scripting system which allows you to write Lua, Python 2, and Python 3 based scripts that can run inside of Resolve 15.

Resolve's new scripting system is able to use the same UI Manager GUI building system as Fusion 9 does. This means the existing reference material on the WSL Thread "Building GUIs With Fusion's UI Manager" can be used in Resolve 15, too.

Fusion Console View

The easiest way to run is script you download from the internet is to drag a .lua or .py script file from your desktop into the Fusion page "Nodes" view. The script will be run automatically by Resolve. Any printed messages from the script will be shown in the Fusion page "Console" view.

You can display the Console window using the Fusion > Console menu.
resolve-fusion-console-menu.png
The Console window allows you to directly type in Lua or Python code using the input field at the bottom of the Console window. You can also paste in a block of code from your system's copy/paste clipboard buffer using the typical Command + V (macOS), or Control+V (Windows/Linux) hotkeys.

If you want to try out the Resolve 15 Fusion page scripting features for the first time you can type in the following Lua code to see details about the Fusion object, and the current composite:

Code: Select all

dump(fu:GetAttrs())
dump(comp:GetAttrs())
fusion-console-view.png
This results in the following text being output to the Console window:

Code: Select all

Lua> dump(fu:GetAttrs())
table: 0x0194f793f0
	FUSIONS_CLVendor = AMD
	FUSIONS_FileName = 
	FUSIONH_CurrentComp = Composition (0x0x199c8c400) [App: 'Fusion' on 127.0.0.1, UUID: ccd22b89-0324-4312-b054-0baf24b87e84]
	FUSIONI_PhysicalRAMTotalMB = 16384
	FUSIONS_CLVersion = OpenCL 1.2  1.2 (Mar 15 2018 21:59:57)
	FUSIONI_VersionLo = 7
	FUSIONS_MachineType = IA32
	FUSIONI_PhysicalRAMFreeMB = 7630
	FUSIONI_VersionHi = 983040
	FUSIONB_IsManager = false
	FUSIONS_Version = 15.0.0b.030
	FUSIONS_CLType = GPU
	FUSIONS_CLDevice = AMD Radeon R9 M370X Compute Engine
	FUSIONI_SerialHi = 0
	FUSIONI_VirtualRAMTotalMB = 18729
	FUSIONS_GLVendor = ATI Technologies Inc.
	FUSIONS_GLVersion = 2.1 ATI-1.66.31
	FUSIONI_VirtualRAMUsedMB = 11099
	FUSIONB_IsRenderNode = false
	FUSIONS_GLDevice = AMD Radeon R9 M370X OpenGL Engine
	FUSIONI_NumProcessors = 8
	FUSIONI_SerialLo = 0
	
Lua> dump(comp:GetAttrs())
table: 0x0194f7c5d0
	COMPN_LastFrameRendered = -2000000000
	COMPB_HiQ = true
	COMPI_RenderFlags = 131072
	COMPN_ElapsedTime = 0
	COMPN_AverageFrameTime = 0
	COMPB_Locked = false
	COMPB_Modified = false
	COMPN_TimeRemaining = 0
	COMPN_CurrentTime = 0
	COMPN_RenderEnd = 0
	COMPN_AudioOffset = 0
	COMPH_ActiveTool = Media In (0x0x1a2d2ce00) [App: 'Fusion' on 127.0.0.1, UUID: ccd22b89-0324-4312-b054-0baf24b87e84]
	COMPS_Name = 
	COMPN_GlobalStart = 0
	COMPI_RenderStep = 1
	COMPS_FileName = 
	COMPB_Rendering = false
	COMPN_RenderStartTime = 0
	COMPN_GlobalEnd = 0
	COMPN_RenderEndTime = 0
	COMPN_RenderStart = 0
	COMPN_LastFrameTime = 0
	COMPB_Proxy = false
	
Where I can run Lua and Python Scripts in Resolve?

You can run your own scripts in Resolve 15:
  • From the Console window
  • From the command prompt using the FuScript executable program
  • From the Scripts:/Comp folder using the Fusion > Scripts menu
  • From the Scripts:/Tool folder using the Nodes view right click > contextual menu
  • As intool scripts on nodes which is accessed in the Inspector view > Tools > Intool Script view
  • As Actions and Events that are stored inside of Config:/ PathMap based .fu files
  • As code inside of graphical fuses, or Console fuses
Resolve Local vs Network Scripting Access

If you open Resolve's System > Configuration section there is an External Scripting Using control that can be configured to allow remote systems to control and automate the Resolve GUI session using fuscript. You have the choice of selecting "None", "Local", or "Network" in this menu.
resolve-configuration-external-scripting-network.png
Resolve Command Line Scripting

Resolve 15's new scripting engine is implemented using the fuscript executable that was added by the addition of the new Fusion page. This fuscript program allow you to run a script via the command line that can control a Resolve graphical session either locally or remotely.

The fuscript executable can be found on Windows/Linux/MacOS systems. If you use fuscript frequently it can be handy to add the program to your system $PATH / %PATH% environment variable. This allows you to only have to type the words "fuscript" to launch the executable vs having to type the full absolute file path into the command line every time.

Here is a quick summary of the default location of FuScript on your Resolve 15 system:
  • /Applications/DaVinci Resolve/DaVinci Resolve.app/Contents/Libraries/Fusion/fuscript
  • /Program Files/Blackmagic Design/DaVinci Resolve/fuscript.exe
fuscript-command-prompt.png

Code: Select all

Usage: fuscript [opts] <script> [args]
   -i                   - Enter interactive mode
   -v                   - Print version information
   -s                   - Run as script server
   -S                   - Run as script server with no timeout
   -p [appname]         - Ping script apps
   -P [appname]         - Ping script apps (longer timeout)
   -q                   - Be quiet
   -b                   - Run with commandline debugger
   -l <lang>            - Explicitly set language, from:
      lua
      py2 or python2
      py3 or python3
   -x <string>          - Execute string
Here is an macOS command line example that launches a Lua script in Resolve 15 via FuScript:

Code: Select all

'/Applications/DaVinci Resolve/DaVinci Resolve.app/Contents/Libraries/Fusion/fuscript' -l lua  -x 'fusion = bmd.scriptapp("Fusion", "localhost");if fusion ~= nil then fu = fusion;app = fu;composition = fu.CurrentComp;comp = composition;SetActiveComp(comp) else print("[Error] Please open up the Fusion GUI before running this tool.") end;resolve = bmd.scriptapp("Resolve", "localhost");if resolve ~= nil then res = resolve;else print("[Error] Please open up the Fusion GUI before running this tool.") end; ' /Volumes/VFX/Resolve/Scripts/ListFiles.lua'
All of the extra code in this command prompt example is used to initialize the "fu:", "comp:", and "resolve:" objects in memory so external scripts can connect to the Resolve Project Manager, the Media Pool, the Fusion page composite session, and to be able to run UI Manager based GUIs. This FuScript based approach to running scripts allows you to quickly create new composites based upon external control.
You do not have the required permissions to view the files attached to this post.
Last edited by Greg Bovine on Tue Apr 10, 2018 3:20 pm, edited 8 times in total.

User avatar
Greg Bovine
Double M
Posts: 129
Joined: Fri Feb 02, 2018 6:07 am
Location: Oslo, Norway
Been thanked: 1 time
Contact:

Scripting Resolve Media Pools and Media Storage Volumes

#2

Post by Greg Bovine » Mon Apr 09, 2018 8:42 am

Zoom the Console Window Fontsize

If you are working with Resolve 15 on a large monitor it can help to zoom the text larger/smaller in the Console view. You can do this using the Command + Scroll Wheel (MacOS) hotkey. The Control + Scroll Wheel should work on Windows/Linux.

Scripting Resolve to Access the Media Pools

The following Resolve 15 Lua script snippets demonstrate how to automate the process of loading external media into the Media Pool, and interacting with the active Media Storage volumes.

ListVolumes

This Resolve 15 Fusion page based Lua script displays the active Media Storage volumes.
Code: [Select all] [Expand/Collapse] [Download] (ListVolumes.lua)
  1. --[[
  2. ListVolumes - v1 2018-04-09
  3. By Andrew Hazelden <andrew@andrewhazelden.com>
  4.  
  5. This Resolve 15 Fusion page based Lua script displays the active Media Storage volumes.
  6.  
  7. Script Output:
  8.  
  9. [Media Storage Volumes]
  10. table: 0x01fe96a8
  11.     1 = /Users/andrew/Movies
  12.     2 = /Volumes/BOOTCAMP
  13.     3 = /Volumes/PineHD
  14. --]]
  15.  
  16. -- Display the volumes attached to the system
  17. function ListVolumes()
  18.     local resolve = Resolve()
  19.     local ms = resolve:GetMediaStorage()
  20.     return ms:GetMountedVolumes()
  21. end
  22.  
  23. function Main()
  24.     -- Display the volumes attached to the system
  25.     print('\n[Media Storage Volumes]')
  26.     local vol = ListVolumes()
  27.     dump(vol)
  28. end
  29.  
  30. Main()
  31. print('[Done]')
  32.  


ListFiles

This Resolve 15 Fusion page based Lua script displays the active files in the Media Storage volumes.
Code: [Select all] [Expand/Collapse] [Download] (ListFiles.lua)
  1. --[[
  2. ListFiles - v1 2018-04-09
  3. By Andrew Hazelden <andrew@andrewhazelden.com>
  4.  
  5. This Resolve 15 Fusion page based Lua script displays the active files in the Media Storage volumes.
  6.  
  7. Script Output:
  8.  
  9. [Media Storage Files]
  10. table: 0x0d8103f8
  11.     1 = /Users/andrew/Movies/Resolve 15.mp4
  12. table: 0x0d77e138
  13. table: 0x0d8150b8
  14.     1 = /Volumes/PineHD/BTS.mp4
  15. [Done]
  16. --]]
  17.  
  18. -- Display the volumes attached to the system
  19. function ListVolumes()
  20.     local resolve = Resolve()
  21.     local ms = resolve:GetMediaStorage()
  22.     return ms:GetMountedVolumes()
  23. end
  24.  
  25. -- Display the files in root of the current media storage folder
  26. function ListFiles(index)
  27.     local resolve = Resolve()
  28.     local ms = resolve:GetMediaStorage()
  29.     local vol = ListVolumes()
  30.     return ms:GetFiles(vol[index])
  31. end
  32.  
  33. function Main()
  34.     -- The volumes attached to the system
  35.     local vol = ListVolumes()
  36.  
  37.     -- Display the files in the attached filesystem
  38.     print('\n[Media Storage Files]')
  39.     for i,val in ipairs(vol) do
  40.         local files = ListFiles(i)
  41.         dump(files)
  42.     end
  43. end
  44.  
  45. Main()
  46. print('[Done]')
  47.  


ListSubfolder

This Resolve 15 Fusion page based Lua script displays the subfolders in the Media Storage volumes.
Code: [Select all] [Expand/Collapse] [Download] (ListSubfolder.lua)
  1. --[[
  2. ListSubfolders.lua - v1 2018-04-09
  3. By Andrew Hazelden <andrew@andrewhazelden.com>
  4.  
  5. This Resolve 15 Fusion page based Lua script displays the subfolders in the Media Storage volumes.
  6.  
  7. Script Output:
  8.  
  9. [Media Storage Subfolders]
  10. ...
  11.  
  12. [Folder 3] /Volumes/PineHD 
  13. table: 0x07ae7bf8
  14.     1 = /Volumes/PineHD/Applications
  15.     2 = /Volumes/PineHD/Library
  16.     3 = /Volumes/PineHD/System
  17.     4 = /Volumes/PineHD/Users
  18.     5 = /Volumes/PineHD/Virtual Machines
  19.     6 = /Volumes/PineHD/etc
  20.     7 = /Volumes/PineHD/opt
  21.     8 = /Volumes/PineHD/tmp
  22.     9 = /Volumes/PineHD/var
  23.    
  24. --]]
  25.  
  26. -- Display the volumes attached to the system
  27. function ListVolumes()
  28.     local resolve = Resolve()
  29.     local ms = resolve:GetMediaStorage()
  30.     return ms:GetMountedVolumes()
  31. end
  32.  
  33. -- Display the subfolders in the MediaStorage
  34. function ListSubFolders(index)
  35.     local resolve = Resolve()
  36.     local ms = resolve:GetMediaStorage()
  37.     local vol = ListVolumes()
  38.     return ms:GetSubFolders(index)
  39. end
  40.  
  41. function Main()
  42.     -- The volumes attached to the system
  43.     local vol = ListVolumes()
  44.  
  45.     -- Display the files in the attached filesystem
  46.     print('\n[Media Storage Subfolders]')
  47.     for i,val in ipairs(vol) do
  48.         -- Display the subfolders in the Media Storage
  49.         print('\n\n[Folder ' .. i .. '] ', val)
  50.         local folders = ListSubFolders(val)
  51.         dump(folders)
  52.     end
  53. end
  54.  
  55. Main()
  56. print('[Done]')
  57.  


Add Folder to Media Pool
adding-footage-to-the-media-pool.png
This Resolve 15 Fusion page based Lua script scans the contents of a user specified folder for a specific file type and then adds the content to the Media Pool.
Code: [Select all] [Expand/Collapse] [Download] (Add Folder to Media Pool.lua)
  1. --[[
  2. Add Folder to Media Pool - v1 2018-04-09
  3. By Andrew Hazelden <andrew@andrewhazelden.com>
  4.  
  5. This Resolve 15 Fusion page based Lua script scans the contents of a user specified folder for a specific file type and then adds the content to the Media Pool.
  6.  
  7. Script Output:
  8.  
  9. [Media Storage Volumes]
  10. table: 0x01fe96a8
  11.     1 = /Users/andrew/Movies
  12.     2 = /Volumes/BOOTCAMP
  13.     3 = /Volumes/PineHD
  14. --]]
  15.  
  16. -- Add to footage to Media Pool using an absolute filepath
  17. function AddToMediaPool(filename)
  18.     local resolve = Resolve()
  19.     local ms = resolve:GetMediaStorage()
  20.     return ms:AddItemsToMediaPool(fusion:MapPath(filename))
  21. end
  22.  
  23. -- Add the footage from a folder to the Media Pool
  24. function AddFolderToMediaPool(folder, ext)
  25.     if folder and folder ~= '' then
  26.         -- Scan the folder
  27.         local path = fusion:MapPath(folder .. osSeparator .. '*.' .. ext)
  28.         local dir = bmd.readdir(path)
  29.         -- dump(dir)
  30.    
  31.         print('[Add Footage to Media Pool] ')
  32.         for i,v in ipairs(dir) do
  33.             if v.IsDir == false then
  34.                 filepath = folder .. osSeparator .. v.Name
  35.  
  36.                 -- Add each of the files in the folder to the Media Pool
  37.                 result = AddToMediaPool(filepath)
  38.                 print('  [' .. i .. '] ' .. filepath)
  39.             end
  40.         end
  41.     else
  42.         print('[Filepath Error] Please specify a folder and run this function again.')
  43.     end
  44. end
  45.  
  46. -- Where the magic happens
  47. function Main()
  48.     -- Add the platform specific folder slash character
  49.     osSeparator = package.config:sub(1,1)
  50.  
  51.     -- Scan a folder and add the footage to Media Pool using an absolute filepath
  52.     AddFolderToMediaPool('/Production/VFX/Resolve/Nokia Ozo+ Video Stitch', 'mp4')
  53.    
  54.     -- Add a specific file to the Media Pool using an absolute filepath
  55.     AddToMediaPool('/Production/VFX/Resolve/Nokia Ozo+ Video Stitch/Resolve-Stitched-Latlong-Stereo.0000.tif')
  56. end
  57.  
  58. Main()
  59. print('[Done]')
  60.  
You do not have the required permissions to view the files attached to this post.

User avatar
Greg Bovine
Double M
Posts: 129
Joined: Fri Feb 02, 2018 6:07 am
Location: Oslo, Norway
Been thanked: 1 time
Contact:

Resolve 15 Supports UI Manager GUIs

#3

Post by Greg Bovine » Tue Apr 10, 2018 2:34 pm

The new Resolve 15 scripting system supports the UI Manager GUI building system that was recently added to Fusion. UI Manager allows you to create native cross-platform compatible GUI for your Lua and Python scripts. This GUI toolkit is based upon the QT window manager.

If you want to start learning how UI Manager works the best thing to do is check out the WSL Reactor "Scripts/Comp" category and install the "UI Manager Lua Examples" atom package. This will get you started quickly with 48+ scripting examples.

There is a companion "Building GUIs With Fusion's UI Manager" tutorial series available:
viewtopic.php?p=10463#p10463

User avatar
Greg Bovine
Double M
Posts: 129
Joined: Fri Feb 02, 2018 6:07 am
Location: Oslo, Norway
Been thanked: 1 time
Contact:

Resolve API Scripting Help

#4

Post by Greg Bovine » Tue Apr 10, 2018 9:21 pm

The Fusion page scripting system in Resolve 15 has an interesting help function in the Lua language that allows you to see a list of the main Resolve API functions. These same base Resolve functions are also accessible using Python. With these commands you can automate switching between Resolve pages, add footage to your Media Pool, and load/save Resolve projects in the Project Manager.


You can run this Lua script in the Fusion page Console:
Code: [Select all] [Expand/Collapse] [Download] (ResolveAPI Functions.lua)
  1. -- List the Resolve API Features
  2. resolve = Resolve()
  3. dump(resolve:GetHelp('ResolveScriptable'))
  4. dump(resolve:GetHelp('Timeline'))
  5. dump(resolve:GetHelp('Timeline item'))
  6. dump(resolve:GetHelp('Media pool item'))
  7. dump(resolve:GetHelp('Folder'))
  8. dump(resolve:GetHelp('MediaPool'))
  9. dump(resolve:GetHelp('Project'))
  10. dump(resolve:GetHelp('Resolve'))
  11. dump(resolve:GetHelp('ProjectManager'))
  12. dump(resolve:GetHelp('MediaStorage'))
  13. dump(resolve:GetHelp('ScriptServer'))
  14. dump(resolve:GetHelp('ScriptServerObject'))
resolve-console-api-help-text.png

Running the code resulted in the following Console output text:
Code: [Select all] [Expand/Collapse] [Download] (Resolve API Functions Output.txt)
  1. ResolveScriptable Members:
  2.   ResolveScriptable:Print()
  3.   :GetApp()
  4.   :GetAttrs()
  5.   :GetHelp()
  6.   :GetHelpRaw()
  7.   :SetAttrs()
  8.  
  9. Resolve Members:
  10.   Resolve:Fusion()
  11.   Resolve:GetMediaStorage()
  12.   Resolve:GetProjectManager()
  13.   Resolve:OpenPage()
  14.   ResolveScriptable:Print()
  15.   :GetApp()
  16.   :GetAttrs()
  17.   :GetHelp()
  18.   :GetHelpRaw()
  19.   :SetAttrs()
  20.  
  21. ProjectManager Members:
  22.   ProjectManager:CreateProject()
  23.   ProjectManager:GetCurrentProject()
  24.   ProjectManager:LoadProject()
  25.   ProjectManager:SaveProject()
  26.   ResolveScriptable:Print()
  27.   :GetApp()
  28.   :GetAttrs()
  29.   :GetHelp()
  30.   :GetHelpRaw()
  31.   :SetAttrs()
  32.  
  33. MediaStorage Members:
  34.   MediaStorage:AddItemsToMediaPool()
  35.   MediaStorage:GetFiles()
  36.   MediaStorage:GetMountedVolumes()
  37.   MediaStorage:GetSubFolders()
  38.   MediaStorage:RevealInStorage()
  39.   ResolveScriptable:Print()
  40.   :GetApp()
  41.   :GetAttrs()
  42.   :GetHelp()
  43.   :GetHelpRaw()
  44.   :SetAttrs()
FusionScript Help Browser

ui-manager-fusion-script-help-browser.png

If you are adventurous and want to go deeper into Resolve scripting, you can download the FusionScript Help Browser example from the WSL UI Manager thread. This script will let you visually use a GUI to browse the scriptable classes that are available in Resolve 15.

The FusionScript Help Browser Lua script is able to be run in Resolve 15 by dragging the script into the "Nodes" view. You could also adding it to the "Scripts:/Comp/ PathMap folder location and restart Resolve so it shows up in the "Fusion > Scripts > menu in the Fusion page.

You can search in this window for the following members:

Code: Select all

ResolveScriptable
Timeline
Timeline item
Media pool item
Folder
MediaPool
Project
Resolve
ProjectManager
MediaStorage
ScriptServer
ScriptServerObject
You do not have the required permissions to view the files attached to this post.
Last edited by Greg Bovine on Tue Apr 10, 2018 9:40 pm, edited 6 times in total.

User avatar
Greg Bovine
Double M
Posts: 129
Joined: Fri Feb 02, 2018 6:07 am
Location: Oslo, Norway
Been thanked: 1 time
Contact:

Re: Resolve Scripting Essentials

#5

Post by Greg Bovine » Tue Apr 10, 2018 9:21 pm

placeholder

User avatar
Greg Bovine
Double M
Posts: 129
Joined: Fri Feb 02, 2018 6:07 am
Location: Oslo, Norway
Been thanked: 1 time
Contact:

Installing Effects Library Templates in Resolve

#6

Post by Greg Bovine » Tue Apr 10, 2018 10:02 pm

Resolve 15 allows you to create macros that can be used as video title templates in the Edit page, or as Fusion page node based snippets that can be easily added to a composite using the Effects Library view:

resolve-effects-library.png

If you have any pre-existing macros or templates from earlier copies of Fusion you can add them to this view with a manual installation technique as long as the macro don't rely on Resolve 15 unsupported nodes like Loaders/Savers/Primatte.

Page 276 in the "DaVinci Resolve Manual.pdf" guide that is included with Resolve 15's Public Beta has a chapter with more details on using and making Resolve "Templates", and "Title Templates".

In this screenshot I placed several 3rd party Fusion macros into Resolve's Templates:/Edit/ and Templates:/Fusion/ PathMap folders. The next time Resolve was rebooted the custom macros were accessible in the Effects Library.

kartavr-effects-library-templates.png

Installing the Macros

If you have any pre-existing Macro .setting files from Fusion/Fusion studio that you would like to have show up in Resolve's Effects Library > Templates section you can do that by placing the content into a Templates:/ PathMap based sub-folder location like the following paths:

Windows Templates

Code: Select all

C:\ProgramData\Blackmagic Design\DaVinci Resolve\Fusion\Templates\Edit\
C:\ProgramData\Blackmagic Design\DaVinci Resolve\Fusion\Templates\Fusion\

or 

%appdata%\Blackmagic Design\Blackmagic Design\DaVinci Resolve\Fusion\Templates\Edit\
%appdata%\Blackmagic Design\Blackmagic Design\DaVinci Resolve\Fusion\Templates\ Fusion\
macOS Templates

Code: Select all

/Library/Application Support/Blackmagic Design/DaVinci Resolve/Fusion/Templates/Edit/
/Library/Application Support/Blackmagic Design/DaVinci Resolve/Fusion/Templates/Fusion/

or

$HOME/Library/Application Support/Blackmagic Design/DaVinci Resolve/Fusion/Templates/Edit/
$HOME/Library/Application Support/Blackmagic Design/DaVinci Resolve/Fusion/Templates/Fusion/
Linux Templates

Code: Select all

/var/BlackmagicDesign/DaVinci Resolve/Fusion/Templates/Edit/
/var/BlackmagicDesign/DaVinci Resolve/Fusion/Templates/Fusion/
You do not have the required permissions to view the files attached to this post.
Last edited by Greg Bovine on Fri Jun 08, 2018 9:57 pm, edited 3 times in total.

User avatar
Greg Bovine
Double M
Posts: 129
Joined: Fri Feb 02, 2018 6:07 am
Location: Oslo, Norway
Been thanked: 1 time
Contact:

Re: Resolve Scripting Essentials

#7

Post by Greg Bovine » Tue Apr 10, 2018 10:05 pm

placeholder

User avatar
Greg Bovine
Double M
Posts: 129
Joined: Fri Feb 02, 2018 6:07 am
Location: Oslo, Norway
Been thanked: 1 time
Contact:

Resolve is just a GUI to an Sqlite3 Media Database

#8

Post by Greg Bovine » Tue Apr 10, 2018 10:28 pm

As a fun R&D note, Resolve uses Sqlite3 formatted databases to store a lot of its own internal settings and records for a video editing project. This detail means you you can use Sqlite3 from the command prompt or from a Lua/Python script to directly probe and read the Resolve project databases and other .db files without needing to even start up Resolve.

resolve-disk-database-folder-resolve-projects.png

With this approach you could go even lower level then Resolve's own scripting API provides if you wanted to delve into reading any setting that is saved into any of Resolve's locally stored .db files. This is something you would only want to do in a read only fashion as you could have database integrity errors if you tried modifying the database live while Resolve is running.

Sqlite3 is a cross-platform command line based database engine that is open source with a public domain license. Sqlite3 can be accessed from Lua using os.execute(), and from a Python script in Fusion. It is possible to use any number of Sqlite3 wrapper scripts for Lua and Python that can make it easier to use as part of a regular scripted workflow.


The free cross-platform "DB Browser for SQLite" tool is a good place to start if you are searching through the Resolve .db files for details:
http://sqlitebrowser.org


Sqlite3 Installation Notes

Sqlite3 Project
https://sqlite.org/

Sqlite3 Dccumentation
http://sqlite.org/docs.html

Sqlite3 Manual Installation

Windows Manual Install

You can manually download Sqlite3 from the "Precompiled Binaries for Windows" section:
http://sqlite.org/download.html

macOS Manual Install
Sqlite3 comes pre-installed with macOS.

Linux Manual Install
Linux users can install Sqlite3 using yum, apt-get, or pacman.

Ubuntu Manual Install

Code: Select all

sudo apt-get install sqlite3 libsqlite3-dev

Sqlite3 Usage Examples

These macOS based examples show how Sqlite3 can be used from a BASH command prompt to open Resolve Project.db files.

When you are researching new SQL commands it is helpful to have the ".header on" and ".mode column" tags added so you can get an idea of the data structure visually. Once you know the final search query to use you can remove those arguments from your queries to simplify the output.

Example 1 - List the Resolve Project Name and Timeline Video Clips

Code: Select all

sqlite3 "/Library/Application Support/Blackmagic Design/DaVinci Resolve/Resolve Disk Database/Resolve Projects/Users/guest/Projects/Ozo Stitch/Project.db" ".header on" ".mode column" "SELECT ProjectName FROM SM_Project;" "SELECT Name, MediaFilePath, Start, Duration FROM Sm2TiItem WHERE DbType = 'Sm2TiVideoClip';"

Example 1 Output:

Code: Select all

ProjectName
-----------
Ozo Stitch

Name        MediaFilePath                                             Start       Duration  
----------  --------------------------------------------------------  ----------  ----------
cam8.mp4    /Production/VFX/Resolve/Nokia Ozo+ Video Stitch/cam8.mp4  86400       268      


Example 2 - List the Resolve Media Pool Video Clips

Code: Select all

sqlite3 "/Library/Application Support/Blackmagic Design/DaVinci Resolve/Resolve Disk Database/Resolve Projects/Users/guest/Projects/Ozo Stitch/Project.db" ".header on" ".mode column" "SELECT Name, DbType, UniqueMediaPoolItemId FROM Sm2MPMedia WHERE DbType = 'Sm2MpVideoClip';"

Example 2 Output:

Code: Select all

Name        DbType          UniqueMediaPoolItemId               
----------  --------------  ------------------------------------
cam3.mp4    Sm2MpVideoClip  2027c029-5a32-48be-9d94-9665090c37a5
cam6.mp4    Sm2MpVideoClip  c8017708-2d00-4a65-90dd-e33cd0408e88
cam2.mp4    Sm2MpVideoClip  fac1bcac-4fb7-4ca4-8e1d-2407bddf74f5
cam7.mp4    Sm2MpVideoClip  c2596427-2bd3-4ab5-996c-b97d3db93942
cam8.mp4    Sm2MpVideoClip  ad9b2904-c5a9-4e3a-a579-b8f5c3998c50
cam5.mp4    Sm2MpVideoClip  2d18b9c7-f1f1-4bae-b3e5-8dcbe6cc1d65
cam1.mp4    Sm2MpVideoClip  2d002633-2e23-4169-a938-d7291f7c15c3
cam4.mp4    Sm2MpVideoClip  97841817-6456-4784-9362-7455e835197b

Example 3 - Resolve Direct DB Media Access Script
resolve-console-reporting-sqlite3-db-output.png
You can also peek into the active Resolve project .db database file using Lua with a script like this (or you could also use lua sqlite3 bindings if you are fancy). This script has only been tested on macOS. Windows and Linux users might have to edit the filepaths to sqlite3 and change other aspects of the code.
Code: [Select all] [Expand/Collapse] [Download] (Resolve Direct DB Media Access.lua)
  1. --[[--
  2. [Resolve Direct DB Media Access]
  3. [Created By] Andrew Hazelden <andrew@andrewhazelden.com>
  4.  
  5. ## Script Usage ##
  6.  
  7. fuscript -l lua "$HOME/Desktop/Resolve Direct DB Media Access.lua"
  8.  
  9. ## Example Output ##
  10.  
  11. [Fusion 3D System]
  12.   [1] "autumn_sunrise.jpg" [UUID] 41134066-b91c-4bf5-9d5c-e12ecbe77283
  13.  
  14.  
  15. [Ozo Stitch]
  16.   [1] "cam3.mp4" [UUID] 2027c029-5a32-48be-9d94-9665090c37a5
  17.   [2] "cam6.mp4" [UUID] c8017708-2d00-4a65-90dd-e33cd0408e88
  18.   [3] "cam2.mp4" [UUID] fac1bcac-4fb7-4ca4-8e1d-2407bddf74f5
  19.   [4] "cam7.mp4" [UUID] c2596427-2bd3-4ab5-996c-b97d3db93942
  20.   [5] "cam8.mp4" [UUID] ad9b2904-c5a9-4e3a-a579-b8f5c3998c50
  21.   [6] "cam5.mp4" [UUID] 2d18b9c7-f1f1-4bae-b3e5-8dcbe6cc1d65
  22.   [7] "cam1.mp4" [UUID] 2d002633-2e23-4169-a938-d7291f7c15c3
  23.   [8] "cam4.mp4" [UUID] 97841817-6456-4784-9362-7455e835197b
  24.  
  25.  
  26. [Image Sequences]
  27.   [1] "v54_p-90_y140.[1-20].jpg" [UUID] 2cc9cd8b-1cef-44bc-8be5-0558cc128578
  28.  
  29.  
  30. ## Install Notes ##
  31.  
  32. macOS:
  33. sqlite3 is pre-installed
  34.  
  35. Linux:
  36. sudo apt-get install sqlite3 libsqlite3-dev
  37.  
  38. Windows:
  39. sqlite3 needs to be manually installed and added to the Windows %PATH% env var
  40.  
  41. --]]--
  42.  
  43. -- ------------------------------------------------------
  44. -- Variables
  45.  
  46. _VERSION = 1.0
  47. _AUTHOR = 'Andrew Hazelden <andrew@andrewhazelden.com>'
  48. _DATE = '2018-03-29'
  49.  
  50. -- ------------------------------------------------------
  51. -- Open the database and scan for media files
  52. function ScanProjectDB(dbFile)
  53.     dbFilepath = resolveProjectsFolder .. dbFile .. '/Project.db'
  54.  
  55.     -- Read the Resolve sqlite3 database
  56.     dbCommand = [["]] ..dbProgram .. [[" "]] .. dbFilepath .. [[" ".header off" "SELECT Name, DbType, UniqueMediaPoolItemId FROM Sm2MPMedia WHERE DbType = 'Sm2MpVideoClip';"]]
  57.     -- print('[Command] ' .. dbCommand)
  58.  
  59.     -- List the output
  60.     print('[' .. dbFile .. ']')
  61.     i = 0
  62.     for files in io.popen(dbCommand):lines() do
  63.         i = i + 1
  64.         filename, format, uuid = string.match(files, '^(.*)|(.*)|(.*)$')
  65.         print('  ['.. i  .. '] "'.. filename .. '" [UUID] ' .. uuid)
  66.         -- Result: [1] "cam3.mp4" [UUID] 2027c029-5a32-48be-9d94-9665090c37a5
  67.     end
  68.     print('\n')
  69. end
  70.  
  71.  
  72. function Main()
  73.     print('[Resolve Media Access] v' .. _VERSION .. ' ' .. _DATE)
  74.     print('[Created By] ' .. _AUTHOR)
  75.     print('---------------------------------------------------------\n')
  76.  
  77.     -- Find out the current Fusion host platform (Windows/Mac/Linux)
  78.     platform = (FuPLATFORM_WINDOWS and "Windows") or (FuPLATFORM_MAC and "Mac") or (FuPLATFORM_LINUX and "Linux")
  79.  
  80.     if platform == "Windows" then
  81.         -- Running on Windows
  82.         resolvePrefsFolder = 'C:\\ProgramData\\Blackmagic Design\\DaVinci Resolve\\'
  83.         resolveProjectsFolder = resolvePrefsFolder .. 'Support\\Resolve Disk Database\\Resolve Projects\\Users\\guest\\Projects\\'
  84.         dbProgram = 'sqlite3'
  85.     elseif platform == "Mac" then
  86.         -- Running on Mac
  87.         resolvePrefsFolder = '/Library/Application Support/Blackmagic Design/DaVinci Resolve/'
  88.         resolveProjectsFolder = resolvePrefsFolder .. 'Resolve Disk Database/Resolve Projects/Users/guest/Projects/'
  89.         dbProgram = '/usr/bin/sqlite3'
  90.     elseif platform == "Linux" then
  91.         -- Running on Linux
  92.         resolvePrefsFolder = '/opt/resolve/'
  93.         resolveProjectsFolder = resolvePrefsFolder .. 'Resolve Disk Database/Resolve Projects/Users/guest/Projects/'
  94.         dbProgram = '/usr/bin/sqlite3'
  95.     else
  96.         print("[Error] There is an invalid Fusion platform detected\n")
  97.         return
  98.     end
  99.  
  100.     -- Scan the Resolve Projects folder
  101.     local dirList = bmd.readdir(resolveProjectsFolder .. '*')
  102.     -- dump(dirList)
  103.  
  104.     -- Extract the media details for each database
  105.     for i, f in ipairs(dirList) do
  106.         if f.IsDir == true then
  107.             ScanProjectDB(f.Name)
  108.         end
  109.     end
  110. end
  111.  
  112. Main()
  113. print('[Done]')

Example 3 Output:

Code: Select all


[Fusion 3D System]
  [1] "autumn_sunrise.jpg" [UUID] 41134066-b91c-4bf5-9d5c-e12ecbe77283


[Ozo Stitch]
  [1] "cam3.mp4" [UUID] 2027c029-5a32-48be-9d94-9665090c37a5
  [2] "cam6.mp4" [UUID] c8017708-2d00-4a65-90dd-e33cd0408e88
  [3] "cam2.mp4" [UUID] fac1bcac-4fb7-4ca4-8e1d-2407bddf74f5
  [4] "cam7.mp4" [UUID] c2596427-2bd3-4ab5-996c-b97d3db93942
  [5] "cam8.mp4" [UUID] ad9b2904-c5a9-4e3a-a579-b8f5c3998c50
  [6] "cam5.mp4" [UUID] 2d18b9c7-f1f1-4bae-b3e5-8dcbe6cc1d65
  [7] "cam1.mp4" [UUID] 2d002633-2e23-4169-a938-d7291f7c15c3
  [8] "cam4.mp4" [UUID] 97841817-6456-4784-9362-7455e835197b


[Image Sequences]
  [1] "v54_p-90_y140.[1-20].jpg" [UUID] 2cc9cd8b-1cef-44bc-8be5-0558cc128578

You do not have the required permissions to view the files attached to this post.

User avatar
SirEdric
Fusionator
Posts: 1636
Joined: Tue Aug 05, 2014 10:04 am
Answers: 1
Been thanked: 57 times
Contact:

Re: Resolve Scripting Essentials

#9

Post by SirEdric » Tue Apr 10, 2018 11:23 pm

Man!
Cool!
<speechless>

statixvfx
Posts: 31
Joined: Mon Aug 07, 2017 10:00 am

Re: Resolve Scripting Essentials

#10

Post by statixvfx » Wed Apr 11, 2018 12:36 am

Fantastic work brother! You're doing god's BMD's work !

User avatar
Dunn
Moderator
Posts: 474
Joined: Mon Aug 04, 2014 4:27 am
Location: Hamburg, Germany
Been thanked: 2 times
Contact:

Re: Resolve Scripting Essentials

#11

Post by Dunn » Wed Apr 11, 2018 2:14 am

Awesome stuff Greg! Thanks for all the hard work. !
.. do you know if the UI Manager is now using Qt5 or still 4.8 ? the buttons suddenly look all rounded.

User avatar
Greg Bovine
Double M
Posts: 129
Joined: Fri Feb 02, 2018 6:07 am
Location: Oslo, Norway
Been thanked: 1 time
Contact:

UI Manager GUI Controls in Resolve

#12

Post by Greg Bovine » Wed Apr 11, 2018 5:56 am

Dunn wrote:
Wed Apr 11, 2018 2:14 am
Awesome stuff Greg! Thanks for all the hard work. !
.. do you know if the UI Manager is now using Qt5 or still 4.8 ? the buttons suddenly look all rounded.
Hi Dunn.

UI Manager scripts that are run inside of Resolve automatically take on the same "themed" look as Resolve uses for it's own GUI controls. It's not really a QT version thing but merely the UX design of Resolve being applied to UI Manager based scripts.

In the private beta version of Resolve 15 the UI Manager created ui:Buttons were square originally with a very hard bevel. Then in the public beta version of Resolve we now get to have the same type of rounded buttons as you would find in the Resolve preferences window.

Here's a few UI screenshots to show what Lua script GUIs look like in Resolve 15:

Reactor Atomizer v1.4 Beta

reactor-atomizer-gui.png

Lua UI Manager Examples - FileDialogs.lua

lua-ui-manager-examples-filedialogs.png

Lua UI Manager Examples - Action Listener.lua

lua-ui-manager-examples-action-listener.png

Lua UI Manager Examples - OFX Blacklist Generator.lua

lua-ui-manager-examples-ofx-blacklist-generator.png
You do not have the required permissions to view the files attached to this post.

User avatar
JUNE
Fusioneer
Posts: 212
Joined: Wed Aug 06, 2014 5:45 am
Been thanked: 9 times
Contact:

Re: Resolve Scripting Essentials

#13

Post by JUNE » Wed Apr 11, 2018 6:48 am

well done,great job

User avatar
Greg Bovine
Double M
Posts: 129
Joined: Fri Feb 02, 2018 6:07 am
Location: Oslo, Norway
Been thanked: 1 time
Contact:

Opening External URLs, Files, and Folders

#14

Post by Greg Bovine » Wed Apr 11, 2018 9:59 am

If you are making a custom pipeline tool it can sometimes be handy to be able to guide the user on the next step to carry out.

This could be letting the user know they need to install an additional piece of software, showing the output folder where media has been exported to, opening up a log text file that was saved to disk by your script, opening up the related HTML or PDF documentation for your tool, or showing the final movie export / rendered image when a task completes.

In all of these cases you likely know the filepath or webpage URL that you want to open. What you might not have is the knowledge of how to do the URL/filepath launching action consistently on Windows/macOS/Linux. The typical Lua based approach in the past would be to use the Lua shell launching command "os.execute()" with your own concoction of custom file/folder/URL launching strings done uniquely for each of the supported host OS platforms were your script can be run from.

Thinking Cross-platform

Before we go into details on the actual scripts for opening files and URLs it is handy to know that you can get your Lua script to report the current operating system's native folder path "slash" direction using the following Lua command:


Slash Direction

Code: [Select all] [Expand/Collapse] [Download] (SlashDirection.lua)
  1. -- Add the platform specific folder slash character
  2. osSeparator = package.config:sub(1,1)
  3. print('[Slash Direction] ' .. osSeparator .. '\n')
  4.  

Finding out the active slash direction is handy if you want to build a custom filepath and need to keep the folder separators consistent. This saves having to use a Lua pattern based command later on to try and normalize the slashes so they are consistent.
SlashDirection.png

Platform


When using the Lua scripting system in Fusion 9 and Resolve 15 it can be helpful to check the current host operating system platform before running any code that might be OS specific:

  1. -- Check the current computer platform
  2. local platform = (FuPLATFORM_WINDOWS and 'Windows') or (FuPLATFORM_MAC and 'Mac') or (FuPLATFORM_LINUX and 'Linux')
  3.  
  4. -- Add the platform specific folder slash character
  5. osSeparator = package.config:sub(1,1)
  6.  
  7. -- Find the user's home folder location using the OS native environment variable on Windows/Mac/Linux
  8. if platform == 'Windows' then
  9.     homeFolder = tostring(os.getenv('USERPROFILE')) .. osSeparator
  10. elseif platform == 'Mac' then
  11.     homeFolder = tostring(os.getenv('HOME')) .. osSeparator
  12. elseif platform  == 'Linux' then
  13.     homeFolder = tostring(os.getenv('HOME')) .. osSeparator
  14. end
  15.  
  16. print(homeFolder)
  17.  

PathMap Lookups

If you want to take advantage of Fusion's PathMap based relative filepaths then the "MapPath" function comes in handy. You can run the PathMap conversion function in the current composite (comp:) or global (fusion:) scope. The composite scope means any custom settings defined in an individual Fusion 9 .comp file are utilized.

pathmap-comp-scope.png
Code: [Select all] [Expand/Collapse] [Download] (PathMap Comp Scope.lua)
  1. -- Convert a PathMap using the global + comp based PathMap settings
  2. path = comp:MapPath('Brushes:/smile.tga')
  3. print(path)
  4.  

or
Code: [Select all] [Expand/Collapse] [Download] (PathMap Global Scope.lua)
  1. -- Convert a PathMap using just global PathMap settings
  2. path = fusion:MapPath('Profile:/RenderNode.prefs')
  3. print(path)
  4.  

Active Composite Filepath

There are several ways to find out the filepath for the active composite. If you are gong to use this to discover the absolute filepath for a item in the same folder a PathMap lookup works well. In Fusion 9 this command would tell you where a file was relative to the current open Fusion composite:
Code: [Select all] [Expand/Collapse] [Download] (Active Composite Filepath.lua)
  1. -- Find out the location of an asset relative to the active composite file on disk
  2. dump(comp:MapPath('Comp:/Render/output.mp4'))
  3.  
Note: In Resolve 15's Fusion page environment the "Comp:/" PathMap location is translated to:

Code: Select all

$HOME/Documents/Blackmagic Design/DaVinci Resolve/Fusion/

Open URLs

The Resolve API has added a new Lua script function that makes it easy to have a script open a webpage URL in the default web browser.

  1. -- Open a webpage URL in the default web browser
  2. if bmd.openurl then
  3.     url = 'https://www.steakunderwater.com'
  4.     bmd.openurl(url)
  5.     print('[Opening URL] ' .. url .. '\n')
  6. end
  7.  
OpenURL.png
Note: The new "bmd.openurl()" function is not present in Fusion 9. The "if" check in the code snippet is used to make sure legacy copies of the Fuscript API in Fusion 7-9 don't stop and abort running the rest of your Lua script code with an error message "[string "???"]:2: attempt to call field 'openurl' (a nil value)[/i" when this URL opening command is used.


Open Files Externally and Folders


The Resolve API and Fusion 9 both support a new "bmd.openfileexternal()" function that allows you to open files using their default handler program.


  1. -- Open a filepath in the default program
  2.  
  3. -- Convert the PathMap
  4. path = comp:MapPath('Brushes:/smile.tga')
  5.  
  6. -- Open the folder view
  7. if bmd.fileexists(path) then
  8.     bmd.openfileexternal('Open', path)
  9.     print('[Opening File] ' .. path .. '\n')
  10. end
  11.  
OpenFile.png

Open Folders Externally


If you specify a folder name when running the "bmd.openfileexternal()" function then a desktop folder view will be opened up using Explorer(Windows) / Finder(macOS) / Nautilius(Linux).

Code: [Select all] [Expand/Collapse] [Download] (OpenFolder.lua)
  1. -- Open a folder using the desktop folder view
  2.  
  3. -- Add the platform specific folder slash character
  4. osSeparator = package.config:sub(1,1)
  5.  
  6. -- Convert the PathMap and extract just the foldername from the filepath
  7. path = comp:MapPath('Reactor:/Deploy/'):match('(.*' .. osSeparator .. ')')
  8.  
  9. -- Open the folder view
  10. if bmd.fileexists(path) then
  11.     bmd.openfileexternal('Open', path)
  12.     print('[Opening Folder] ' .. path .. '\n')
  13. end
  14.  
OpenFolder.png
You do not have the required permissions to view the files attached to this post.

User avatar
Greg Bovine
Double M
Posts: 129
Joined: Fri Feb 02, 2018 6:07 am
Location: Oslo, Norway
Been thanked: 1 time
Contact:

Viewing the Fusion API Functions in Resolve

#15

Post by Greg Bovine » Wed Apr 11, 2018 1:54 pm

Printing out the Fusion Functions

Just like the GetHelp command was able to be used to list the Resolve API commands, you can also use GetHelp to list the Fusion page API functions, too. Some of these commands reported would be undocumented internal functions used by Fusion, or were only described briefly in an old Eyeon era Fusion user manual / VFXpedia website archive / Fusion 6.4 - 7.7 bundled Lua script examples.

This Lua script is used to list the built-in "fusion:" and "comp:" pointer based functions:
Code: [Select all] [Expand/Collapse] [Download] (FusionAPI.lua)
  1. dump(fusion:GetHelp('Fusion'))
  2. dump(comp:GetHelp('Composition'))
  3.  
The Console text that comes back lists all of the built-in Fusion functions you would need to interact with your Fusion page composite:
Code: [Select all] [Expand/Collapse] [Download] (FusionAPI Output.txt)
  1. dump(comp:GetHelp("Composition"))
  2. Composition Members:
  3.   Composition:AbortRender()
  4.   Composition:AbortRenderUI()
  5.   Composition.ActiveTool [R]          - Represents the currently active tool on this comp
  6.   Composition:AddSettingAction()      - Adds a .settings to the comp
  7.   Composition:AddTool()               - Adds a tool to the comp at a given position
  8.   Composition:AddToolAction()         - Adds a tool to the comp
  9.   Composition:AskRenderSettings()
  10.   Composition:AskUser()               - Present a custom dialog to the user, and return selected values
  11.   Composition.AutoPos [RW]
  12.   Composition:ChooseAction()          - Displays a dialog with a list of selectable actions
  13.   Composition:ChooseTool()            - Displays a dialog with a list of selectable tools
  14.   Composition:ClearUndo()             - Clears the Undo/Redo history
  15.   Composition:Close()                 - Close the composition
  16.   Composition:Copy()                  - Copy a list of tools to the Clipboard
  17.   Composition:CopySettings()          - Copy a list of tools to a settings table
  18.   Composition.CurrentFrame [R]        - Represents the currently active frame for this composition
  19.   Composition.CurrentTime [RW]        - The current time position for this composition
  20.   Composition:DisableSelectedTools()  - Pass-through the selected tools
  21.   Composition:EndUndo()               - End an undo event
  22.   Composition:Execute()
  23.   Composition:ExpandZone()
  24.   Composition:FindTool()              - Finds first tool by name
  25.   Composition:FindToolByID()          - Finds tools of a given type
  26.   Composition:GetCompPathMap()        - Returns a table of all Composition path maps
  27.   Composition:GetConsoleHistory()
  28.   Composition:GetData()               - Get custom persistent data
  29.   Composition:GetFrameList()
  30.   Composition:GetNextKeyTime()        - Gets the next key time
  31.   Composition:GetPrefs()              - Retrieve a table of preferences
  32.   Composition:GetPrevKeyTime()        - Gets the previous key time
  33.   Composition:GetPreviewList()        - Retrieves a table of previews
  34.   Composition:GetRedoStack()
  35.   Composition:GetToolList()           - Returns a list of all tools, or selected tools, in the composition
  36.   Composition:GetUndoStack()
  37.   Composition:GetViewList()
  38.   Composition:Heartbeat()
  39.   Composition:IsLocked()
  40.   Composition:IsPlaying()
  41.   Composition:IsReadOnly()
  42.   Composition:IsRendering()
  43.   Composition:IsViewShowing()
  44.   Composition:IsZoneExpanded()
  45.   Composition:Lock()                  - Lock the composition from updating
  46.   Composition:Loop()                  - Enables looping interactive playback
  47.   Composition:MapPath()               - Expands path mappings in a path string
  48.   Composition:MapPathSegments()       - Expands all path mappings in a multipath
  49.   Composition:NetRenderAbort()
  50.   Composition:NetRenderEnd()
  51.   Composition:NetRenderStart()
  52.   Composition:NetRenderTime()
  53.   Composition:Paste()                 - Paste tools from the Clipboard
  54.   Composition:Play()                  - Starts interactive playback
  55.   Composition:Print()
  56.   Composition:Redo()                  - Redo one or more changes to the composition
  57.   Composition:Render()                - Start a render
  58.   Composition:ReverseMapPath()        - Collapses a path into best-matching path map
  59.   Composition:RunScript()             - Run a script
  60.   Composition:Save()                  - Save the composition
  61.   Composition:SaveAs()                - Save the composition
  62.   Composition:SaveCopyAs()            - Save a copy of the composition
  63.   Composition:SaveVersion()           - Save the composition
  64.   Composition:SetActiveTool()         - Set the currently active tool
  65.   Composition:SetData()               - Set custom persistent data
  66.   Composition:SetPrefs()              - Set preferences from a table of attributes
  67.   Composition:SetReadOnly()
  68.   Composition:ShowView()
  69.   Composition:StartUndo()             - Start an undo event
  70.   Composition:Stop()                  - Stops interactive playback
  71.   Composition:Undo()                  - Undo one or more changes to the composition
  72.   Composition:Unlock()                - Unlock the composition
  73.   Composition.UpdateMode [RW]
  74.   Composition:UpdateViews()
  75.   Composition.XPos [RW]
  76.   Composition.YPos [RW]
  77.   Composition:_Output_Error()
  78.   Composition:_Output_Print()
  79.   Composition:_Save()
  80.   Composition:_SaveAs()               - Save the composition
  81.   Composition:_SaveCopyAs()           - Save a copy of the composition
  82.   Composition:_SetCurrentTime()
  83.   Object:Comp()
  84.   Object:Composition()
  85.   Object:DoAction()
  86.   Object:GetData()                    - Get custom persistent data
  87.   Object:GetID()
  88.   Object:GetReg()
  89.   Object:QueueAction()
  90.   Object:SetData()                    - Set custom persistent data
  91.   Object:TriggerEvent()
  92.   :GetApp()
  93.   :GetAttrs()
  94.   :GetHelp()
  95.   :GetHelpRaw()
  96.   :SetAttrs()
  97.  
  98.  
  99. dump(fusion:GetHelp("Fusion"))
  100. Fusion Members:
  101.   Fusion.ActionManager [R]           - The Global Action Manager
  102.   Fusion:AddConfig()
  103.   Fusion:AllowNetwork()
  104.   Fusion.BinManager [R]              - Bins
  105.   Fusion.Bins [R]                    - Bins
  106.   Fusion.Build [R]                   - The build number of Fusion.
  107.  
  108.   Fusion.CacheManager [R]            - The Global Cache Manager
  109.   Fusion:ClearFileLog()
  110.   Fusion:ClearRecentCompList()
  111.   Fusion:Copy()
  112.   Fusion:CreateFloatingView()
  113.   Fusion:CreateMail()                - Create an empty Mail message object
  114.   Fusion.CurrentComp [R]             - Represents the currently active composition
  115.   Fusion.CurrentFrame [R]
  116.   Fusion:CustomizeToolbars()
  117.   Fusion:Cut()
  118.   Fusion:Delete()
  119.   Fusion:DumpCgObjects()             - Dumps Cg Objects
  120.   Fusion:DumpGLObjects()             - Dumps OpenGL Objects
  121.   Fusion:DumpGraphicsHardwareInfo()  - Dumps OpenGL Objects
  122.   Fusion:DumpOpenCLDeviceInfo()      - Dumps OpenCL device info
  123.   Fusion:EditScript()                - Edit Script
  124.   Fusion:Execute()
  125.   Fusion.FileLogging [RW]
  126.   Fusion:FindReg()                   - Find a registry object by ID
  127.   Fusion.FontManager [R]             - The Global Font Manager
  128.   Fusion:GetActiveFrameIndex()
  129.   Fusion:GetActiveWndIndex()
  130.   Fusion:GetAppInfo()
  131.   Fusion:GetArgs()                   - Get command line arguments
  132.   Fusion:GetCPULoad()
  133.   Fusion:GetClipboard()              - Retrieves the tool(s) on the clipboard, as tables and as ASCII text.
  134.   Fusion:GetCompList()               - Retrieves a table of all compositions currently present
  135.   Fusion:GetCurrentComp()            - Returns the currently active composition
  136.   Fusion:GetData()                   - Get custom persistent data
  137.   Fusion:GetEnv()                    - Retrieve the value of an environment variable
  138.   Fusion:GetGlobalPathMap()          - Returns a table of all global path maps
  139.   Fusion:GetMainWindow()
  140.   Fusion:GetMousePos()
  141.   Fusion:GetNumRecentFiles()
  142.   Fusion:GetPrefs()                  - Retrieve a table of preferences
  143.   Fusion:GetPreviewList()            - Retrieves a table of global previews
  144.   Fusion:GetRecentCompList()
  145.   Fusion:GetRecentFileName()
  146.   Fusion:GetRegAttrs()               - Retrieve information about a registry ID
  147.   Fusion:GetRegList()                - Retrieve a list of all registry objects known to the system
  148.   Fusion:GetRegSummary()             - Retrieve a list of basic info for all registry objects known to the system
  149.   Fusion:GetResolve()
  150.   Fusion:GetToolIcon()
  151.   Fusion:GetToolList()
  152.   Fusion:GetVersion()
  153.   Fusion.HotkeyManager [R]           - The Global Hotkey Manager
  154.   Fusion:IsNetworkAllowed()
  155.   Fusion:IsUIVisible()
  156.   Fusion:IsUtilityOpen()
  157.   Fusion:LoadComp()                  - Loads an existing composition
  158.   Fusion:LoadPrefs()                 - Reloads all current global preferences
  159.   Fusion:LoadRecentComp()            - Loads an composition from the recent file list
  160.   Fusion:MapPath()                   - Expands path mappings in a path string
  161.   Fusion:MapPathSegments()           - Expands all path mappings in a multipath
  162.   Fusion.MenuManager [R]             - The Global Menu Manager
  163.   Fusion.MouseX [R]
  164.   Fusion.MouseY [R]
  165.   Fusion:NewComp()                   - Creates a new composition
  166.   Fusion:NewFloatFrame()
  167.   Fusion:NewImageView()
  168.   Fusion:NewTabbedFrame()
  169.   Fusion:OpenFile()                  - Open a file
  170.   Fusion:OpenLibrary()
  171.   Fusion:OpenLibraryStudio()
  172.   Fusion:Paste()
  173.   Fusion:PasteSettings()
  174.   Fusion:QueueComp()                 - Queue a composition to be rendered locally
  175.   Fusion.QueueManager [R]            - The global render manager for this instance of Fusion
  176.   Fusion:Quit()                      - Quit Fusion
  177.   Fusion:RemoveConfig()
  178.   Fusion.RenderManager [R]           - The global render manager for this instance of Fusion
  179.   Fusion:ReverseMapPath()            - Collapses a path into best-matching path map
  180.   Fusion:RunScript()                 - Run a script
  181.   Fusion:SavePrefs()                 - Saves all current global preferences
  182.   Fusion:SelectAll()
  183.   Fusion:SetActiveFrameIndex()
  184.   Fusion:SetActiveWndIndex()
  185.   Fusion:SetBatch()
  186.   Fusion:SetClipboard()              - Sets the clipboard to contain the tool(s) specifed by a table or as ASCII text.
  187.   Fusion:SetData()                   - Set custom persistent data
  188.   Fusion:SetFusionApp()
  189.   Fusion:SetMasterApp()
  190.   Fusion:SetOnlyActiveComp()
  191.   Fusion:SetPrefs()                  - Set preferences from a table of attributes
  192.   Fusion:ShowAbout()                 - Display the About dialog
  193.   Fusion:ShowPrefs()                 - Display the Preferences dialog
  194.   Fusion:ShowUI()
  195.   Fusion:ShowWindow()                - Show or Hide main window
  196.   Fusion:Sleep()
  197.   Fusion:Test()
  198.   Fusion:ToggleBins()                - Shows or hides the Bins window
  199.   Fusion:ToggleRenderManager()       - Shows or hides the Render Manager
  200.   Fusion:ToggleUtility()             - Shows or hides a Utility plugin
  201.   Fusion.UIManager [R]
  202.   Fusion.Version [R]                 - The version number of Fusion.
  203.  
  204.   Fusion:_Memory_Purge()
  205.   Fusion:_NewComp()                  - Creates a new composition
  206.   Object:Comp()
  207.   Object:Composition()
  208.   Object:DoAction()
  209.   Object:GetData()                   - Get custom persistent data
  210.   Object:GetID()
  211.   Object:GetReg()
  212.   Object:QueueAction()
  213.   Object:SetData()                   - Set custom persistent data
  214.   Object:TriggerEvent()
  215.   :GetApp()
  216.   :GetAttrs()
  217.   :GetHelp()
  218.   :GetHelpRaw()
  219.   :SetAttrs()
  220.  
Accessing the hidden Fusion "Import" Menu Functions

If you miss the previous Fusion Studio "File > Import > " menu items when you are in Resolve 15, you can still run those commands directly from the Console using the Lua based "fu:ToggleUtility()" function.

Keep in mind the underlying Fusion import functions that are called by "fu:ToggleUtility()" are hidden for a reason: They haven't been updated yet fully to work in Resolve so I they are not Resolve Media Pool aware and may have other issues. This means you can try running the commands if you are feeling brave but you shouldn't be surprised when you run the FBX or Alembic import commands if you don't get a full 3D scene import with the texture maps loaded in correctly too. ;)


Note: There is a little bit of random crashyness on MacOS for Lua based file requester dialogs in Resolve 15's initial public beta. Make sure to save your project once before running any of the ToggleUtility functions.


Show the ABC import dialog:
Code: [Select all] [Expand/Collapse] [Download] (AbcImport.lua)
  1. fu:ToggleUtility('AbcImport')

Show the FBX import dialog:
Code: [Select all] [Expand/Collapse] [Download] (FBXImport.lua)
  1. fu:ToggleUtility('FBXImport')

Show the SVG import dialog:
Code: [Select all] [Expand/Collapse] [Download] (SVGImport.lua)
  1. fu:ToggleUtility('SVGImport')

Show the Shapes import dialog:
Code: [Select all] [Expand/Collapse] [Download] (ShapeImport.lua)
  1. fu:ToggleUtility('ShapeImport')

Show the Tracks import dialog:
Code: [Select all] [Expand/Collapse] [Download] (TrackImport.lua)
  1. fu:ToggleUtility('TrackImport')

Printing out Your PathMap Table

You can see a print out of the active PathMaps that are present in the Resolve Fusion page using this Lua command:
Code: [Select all] [Expand/Collapse] [Download] (GetGlobalPathMap.lua)
  1. dump(fu:GetGlobalPathMap())

The Console text that comes back from running this PathMap function is:
Code: [Select all] [Expand/Collapse] [Download] (GetGlobalPathMap output.txt)
  1. table: 0x01e6d1b870
  2.     Queues: = AllDocs:Queue
  3.     Guides: = UserPaths:Guides
  4.     Templates: = UserPaths:Templates
  5.     Config: = UserPaths:Config
  6.     ResolveDB: = /Library/Application Support/Blackmagic Design/DaVinci Resolve/Resolve Disk Database/Resolve Projects/Users/guest/Projects/
  7.     EditTemplates: = Templates:Edit
  8.     Comps: = UserDocs:
  9.     Macros: = UserPaths:Macros
  10.     AutoSaves: = Comps:Default AutoSaves
  11.     UserPaths: = UserData:;AllData:;Fusion:;Reactor:Deploy
  12.     Layouts: = UserPaths:Layouts
  13.     Reactor: = /Library/Application Support/Blackmagic Design/DaVinci Resolve/Fusion/Reactor/
  14.     Defaults: = UserPaths:Defaults
  15.     Libraries: = UserPaths:Library
  16.     FusionTemplates: = Templates:Fusion
  17.     Thumbs: = Stamps:
  18.     UserDocs: = /Users/StatixVFX/Documents/Blackmagic Design/DaVinci Resolve/Fusion
  19.     LuaModules: = UserPaths:Modules/Lua
  20.     FusionLibs: = /Applications/DaVinci Resolve/DaVinci Resolve.app/Contents/Libraries/Fusion
  21.     LoaderCache: = Temp:DiskCache
  22.     Bins: = UserData:Bins
  23.     Comp: = Comps:
  24.     Profile: = Profiles:Default/
  25.     Brushes: = UserPaths:Brushes
  26.     AllLUTs: = LUTs:;/Library/Application Support/Blackmagic Design/DaVinci Resolve/LUT
  27.     Profiles: = UserData:Profiles/
  28.     AllDocs: = /Users/StatixVFX/Documents/Blackmagic Design/DaVinci Resolve/Fusion
  29.     Temp: = /var/folders/q_/j93d7rd953zbvfstpxpt7nk00000gn/T/
  30.     FFmpeg: = Reactor:/Deploy/Bin/ffmpeg/bin/
  31.     UserData: = /Users/StatixVFX/Library/Application Support/Blackmagic Design/DaVinci Resolve/Fusion
  32.     Scripts: = UserPaths:Scripts;Reactor:System/Scripts
  33.     Fuses: = UserPaths:Fuses
  34.     Previews: = Temp:
  35.     Filters: = UserPaths:Filters
  36.     AllData: = /Library/Application Support/Blackmagic Design/DaVinci Resolve/Fusion
  37.     Fusion: = /Applications/DaVinci Resolve/DaVinci Resolve.app/Contents/Libraries/Fusion/../../Resources/Fusion
  38.     Programs: = /Applications/
  39.     DiskCaches: = Temp:DiskCache
  40.     Settings: = UserPaths:Settings
  41.     Fonts: = $(HOME)/Library/Fonts;/System/Library/Fonts;/Library/Fonts;/Network/Library/Fonts
  42.     Help: = Fusion:Help;Fusion:../../..
  43.     LUTs: = UserPaths:LUTs
  44.     Stamps: = UserData:Stamps
  45.     Plugins: = UserPaths:Plugins
Printing out the Fusion Registry

And finally you can print out the raw Fusion page registry data to the Console to see all of the installed and supported Fuses, Plugins, macros, image formats, video formats, and 3D mesh formats that are active:
Code: [Select all] [Expand/Collapse] [Download] (GetRegistry.lua)
  1. dump(fu:GetRegSummary())