Jump to: Board index » General » Fusion

script code for saving settings

Learn about 3D compositing, animation, broadcast design and VFX workflows.
  • Author
  • Message
Offline

vinayragbotra

  • Posts: 31
  • Joined: Sat Apr 04, 2015 4:35 pm

script code for saving settings

PostFri Feb 02, 2018 12:52 pm

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.
Offline
User avatar

Bryan Ray

  • Posts: 2478
  • Joined: Mon Nov 28, 2016 5:32 am
  • Location: Los Angeles, CA, USA

Re: script code for saving settings

PostSat Feb 03, 2018 2:02 am

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
Bryan Ray
http://www.bryanray.name
http://www.sidefx.com
Offline

vinayragbotra

  • Posts: 31
  • Joined: Sat Apr 04, 2015 4:35 pm

Re: script code for saving settings

PostSat Feb 03, 2018 3:04 pm

Thank you so much sir.
It worked.
Offline
User avatar

Bryan Ray

  • Posts: 2478
  • Joined: Mon Nov 28, 2016 5:32 am
  • Location: Los Angeles, CA, USA

Re: script code for saving settings

PostSat Feb 03, 2018 6:10 pm

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.
Bryan Ray
http://www.bryanray.name
http://www.sidefx.com
Offline

vinayragbotra

  • Posts: 31
  • Joined: Sat Apr 04, 2015 4:35 pm

Re: script code for saving settings

PostTue Feb 06, 2018 1:50 am

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?
Offline
User avatar

Bryan Ray

  • Posts: 2478
  • Joined: Mon Nov 28, 2016 5:32 am
  • Location: Los Angeles, CA, USA

Re: script code for saving settings

PostTue Feb 06, 2018 3:34 am

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.
Bryan Ray
http://www.bryanray.name
http://www.sidefx.com
Offline

vinayragbotra

  • Posts: 31
  • Joined: Sat Apr 04, 2015 4:35 pm

Re: script code for saving settings

PostWed Feb 07, 2018 1:54 am

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?
Offline
User avatar

Bryan Ray

  • Posts: 2478
  • Joined: Mon Nov 28, 2016 5:32 am
  • Location: Los Angeles, CA, USA

Re: script code for saving settings

PostWed Feb 07, 2018 4:21 am

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.
Bryan Ray
http://www.bryanray.name
http://www.sidefx.com

Return to Fusion

Who is online

Users browsing this forum: No registered users and 34 guests