Page 1 of 1

script code for saving settings

PostPosted: Fri Feb 02, 2018 12:52 pm
by vinayragbotra
How to make e script to save settings of tools onto local disk in fusion?
I know we can do it by right clicking on slected tools and then save setting as.
But I want to do it with script.

Re: script code for saving settings

PostPosted: Sat Feb 03, 2018 2:02 am
by Bryan Ray
tool:SaveSettings("path/filename")

For instance,
Code: Select all
Blur1:SaveSettings("C:\\Users\\bray\\AppData\\Roaming\\Blackmagic Design\\Fusion\\Defaults\\Blur.setting")


See page 167 of the Fusion 8 Scripting Guide:
http://documents.blackmagicdesign.com/F ... _Guide.pdf

Re: script code for saving settings

PostPosted: Sat Feb 03, 2018 3:04 pm
by vinayragbotra
Thank you so much sir.
It worked.

Re: script code for saving settings

PostPosted: Sat Feb 03, 2018 6:10 pm
by Bryan Ray
By the way, you'll probably get faster and more reliable answers if you post Fusion questions to the Fusion subforum here. It was kind of random chance that I happened to see this question.

Re: script code for saving settings

PostPosted: Tue Feb 06, 2018 1:50 am
by vinayragbotra
Sure Sir,
Kindly share the link once of subform.
And there is one more quation.
Settings are getting saved one by one
I have selected more than one setting, I run a loop to save settings, but how to save all selected tool in one single setting?

Re: script code for saving settings

PostPosted: Tue Feb 06, 2018 3:34 am
by Bryan Ray
Looks like a mod has moved your thread, so if you can see this message, you've found the Fusion forum!

To get a list of selected tools:

Code: Select all
tools = composition:GetToolList(true)


GetToolList() takes two arguments. The first is a boolean value, true or false, that determines whether you are collecting selected tools or all of the tools in the comp. The second is a tool type. This is the RegID of that tools you want to select. For instance, composition:GetToolList(false, "Loader") will return all the Loaders in your composition, regardless of whether they are selected.

To perform an operation on each item in the list:

Code: Select all
for i, j in pairs(tools) do
    <operation>
end


pairs() is an iterator function that returns the key and value pair to the variables declared in the loop, along with a link to the next item in the table. pairs() will return the keys in an arbitrary order. If your table is indexed by integer indices, you can traverse it in order using ipairs() instead.

So to save a .setting for each selected tool in my own Settings folder:

Code: Select all
path = "C:\\Users\\bray\\AppData\\Roaming\\Blackmagic Design\\Fusion\\Settings\\"
for i, j in pairs(tools) do
    tools[i]:SaveSettings(path .. tools[i].Name .. ".setting")
end


Edit: One more thing. This should be a comp script instead of a tool script. Tool scripts will be run once for each selected tool, which is problematic when using GetToolList() like this.

Re: script code for saving settings

PostPosted: Wed Feb 07, 2018 1:54 am
by vinayragbotra
Thank you Sir.
Yes Sir,
I did exactly same, but by loop, settings will be saved one by one.
Like blur1 and loader1 are selected.
Now if I run loop here, blur1 will be saved as blur1.setting and loader1 will be saved as loader1.setting
Is there any way, we can save blur1 and loader1 in one single setting?

Re: script code for saving settings

PostPosted: Wed Feb 07, 2018 4:21 am
by Bryan Ray
A setting file with more than one tool in it is a Macro—when recalled, all of the tools present in the setting will be created. You can use the Macro Editor (select all the nodes, right-click and choose "Edit Macro") to wrap them in up in a group that will look like a single node, or you can group them yourself, copy-and-paste into a Text Editor and save it with the .setting extension—this file needs to go into the Macros directory and will be accessible through Add Tools > Macros—or you can open the Bins and drag the collection of nodes into that window. When you do it that way, you'll have to drag the tools into a comp from the Bin, but they'll come in ungrouped—a handy way of making a template.

I'm not sure the most direct way of making a macro using a script. I'm sure it can be done, but I've never tried it.