## The ScriptScript

SirEdric
Fusionator
Posts: 1583
Joined: Tue Aug 05, 2014 10:04 am
Been thanked: 52 times
Contact:

### The ScriptScript

Hey Folks.

Often times I find myself creating pipeline scripts, or even short snippets of code to pass on to my co-workers,
to make their daily life easier.
Many times though they end up invading my office and up comes a conversation like:

All my imported OBJs look dark and dull in Fusion. How comes?
Well...I told you before that depending on what the *exporting* program put in those files, the materials might come in as 0.6/0.6/0.6. Set them to 1/1/1 and you're a happy bunny.
But there's so many material nodes...
I know. That's why I deployed that "setMatTo111" script. There's also a Video on how and when to use it. And the documenting PDF can be found in X:\ReadmeOrNot\ThisIsHowToDoIt.PDF.
Ah, ya, thanks. I always forget the name of that script...

Another scenario is that one has to do *really* simple things. Like setting all Loaders to postMultiply by Alpha.
Three lines like

Code: Select all

if tool.PostMultiplyByAlpha then
tool.PostMultiplyByAlpha[1] = 1
end

But to actually use it in a larger team, you have to write all that shizbang for comp:, toollist(), flow, maybe a Dialog, and of course an Undo event.
So instead of three lines you end up with 50.
(Yes....some of them are commented print functions...)

So here we go with.... The ScriptScript.
ScriptScript_v08.png
A home for all those snippets and small routines. Along with documentation for your co-workers.
They can keep it open on the second monitor, as it will always pick the current comp.
Not really suitable for large monster-scripts, but rather for those nifty little tidbits.
Obviously this is early stages, but I thought it worth sharing.

How to use it

Well...you certainly have one or the other function flying around that deserves a better place than being buried in scripts->comp->workflow->2017->client->...

First, put your function in the designated area of the script. There some comments to tell you how to use the built-in names from the script.
Like so:

Code: Select all

function AlphaPostMultiply() -- Set Loaders to Post Multiply Alpha in the import tab.
if tool.PostMultiplyByAlpha then
tool.PostMultiplyByAlpha[ct] = 1
return true -- triggers the counter et al
end
end

Then, "register" your function in the top table of the script and add descriptions like:

Code: Select all

