Page 1 of 1

Script: Class Browser for DaVinci Resolve/Fusion

PostPosted: Sun Feb 23, 2020 3:38 pm
by roger.magnusson
An invaluable tool when creating GUI:s for Resolve/Fusion scripts is the FusionScript Help Browser by Andrew Hazelden (also available in Reactor for Fusion and Resolve). It uses the built-in script help/documentation system in Fusion/Resolve and displays it in an easy to use way.

I always wanted two more features though:
  • Clearly identify a class member as a property or a method
  • A graphical representation of the class hierarchy
I added these two features and some other small stuff that I haven't seen done in other scripts.

Startup time is a few seconds slower than Andrews script since I'm putting all the classes in a Tree instead of the faster ComboBox. Once it's started performance is not an issue though.

Note that Resolve kidnaps the keyboard in certain scenarios. Up/Down arrows in the class tree won't work if the script is opened on the Edit page for example. This only affects Resolve, not Fusion. If you need to use the keyboard you can make the Class Browser window a modal window (see the create_window function).

The filtering functionality is set to "contains" but you can use wildcards (* and ?). To list all classes that starts with "UI" just type UI* and press enter (note that classes might be hidden by the "Hide Classes Without Members" checkbox even when filtering).

One thing to note is that sometimes a property says Read-only when you might assume it's Read-write, like UITreeItem.Text. That's because the property is an indexer to a collection of values. The collection is Read-only, but the individual values inside it are Read-write.



Image
Class Browser in Flat View mode


Image
Nested View, with a filter applied to show all classes starting with "UI"


Image
New in v1.1, Registry Attributes for Fusion classes


@BMD, it would be very helpful if the existing Resolve API documentation (readme.txt) was added to the built-in script help system instead of the separate text file. Fusion has many class members documented like this and even Fairlight has some as well. The Resolve readme.txt implies this is already available in the script system, but it's only a list of method names without any description.

Running the script

Unzip the file first (the forum doesn't allow the .lua file extension). The easiest way to run the script is to drag and drop it on the console. To open the console go to the Workspace menu and select Console.

Image


To add the script to the Workspace > Scripts menu, place the script in this folder:
  • Linux
    ~/.local/share/DaVinciResolve/Fusion/Scripts/Comp

  • macOS
    ~/Library/Application Support/Blackmagic Design/DaVinci Resolve/Fusion/Scripts/Comp

  • Windows
    %AppData%\Blackmagic Design\DaVinci Resolve\Support\Fusion\Scripts\Comp
Tested on CentOS 7.6, macOS Catalina, Windows 10 v1909. Resolve v16.1.2 (free and Studio versions), Fusion Studio v16.1.1. Fusion v9 works but might have some visual glitches.

Any feedback is welcome!

Release notes

v1.3 2022-02-23
  • New: The "See also" references are now links where possible (not clickable in Fusion 9)
  • New: The class name and inheritance hierarchy is now shown in a sticky header above the scrollable text area
  • New: Added links to matching Qt documentation (according to my best guesses) when displaying the UI classes
  • New: Option to enable verbose log for debugging
  • New: Option to always rebuild the cached data file on start (set force_update_file = true)
  • New: Support for manually added classes and class members (currently, methods are added to the Fairlight, Timeline and Timeline item classes in DaVinci Resolve)
  • New: Open Script Folder button, for easy access to the code when the script has been installed
  • New: Hover on a method return type to see if it has been given a descriptive name
  • Fixed: Tag Maps didn't work in v17+ because the table structure had changed
  • Fixed: UI issues after Qt was updated to 5.15.2

v1.2.3 2021-03-18
  • Fixed: Startup crash in Resolve/Fusion v17.1 caused by class types that are no longer available
  • Fixed: Classes containing only ignored discovered methods (like _cast) caused properties to be skipped
  • Fixed: FuPath methods weren't being discovered

v1.2.2 2020-05-14
  • Fixed: The Plugins path was incorrect for Fusion on Windows

v1.2.1 2020-05-13
  • New: Additional properties discovered automatically
  • New: Several more files are probed for methods and properties
  • Fixed: Some PreviewControl classes weren't showing in the nested view

v1.2 2020-05-10
  • New: Tag Maps and Enum Maps
  • New: Additional methods that aren't documented in the help system are now discovered automatically
  • Fixed: Fusion v9 window layout issue
  • Fixed: Fusion v9 didn't show property types when available
  • Fixed: Fusion v9 error when registry entries contained tables, added workaround for dumptostring() bug

v1.1 2020-04-02
  • Added support for showing Fusion registry entries associated with a class
  • Registry attributes have tooltips with descriptions from the Fusion 8 Scripting Guide

v1.0 2020-02-23
  • First!

Re: Script: Class Browser for DaVinci Resolve/Fusion

PostPosted: Sun Feb 23, 2020 6:19 pm
by Igor Riđanović
Very nice. I'll test it out for sure.

Sent from my S60 using Tapatalk

Re: Script: Class Browser for DaVinci Resolve/Fusion

PostPosted: Sun Feb 23, 2020 10:04 pm
by Igor Riđanović
Nice work. It works in Windows 10. I haven't had much time to explore though. Windows users can also drop the script in
Code: Select all
%AppData%\Blackmagic Design\DaVinci Resolve\Support\Fusion\Scripts\Comp

and it will be permanently available under Workspace/Scripts dropdown menu (v16) or Fusion/Scripts in V15.

Re: Script: Class Browser for DaVinci Resolve/Fusion

PostPosted: Mon Feb 24, 2020 7:07 am
by iddos-l
Great stuff!
Tested on mac Mojave resolve 16.1.2, works great.
Thanks for this.
The hierarchy of the resolve class in the nested view is different from what I expected. From the python API docs I would expect the MediaPool object to be under the project class and so on.
Is this my lack of understanding of the objects hierarchy?

Re: Script: Class Browser for DaVinci Resolve/Fusion

PostPosted: Mon Feb 24, 2020 8:17 am
by roger.magnusson
I don't know if BMD:s system for generating the help data has some manual parts in it (besides the text) or if it's entirely automatic. If it's automatic I would say it's correct.

However, just because you need a Project reference to get a MediaPool reference doesn't say anything about where they inherit from. They don't need to be related at all. Think of inheritance as "is a", as in "MediaPool is a Project". Then it should be clear that it's not correct.

Re: Script: Class Browser for DaVinci Resolve/Fusion

PostPosted: Tue Mar 31, 2020 3:14 am
by roger.magnusson
While the script still works in Resolve, the latest Fusion Studio (v16.2 build 22) on macOS has an issue where any Lua script that is executed from the Script menu fails when running loops. Hopefully it will be fixed soon since this affects a ton of scripts made by the Fusion community.

Re: Script: Class Browser for DaVinci Resolve/Fusion

PostPosted: Thu Apr 02, 2020 10:13 pm
by roger.magnusson
Class Browser 1.1 adds the ability to view registry attributes for Fusion classes. Download link is in the first post.

Re: Script: Class Browser for DaVinci Resolve/Fusion

PostPosted: Mon Apr 06, 2020 5:56 am
by Pieter Van Houte
This looks very useful indeed! You should put this in Reactor... ;)

