< Previous | Contents | Next >

Object Data

Data is a special type of Metadata that is stored within the application preferences or composition.

As opposed to Metadata that is read from an image data stream (e.g., OpenEXR) and is passed from tool to tool, the Object Data is not passed with the data stream. Instead, it is consistent for the current state of the application, composition, or tool.

This makes it a perfect candidate for reliably storing states of custom scripts with the composition.

For example, let’s say a custom script with a GUI needs to store its last used path so that the user does not have to change the path each time the script is being used.


image


image

image

if globals.mytool_lastpath then


path = mytool_lastpath

path = “default/path”

end

else

One option is to create a global variable and check if it is set on each run:



-- ... Dialog with the path


globals.mytool_lastpath = path


However, once Fusion is closed the variable is gone. This strategy only makes sense for data that is not likely to change from session to session, like a cached list of currently loaded Tools.

image

path = “default/path”

end

else

path = last_path

if last_path then

local last_path = fusion:GetData(“mytool.lastpath”)

But for our scenario, it may be wiser to store each latest path with the fusion preferences so that each new composition can reference the last used path, even when Fusion is closed and reopened.


-- ... Dialog with the path


fusion:SetData(“mytool.lastpath”, path)


However, another strategy might be to store the data with the composition, so each composition can have its own path. Simply replace fusion with composition or any other context that makes sense if your case.


image


...

fusion:SetData(“MyStudioInc.MyRenderSettings.RemoteNames”, “clients”)

fusion:SetData(“MyStudioInc.MyCompTool.DoMagic”, true)

Please note that the dot notation is not random. Dots represent a subtable. So you can put multiple variables or even other nested tables inside of “mytool.” Use this to your advantage, e.g., to define a domain wide root name that represents your studio, a sub table with the tools and their individual settings:


 

Where is the actual ObjectData stored?