myScripts = {
-- Script Display Name, Affects tools, Script Function Name, Description, additional Args
{"Post Multiply by Alpha", "Loaders", "AlphaPostMultiply", [[<h3 align="center">Alpha Post Multiply</h3><br>Set Loader's PostMultiplyBy Alpha to 1.]]},
}

Restart [se] ScriptScript and enjoy....
se_ScriptScript.lua
Huge thanks to @AndrewHazelden for his gorgeous UI Examples and support.

Cheers.

Eric.
You do not have the required permissions to view the files attached to this post.
Last edited by SirEdric on Wed Feb 14, 2018 9:01 pm, edited 2 times in total.

AndrewHazelden
Fusionator
Posts: 1215
Joined: Fri Apr 03, 2015 3:20 pm
Location: West Dover, Nova Scotia, Canada
Been thanked: 11 times
Contact:

### Re: The ScriptScript

Cool work as usual SirEdric!

Great to see you pushing forward the usability tweaks, and homebrew scripted additions for Fusion the way you are.

Cheers,
Andrew

SirEdric
Fusionator
Posts: 1583
Joined: Tue Aug 05, 2014 10:04 am
Been thanked: 52 times
Contact:

### Re: The ScriptScript

Thanks mate...

SecondMan
Posts: 3122
Joined: Thu Jul 31, 2014 5:31 pm
Been thanked: 35 times
Contact:

### Re: The ScriptScript

Oooh! Nice one Eric!

Would be nice to see people here add snippets to it as we go along...

SirEdric
Fusionator
Posts: 1583
Joined: Tue Aug 05, 2014 10:04 am
Been thanked: 52 times
Contact:

### Re: The ScriptScript

Aaaand here we go with a new version.
ScriptScript_v09.png
Now you can add pre-defined arguments in the scripts table, which will then show up in a nifty combo box:

Code: Select all

{"Bite my Back", "Benders", "bla", [[<h3 align="center">Yeah</h3><br>Whatever]], {"some", "odd", "stuff"},},

It also comes with an option to start external (bigger) scripts rather than the build in snippets:

Code: Select all

{"Ext Set all Mat", "External", "externalScript", [[<h3 align="center">Do something outside the box.</h3><br>starts externally!]], [[Q:\_assets\FusionScripts\Comp\MO_MultiOBJtoSPX.lua]],},

And last but not least (thanks again for the wonderful support from @AndrewHazelden ),
there's also a comfortable way to add images to the info box on the right.
se_ScriptScript.zip
Cheers
You do not have the required permissions to view the files attached to this post.

SirEdric
Fusionator
Posts: 1583
Joined: Tue Aug 05, 2014 10:04 am
Been thanked: 52 times
Contact:

### Re: The ScriptScript

And as a bonus you can even color-code the tree items, based on the "affects" category.

Code: Select all

myColors = {
["Materials"] = { 0.54, 0.7, 0.48, 1 },
["3D Meshes"] = { 0.67, 0.78, 0.9, 1 },
["Loaders"] = { 0.74, 0.9, 0.74, 1 },
}

ScriptScript_v091.png
se_ScriptScript.lua
You do not have the required permissions to view the files attached to this post.

SirEdric
Fusionator
Posts: 1583
Joined: Tue Aug 05, 2014 10:04 am
Been thanked: 52 times
Contact:

### Re: The ScriptScript

And here we go with the sundae...errr....sunday snippet.
Quite useful, as I have to say, when experiencing OpenCL issues and looking for a quick way to switch 'em all off.
ScriptScript_v093.png
Plus, after a script has run, clicking on any of the processed tool's name in the tool tree list,
will select that tool on the flow to easily find and examine said tool.
se_ScriptScript.lua
You do not have the required permissions to view the files attached to this post.

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

### Re: The ScriptScript

Amazing toolset @SirEdric !

SirEdric
Fusionator
Posts: 1583
Joined: Tue Aug 05, 2014 10:04 am
Been thanked: 52 times
Contact:

### Re: The ScriptScript

Did I promise updates? I certainly did...
And since I'm always trying to fulfill my promises here comes...an update!
ScriptScript_v095.png
Apart from a few minor improvements, one can now filter the Categories using the combo in the upper right.
And...it comes with a new snippet called "The Gradiator".
How many times when you create a gradient you spent time to evenly spread out those tiny little triangles?
These times are over, because The Gradiator does exactly that. Spacing out those triangles nice and even.
But wait! There's more!
You can also create hard transitions (or soft-ish transitions, based on the threshold) between those triangles.
Enjoy!
se_ScriptScript.lua
Eric
You do not have the required permissions to view the files attached to this post.

ChristopherNodal
Fusioneer
Posts: 165
Joined: Mon Jan 11, 2016 1:42 pm

### Re: The ScriptScript

Hi Eric,

Thank you for the update! I really find your ScriptScript to be an addition with tremendous potential. I have been looking into it a bit and I found the way any additional scripts would have to be added a little cumbersome and hard to read. So I would like to make a suggestion if you don't mind?

What about giving se_ScriptScript the ability to read .se_Script files? So it would truly be an se_ScriptScript!

An example of an se_Script file would look something like this:
1. setMat = {
2.     DisplayName = "Set All Materials to 1/1/1",
3.     AffectsTools = "Materials",
4.     Description = "[[<h3 align="center">Materials Full Brightness</h3><br>Set the Diffuse Color of Materials in the comp to R,G,B = 1,1,1 to achieve a neutral look.<br>You can also put other <b>comma separated</b> values like 1,0,0 or 0.5,0.75,1 into the Additional Arguments field.]]",
5.     Arguments = "1.0,1.0,1.0",
6. },
That way users can have their own .se_Script files to add and the main script would never need to be touched which makes updating it straightforward. Internally, the above function could take the filename and the table name as the function name (SirEdric.setMat) to avoid conflicts.

Something like that.

Thanks!

SirEdric
Fusionator
Posts: 1583
Joined: Tue Aug 05, 2014 10:04 am
Been thanked: 52 times
Contact:

### Re: The ScriptScript

Thanks for the thanks, Christopher...

And thanks for the suggestion as well.
I've been playing with that idea myself and find it intriguing as well.
Obviously apart from the "description table", the .se_Script (love the name...) would also need to hold the actual function itself.

Another idea was to have a little "sandbox" Textbox inside ScriptScript where you can write & test some mini-code-snippets (like 10 lines max) before implementing them into larger.
But on a second thought this sounds a bit like it would jeopardize the original "easy to use for anyone" idea.

Currently I'm busy as hell anyways and only come to scripting during the weekend (which also demands my attention to the family...).

So... yeah....babysteps forward, but I'm at it...

Cheers & all the best.

Eric.

ChristopherNodal
Fusioneer
Posts: 165
Joined: Mon Jan 11, 2016 1:42 pm

### Re: The ScriptScript

SirEdric wrote:
Mon Mar 05, 2018 8:49 pm
Obviously apart from the "description table", the .se_Script (love the name...) would also need to hold the actual function itself.
Yes I did not have that figured out yet. There are a few possibilities. But I will give it some further thought

SirEdric
Fusionator
Posts: 1583
Joined: Tue Aug 05, 2014 10:04 am
Been thanked: 52 times
Contact:

### Re: The ScriptScript

Well...ScriptScript calls the function with doIt = getfenv()[myFunc]().
So when one read the .se_Script by means of dofile(),
any function declared in there *should* live in the functionEnvironment as well....
(I hope...)

PeterLoveday
Fusioneer
Posts: 130
Joined: Sun Sep 14, 2014 6:09 pm
Been thanked: 2 times

### Re: The ScriptScript

Or you put the function in the table and call it from there?

SirEdric
Fusionator
Posts: 1583
Joined: Tue Aug 05, 2014 10:04 am
Been thanked: 52 times
Contact:

### Re: The ScriptScript

How would one do that, calling-wise?