Re: Script: Class Browser for DaVinci Resolve/Fusion

PostPosted: Sun May 10, 2020 8:09 pm
by roger.magnusson
I think the next version of the Class Browser might be worthy of a Reactor release. It's all about Fusion this time.

...and it's released today! :D
Link in the first post.

Anyone who has ever tried to make a Fuse script will appreciate this I think. The Class Browser can now discover methods that aren't listed in Fusion's built-in script help system.

Some notable Fuse-related classes to look at:
  • Operator (/Object/Operator)
    Here you will find methods like GetPrevKeyTime(t) which allows a Fuse easy access to relevant keyframe details.

  • Request (/Object/Message/Request)
    Ever needed to get the current tool inside the Fuse Process() method? GetOp() will take care of that.

  • InputControl and its sub classes (/Object/InputControl/*)
    The Tag Map (also known as TagList or Attributes) is listed for each input control. Tag Maps that use enum values have them listed here as well.

  • Image (/Object/Parameter/Image)
    95 methods that weren't visible before. :o
    Oh, and all the Tag Maps you can eat.

Re: Script: Class Browser for DaVinci Resolve/Fusion

PostPosted: Mon May 11, 2020 3:46 pm
by Bryan Ray
Fantastic! Thank you so much!

Re: Script: Class Browser for DaVinci Resolve/Fusion

PostPosted: Sat Jul 18, 2020 10:25 am
by robozb
Cooool!!! Thank you!!!

Re: Script: Class Browser for DaVinci Resolve/Fusion

PostPosted: Sat Jul 18, 2020 10:58 am
by TheBloke
This is fantastic! I've wanted to start getting into scripting and this is going to be an incredible help.

Lovely UI, too.

Please do put this in Reactor if/when you've got the time. It deserves to be seen by the biggest audience possible, and it'd be great to have automatic version management and the rest.

Thanks so much for this.

Re: Script: Class Browser for DaVinci Resolve/Fusion

PostPosted: Thu Mar 18, 2021 10:25 am
by OlliVan
It fails on Resolve Studio 17:

Code: Select all
...inci Resolve/Fusion/Scripts/Comp/Class Browser 1.2.2.lua:68: table index is nil

Re: Script: Class Browser for DaVinci Resolve/Fusion

PostPosted: Thu Mar 18, 2021 1:07 pm
by roger.magnusson
Fixed in v1.2.3 that's now available in the first post.

Re: Script: Class Browser for DaVinci Resolve/Fusion

PostPosted: Sat Mar 20, 2021 11:14 am
by roger.magnusson
Class Browser is now available in Reactor as well.

Re: Script: Class Browser for DaVinci Resolve/Fusion

PostPosted: Sat Mar 20, 2021 1:57 pm
by iddos-l
Cheers


Sent from my iPhone using Tapatalk

Re: Script: Class Browser for DaVinci Resolve/Fusion

PostPosted: Tue Mar 23, 2021 3:32 pm
by roger.magnusson
Has anyone tried the Class Browser on an M1 Mac? I don't have one and I'm curious to know if the detection of methods in the binary files work as expected. If it fails it would probably just detect fewer methods without showing any warnings or errors.

Re: Script: Class Browser for DaVinci Resolve/Fusion

PostPosted: Wed Feb 23, 2022 7:55 pm
by roger.magnusson
The Class Browser is two years old today and we will celebrate with a new release. :D

Details and download in the first post.