Migrating from Nuke to Fusion. Need help in recreating Nuke gizmo

User avatar
pete3d
Posts: 18
Joined: Thu Oct 12, 2017 4:50 am
Location: Sydney, Australia

Migrating from Nuke to Fusion. Need help in recreating Nuke gizmo

#1

Post by pete3d » Sat Oct 28, 2017 3:28 pm

Hello Fusionistas,

I am very glad to have finally become part of this amazing and supportive Fusion community.
After having worked with Nuke for a while I decided to give Fusion a shot.

As part of migrating to Fusion I am trying to reacreate my nuke WRITE/SAVER gizmo.
Please find attached my current Nuke gizmo which can do the following:
- Query's environment variables and folder structures via python
- gizmo reacts to (events) e.g. when I select the gizmo it executes python code
- Autoconstructs next possible version output path xxx.%04d.jpg like in screenshot example
- When pressed render it executes a python subprocess and calls Thinkbox Deadline Command with passed arguments to submit a nuke Farm job.


Having studied this forum a little bit I think that macros is the direction I will need to take to recreate this gizmo?!

I started with creating a macro out of the Saver/Write node and managed to create custom button controls. Hurray!
The next bit I am stuck a little. As I am familiar with python and not so much with Lua (a matter of time :D ) I would love to attach python commands to the custom macro controls in some way.

At basic level, when I press a custom macro control button how can I execute 'Hello World' in the python console.



I would appreciate if any of you fusionistas could give me pointers and help in the very beginning of my fusion journey. :)

cheers
pete
Capture.JPG
You do not have the required permissions to view the files attached to this post.

User avatar
AndrewHazelden
Fusionator
Posts: 1387
Joined: Fri Apr 03, 2015 3:20 pm
Answers: 4
Location: West Dover, Nova Scotia, Canada
Been thanked: 59 times
Contact:

Re: Migrating from Nuke to Fusion. Need help in recreating Nuke gizmo

#2

Post by AndrewHazelden » Sat Oct 28, 2017 4:09 pm

Hi pete3d.

Welcome to the forum! :)
pete3d wrote:I started with creating a macro out of the Saver/Write node and managed to create custom button controls. Hurray! The next bit I am stuck a little. As I am familiar with python and not so much with Lua (a matter of time :D ) I would love to attach python commands to the custom macro controls in some way.
WSL Reference Posts

If you have a DIY spirit you should be able to combine the techniques shown in the following two posts to get the end result you are after:

Version Up/Down for loader/saver

Creating a UI Manager GUI Inside of a Node's UserControls Interface

You are able to make a full GUI that matches what your current Gizmo's Render Frames window has using Fusion UI Manager based GUI elements that are attached to your UserControls button.

Command Line Tasks

As far as executing a command line process from a node's UserControls interface goes you have the choice of:

Using the Lua native os.execute command to run your deadline submitter tool directly:
Code: [Select all] [Expand/Collapse] [Download] (RunCommand1.lua)
  1. os.execute([[C:\Program Files\Thinkbox\Deadline\bin\deadlinecommand -help]])
or

Communicating with your deadline submitter by running a Python command from a string like this from Lua:
Code: [Select all] [Expand/Collapse] [Download] (RunCommand2.lua)
  1. comp:Execute([[!Py: import sys; print("[Python Version] " + str(sys.version) + "\n")]])
Reading Environment Variables

You can read environment variables in Lua using:
  1. print(os.getenv("PATH"))
Extra User Controls Reference Documentation

If you haven't spotted this VFXPedia page on customizing UserControls it is worth looking over:
VFXPedia Gringo/User Controls

User avatar
AndrewHazelden
Fusionator
Posts: 1387
Joined: Fri Apr 03, 2015 3:20 pm
Answers: 4
Location: West Dover, Nova Scotia, Canada
Been thanked: 59 times
Contact:

SaverPlus Macro Node With UI Manager GUI

#3

Post by AndrewHazelden » Sun Oct 29, 2017 6:36 am

Hi. I spent my morning and put together a proof of concept Fusion based SaverPlus macro node that has functional and working controls that are similar what was shown in your "A_Write" Nuke Gizmo screenshot. :D

Download
SaverPlus.setting
SaverPlus Macro Installation

The SaverPlus.setting file is a macro so it should be copied to your Fusion user prefs "Macros:/" folder.

SaverPlus Screenshots

This image shows the SaverPlus Node's Tool attributes:
2017-10-29-Saver-Plus-Tools-Screenshot.png
This image shows the Console tab textual output after the Render Frames window "OK" button has been pressed:
2017-10-29-Saver-Plus-Console-Tab-Screenshot.png
Notes

The inline script code on the SaverPlus node could be saved to a fixed location on your system and referenced externally if that was how your preferred to do things.

Although it is theoretically possible create a custom UI Manager GUI for the SaverPlus node using Python, at this point in time there is no "Fusion 9 Scripting Guide.pdf" file that would show how to do it. That is why this script is 100% Lua based. Once there is Python based UI Manager documentation out in the wild it should be a trivial task to port the SaverPlus script from Lua to Python. :-)

When the "Render" button is pressed on the SaverPlus node a UI Manager based GUI is used to show the "Render Frames" dialog.
2017-10-29-Saver-Plus-Render-Frames-Screenshot.png
You can then enter your frame range in the Frames field. The Render Start and Render End frame range is entered as the default values shown in the Frames field.

When you press the OK button in the "Render Frames" dialog the active settings from the SaverPlus node is written to the Console tab for logging purposes.

The Saver Node's "Output Format" control is used by the script attached to the "Render" button to drive the image filetype extension that is appended to the end of the generated filename, and used as an intermediate folder name that is written just before the version number.

If the output folder path for the SaverPlus Filename doesn't exist yet it is created automatically by the script with the help of the bmd.createdir() function.

The UserControls based TextEditControl fields on the Saver node can be set to a read only state by adding this tag "TEC_ReadOnly = true,".

I placed a sample "deadlinecommand" code chunk at the bottom of the script that writes in the native deadline program path for Windows/Mac/Linux. The final os.execute() function has been commented out since you will need to add your customized submission code there.
2017-10-29-Saver-Plus-Deadline-Code.png
Sample Console Tab Output

Here is the Console tab textual output I get when I add the Saver Plus node to my comp, click the "Render" button, then press the "OK" button in the Render Frames window:

Code: Select all

[SaverPlus] v1.0
[Created By] Andrew Hazelden <andrew@andrewhazelden.com>

[Render Frames Window] OK Button Pressed

[%PATH% Env Var] /usr/bin:/bin:/usr/sbin:/sbin
[Comp Path] /Users/andrew/Desktop/Pete3d SaverPlus/SaverPlus Composite.comp
[Saver Name] SaverPlus
[Saver-Relative Numbering] 0
[Sequence Offset] 0
[Frame Range] 24-300x1
[Project Path] X:/projects/render/
[Base Name] rnd
[Sequence] set
[Shot] 020
[Task] model
[Version] v001
[Type] bashcomp
[Slate] 1
[Submit to ftrack] 1
[Comment] Added trees on the left side
[File Type] exr
[Saver Filename] X:/projects/render/bashcomp/model/v001/exr/rnd_set_020_model_bashcomp_v001.0000.exr
[Output Folder Created] X:/projects/render/bashcomp/model/v001/exr/
[Deadline Launch Command] /Applications/Thinkbox/Deadline8/Resources/deadlinecommand -help	
You do not have the required permissions to view the files attached to this post.

User avatar
pete3d
Posts: 18
Joined: Thu Oct 12, 2017 4:50 am
Location: Sydney, Australia

Re: Migrating from Nuke to Fusion. Need help in recreating Nuke gizmo

#4

Post by pete3d » Sun Oct 29, 2017 1:29 pm

Andrew! I am missing words! You are legendary!

Just saw this morning your fantastic responses which I just can't wait to try out at work. I will write to you soon how i go with integrating it into our pipeline.

You made my day!

Peter

User avatar
theotheo
Fusionista
Posts: 312
Joined: Thu Aug 07, 2014 8:35 am
Answers: 2
Been thanked: 20 times

Re: Migrating from Nuke to Fusion. Need help in recreating Nuke gizmo

#5

Post by theotheo » Sun Oct 29, 2017 2:28 pm

Fantastic contribution Andrew,

I'm certain a lot of new Fusion users will appreciate this. One of the first things to do when integrating a new piece of software into a pipeline is to take care of all the IO.

User avatar
pete3d
Posts: 18
Joined: Thu Oct 12, 2017 4:50 am
Location: Sydney, Australia

Re: Migrating from Nuke to Fusion. Need help in recreating Nuke gizmo

#6

Post by pete3d » Mon Oct 30, 2017 4:11 pm

Hi Andrew,

so I started with the integration and I have to tell you that I already have a working fusion deadline submission under Deadline 9 :)
I decided not to call deadlinecmd from within fusion but rather to call python.exe and pass some arguments to it.
We already have a generic deadline_submitter.py which just needs some args for creating a JOBINFO and PLUGINFO file and then submits to deadlinecmd from there.
I am pretty happy how things are going with the submission.
Now I want to focus on the interface of the macro and I am stuck at following:

- How can I set in the macro values through variables ? You hardcoded all the values like 'rnd', '020', 'model' and so on. I tried os.getenv instead of your hardcoded values, but it doesn't accept any of it ?

cheers,
Peter

User avatar
AndrewHazelden
Fusionator
Posts: 1387
Joined: Fri Apr 03, 2015 3:20 pm
Answers: 4
Location: West Dover, Nova Scotia, Canada
Been thanked: 59 times
Contact:

Working with Input Attributes on a Node

#7

Post by AndrewHazelden » Mon Oct 30, 2017 5:38 pm

pete3d wrote:- How can I set in the macro values through variables ? You hardcoded all the values like 'rnd', '020', 'model' and so on. I tried os.getenv instead of your hardcoded values, but it doesn't accept any of it ?
Hi Pete3d.

Have you ever opened up a Fusion .comp or macro .setting file in a text editor? If you enable Lua syntax highlighting you will see it is a raw Lua table structure that is in plain text format.
viewing-a-setting-file-as-a-lua-document.png
They aren't "hard coded" per se. The UserControls based attributes are merely living as regular inputs on the Saver node. An input on a node in Fusion is the direct equivalent of a Maya "Extra Attribute" tag.

If you select one or several nodes in the Fusion flow area and copy them into your clipboard they are stored as plain text elements. During development work you can quickly take a look at a node setting's in textual formatted detail by copying a flow area selected node into your clipboard and then pasting it into a text editor to see what is set as the node input or output settings for your macro.

If you scroll down in a text editor while looking at the SaverPlus.setting node you will see the line "SaverPlus = Saver {". That is the start of this node.

Scroll down a little bit further until you see the input line that looks like "Inputs = {". This lists a block of code that holds the customized settings for all attributes on a node.

If an entry is not listed in the inputs section on a node but the attribute is present in Fusion's Tool view that typically means the attribute is set to the default value for the node. Changing the value off the default setting will make a new entry for that attribute in the "Inputs = {" section.

For the SaverPlus node, after you scroll past the clip specific settings, you will see the following settings listed for the inputs:

Code: Select all

CreateDir = Input { Value = 1, },
OutputFormat = Input { Value = FuID { "OpenEXRFormat" }, },
["Gamut.SLogVersion"] = Input { Value = FuID { "SLog2" }, },
ProjectPathControl = Input { Value = "X:/projects/render/", },
SequenceControl = Input { Value = "set", },
ShotControl = Input { Value = "020", },
TaskControl = Input { Value = "model", },
VersionControl = Input { Value = "v001", },
SlateControl = Input { Value = 1, },
SubmitToFtrackControl = Input { Value = 1, },
CommentControl = Input { Value = "Added trees on the left side", },
SlateControl = Input { Value = 1, },
SubmitToFtrackControl = Input { Value = 1, },
["JpegFormat.Quality"] = Input { Value = 97, },
["OpenEXRFormat.Depth"] = Input { Value = 1, },
["OpenEXRFormat.Compression"] = Input { Value = 8, },
["OpenEXRFormat.Channels"] = Input { Value = 1, },
["QuickTimeMovies.Compression"] = Input { Value = FuID { "Apple ProRes 422 HQ_apch" }, },
Each of the custom UserControls that were added to the SaverPlus macro had the word "Control" added to the name for convenience to make them easier to spot.

As an example. the input entry of the TaskControl item has an input value of the "model" text string.

Code: Select all

TaskControl = Input { Value = "model", },
This is not an environment variable but just a regular attribute on the node. If you wanted to clear out the default settings for the SaverPlus node you can use your text editor to clear out the input values in the quotes for each of the UserControl items like ProjectPathControl, SequenceControl, ShotControl, TaskControl, VersionControl, etc... When you save this revision to the macro node's .setting file in your text editor, all future copies of the macro node you add to your composites will have your new initial default value you choose.

List Input Control Names Script

If you download and install the UI Manager example script "List Input Control Names.lua" that I've written it will show a Fusion "UI Manger" GUI based window with the selected node's input names in a tree view layout that can be scrolled through.

Double clicking on the row in the tree view will copy the current entry's Lua formatted style variable name into your clipboard buffer.

Select the "Task Control" input in that script's GUI window. Then double click on that line in the tree view. This will copy the text "SaverPlus.TaskControl" into your clipboard.
saverplus-list-input-control-names.png
You can then paste the "SaverPlus.TaskControl" word from your clipboard buffer into the Console tab's text entry field. Then add the text = "render" to the end of that code chunk and press enter to run it. This will set a new value for the SaverPlus macro node's TaskControl attribute:

Code: Select all

SaverPlus.TaskControl = "render"
Reading Node Settings

In the "Fusion 8 Script Manual.pdf" on page 35-36 is the Inputs and Outputs section.This part of the Fusion scripting documentation covers how to set node input values.

You can read the current value from the TaskControl attribute on the SaverPlus node by pasting the following Lua code into the Console tab:

Code: Select all

task = SaverPlus:GetInput("TaskControl")
print("[TaskControl] " .. tostring(task))
This gives an output of:

Code: Select all

[TaskControl] render
On page 39 of the same "Fusion 8 Script Manual.pdf" guide there is a description of how to read the standard attributes on a node using the dump() or "==" based command in the Console tab.

You can read the standard attributes on the node by writing in:

Code: Select all

==SaverPlus:GetAttrs()
or

Code: Select all

dump(SaverPlus:GetAttrs())
Running these commands would give you the output of:

Code: Select all

table: 0x61335958
	TOOLNT_EnabledRegion_Start = table: 0x6131be18
		1 = -1000000000
	TOOLB_CtrlWZoom = false
	TOOLNT_Region_End = table: 0x613422a0
		1 = -1000000000
	TOOLB_NameSet = false
	TOOLNT_Region_Start = table: 0x6131bea8
		1 = -1000000000
	TOOLBT_Clip_IsMultiFrame = table: 0x61342428
		1 = false
	TOOLBT_Clip_Saving = table: 0x613359a0
		1 = true
	TOOLST_Clip_Name = table: 0x6132b240
		1 = X:/projects/render/bashcomp/model/v001/jpeg/rnd_set_020_model_bashcomp_v001.0000.exr
	TOOLB_PassThrough = false
	TOOLST_Clip_FormatName = table: 0x6132b288
		1 = OpenEXRFormat
	TOOLI_Number_o_Inputs = 1
	TOOLIT_Clip_Length = table: 0x61342258
		1 = 0
	TOOLS_RegID = Saver
	TOOLB_Visible = true
	TOOLNT_EnabledRegion_End = table: 0x6131be60
		1 = 1000000000
	TOOLNT_Clip_End = table: 0x6132b1f8
		1 = 0
	TOOLI_ID = 3
	TOOLIT_Clip_Height = table: 0x6132b190
		1 = 0
	TOOLBT_Clip_IsPreviewSaver = table: 0x61335a20
		1 = false
	TOOLIT_Clip_Width = table: 0x6132b350
		1 = 0
	TOOLB_ShowControls = true
	TOOLB_Selected = false
	TOOLB_Locked = false
	TOOLB_HoldOutput = false
	TOOLS_Name = SaverPlus
	TOOLNT_Clip_Start = table: 0x6132b148
		1 = -2000000000
	TOOLIT_Clip_StartFrame = table: 0x61342210
		1 = 0
	TOOLN_LastFrameTime = 0
	TOOLST_Clip_FormatID = table: 0x6132b2d0
		1 = OpenEXRFormat
	TOOLB_CacheToDisk = false
You could then read the "TOOLST_Clip_Name" clip value for example from the above output using:

Code: Select all

dump(SaverPlus:GetAttrs()["TOOLST_Clip_Name"])
This would give you an output of:

Code: Select all

table: 0x6131ab88
	1 = X:/projects/render/bashcomp/model/v001/jpeg/rnd_set_020_model_bashcomp_v001.0000.exr
Note: There are multiple ways to set a loader/saver node's filename. This last example was just showing what the raw attributes on the node look like. :)

Extra Learning Resources

The "Macro Building Essentials" tutorial thread is where I am starting to explain macro creation and editing concepts in Fusion:
viewtopic.php?f=6&t=1581&p=11590#p11590


For more details on reading node inputs and outputs check out the VFXPedia documentation here:
https://www.steakunderwater.com/VFXPedi ... utput_List
You do not have the required permissions to view the files attached to this post.

User avatar
pete3d
Posts: 18
Joined: Thu Oct 12, 2017 4:50 am
Location: Sydney, Australia

Re: Migrating from Nuke to Fusion. Need help in recreating Nuke gizmo

#8

Post by pete3d » Mon Oct 30, 2017 7:45 pm

Hi Andrew,
wow. Very elaborate answer. Thank you so much for it.

I think I didn't explain correctly to you the first time around what my problem was. Lets start again.

I managed to query the fields and send arguments to the os.execute section of your code and use (python.exe and args ) with arguments to submit SaverPlus to the farm. All works thanks to your code. :) So far so good.

- What I would like to happen is when I create the SaverPlus node, the default values like for example 'task' to be populated with a environment values. (E.g. os.getenv("A_TASK"), A_SEQ, A_SHOT ). All those and other environment variables are available and just need to be filled into the fields automatically upon creation of SaverPlus. Right now when I create the node it's values are "hardcoded" to a string e.g. 'model'.

I don't know where to put code, which makes the SaverPlus fill out all the required fields on its own each time its created. Hope that makes more sense of what I am trying to accomplish.

Thanks for the tip with copy paste and how to read the values. Learning so much just with this one thing I am trying to achieve.

cheers
Peter

User avatar
AndrewHazelden
Fusionator
Posts: 1387
Joined: Fri Apr 03, 2015 3:20 pm
Answers: 4
Location: West Dover, Nova Scotia, Canada
Been thanked: 59 times
Contact:

How do you want to add your nodes to the comp?

#9

Post by AndrewHazelden » Mon Oct 30, 2017 10:37 pm

pete3d wrote:What I would like to happen is when I create the SaverPlus node, the default values like for example 'task' to be populated with a environment values. (E.g. os.getenv("A_TASK"), A_SEQ, A_SHOT ). All those and other environment variables are available and just need to be filled into the fields automatically upon creation of SaverPlus. Right now when I create the node it's values are "hardcoded" to a string e.g. 'model'.

I don't know where to put code, which makes the SaverPlus fill out all the required fields on its own each time its created. Hope that makes more sense of what I am trying to accomplish.
Let's explore the different ways a compositor could add a SaverPlus node to a composite and have a script run at the same time that would be able to do your custom environment variable setup thing.

Pushing an Environment Variable into UserControl Attribute

This Lua example shows how you can push an entry from a custom environment variable into a UserControls attribute on a SaverPlus macro node.

You could bind this code chunk to a hotkey on your keyboard so the script would be run from a hotkey.fu file whenever the artist presses some sort of "refresh" hotkey mapping you select.

Or this code could be executed from a script when you are adding the original SaverPlus node to the comp.
Code: [Select all] [Expand/Collapse] [Download] (SetUserControlsEnvVar.lua)
  1.  
  2. if os.getenv("A_TASK") ~= nil then
  3.   -- Read the env var
  4.   task = tostring(os.getenv("A_TASK"))
  5.   --
  6.   -- List the selected Node in Fusion
  7.   selectedNode = comp.ActiveTool
  8.   if selectedNode then
  9.     -- Make sure a saver node is selected
  10.     if selectedNode:GetAttrs().TOOLS_RegID == "Saver" then
  11.       selectedNode.TaskControl = task
  12.       print("[" .. selectedNode.Name .. "] " .. task)
  13.     else
  14.       print("Please select a saver node.\n")
  15.     end
  16.   else
  17.     print("Please select a saver node.\n")
  18.   end
  19. else
  20.   print("[A_TASK Environment Variable] Nil\n")
  21. end
  22.  

Clearing the Initial Settings in a Macro

To start with, here is a modified version of the SaverPlus.setting macro file with the default UserControl input values cleared out to a fresh empty state:
SaverPlus.setting
This was done by opening the file up in a text editor and changing all the relevant entries to have cleared out input strings that look like this:

Code: Select all

ProjectPathControl = Input { Value = "", },
SequenceControl = Input { Value = "", },
ShotControl = Input { Value = "", },
TaskControl = Input { Value = "", },
VersionControl = Input { Value = "", },
SlateControl = Input { Value = 0, },
SubmitToFtrackControl = Input { Value = 0, },
CommentControl = Input { Value = "", },
At the same time I removed the initial default Loader node filename element by clearing out the Clip "Filename" input line section in the .setting file.

This cleared out filename field on the node will cause a file browser dialog to appear the moment the macro is added to the comp if the "comp:Unlock()" state is active in Fusion. If you enable the "comp:Lock()" mode when adding nodes to a comp by a Python/Lua script then new file browser dialogs are not shown.

This is the part of the .setting file that had the filename entry that was cleared out to an empty "" string.

Code: Select all

Clip = Input {
  Value = Clip {
    Filename = "",
How does your studio start a new comp?

Just like there are many ways to automate something in Maya, there are many ways a task could be achieved in Fusion. :wip:

It comes down to the specific ways the Pipeline TD likes something to be implemented and the end artist's preferences. Also the amount of time you'd want to spend automating things would limit how "deep" of an integration you would go for. :D

The first question I would ask is how are your studio's customized macro nodes being added to the composite for a typical project? It probably lines up with one of the following options:

Option 1:

Are you starting with a default Fusion .comp composite file that acts as a template for all new projects in your studio? This would have your base multi-pass / render layer Loader nodes and OCIO color management nodes in the comp.

You can save a copy of your .comp file as the starting point template that is opened by your Fusion application launcher tool for the artist.

or

You can select all of the nodes in your comp's flow area and copy that text to your clipboard and save it to disk in your text editor as a custom macro .setting file. When this macro is added to a new comp by the Artist it would have all of the nodes placed in the active comp at once easily from Fusion's "Select Tools" dialog window (Shift + Spacebar hotkey) or the "Tools > Macro" menu item.

Both approaches could work.

Options 2:

Are you going to make a custom pipeline script that would make a new Fusion .comp file on the fly based upon the render layers coming out of your 3D package, or asset/shot management system? This would let you add in the Loader node based media and Saver node output settings you feel is appropriate from a database driven/pipeline controlled perspective.

When doing this approach either:

A custom script that you create is used to generate the Lua table structure for the full composite file as a block of text that is written to disk as the 100% finished .comp file.

or

Alternatively you can use the command line based FuScript process / or a script placed in the Fusion "Script" menu to add one node at a time to the foreground Fusion composite in a clean and elegant fashion with the exact X/Y position you want.

The script would then connect the nodes together in the flow area and set up the custom default values you want for any of the nodes.

Here are two recent FuScript posts that explain how the FuScript executable program can be used to run command line tasks that connect to a graphical Fusion Studio session running locally on the same system, or to connect a remote workstation/node:

Running Python Scripts in FuScript

Running UI Manager GUIs from a Terminal FuScript Session

Option 3:

Are you starting a new comp from scratch each time?

The Fusion compositing artist could manually place your customized saver node in their composite using a hotkey. This is typically done by setting up a hotkey that would allow the artist to click in the Fusion flow area and press a hotkey button like "S" or "Shift + S" to add the saver node. A hotkey like "L" or "Shift + L" could be used to add you Loader nodes.

You could use the Fusion Hotkey Editor for simple configurations with the View > Customize Hotkeys... Menu item.

For more complex hotkeys with custom scripted Action you could go deeper by adding a custom hotkey entry to a text file with the .fu extension that placed in the Fusion user prefs Config:/ folder. A hotkeys file lets you to load the macro or node into the comp, and possibly run a small chunk of code in an "Action{}" element in the .fu file (if you wanted) that would pre-fill any settings you need from your environment variables.

This is the simplest hotkey.fu example that shows how you could add a regular saver node with the "S" key to the flow area, and a custom SaverPlus node with the Shift+S hotkey.
Code: [Select all] [Expand/Collapse] [Download] (SaverPlus_Hotkeys.fu)
  1.  
  2. -- SaverPlus_Hotkeys.fu Example - v1 2017-10-31
  3. -- By Andrew Hazelden <andrew@andrewhazelden.com>
  4.  
  5. -- This is a hotkeys.fu file that would be placed in the fusion user prefs Config:/ folder.
  6. -- After you copy the .fu file in place, you need to restart Fusion to use these hotkey entries.
  7. -- This is due to the the fact the .fu files are only loaded during Fusion's startup phase.
  8.  
  9. {
  10.   Hotkeys {
  11.     Target = "FlowView",
  12.  
  13.     S = "AddTool{id = 'Saver'}",
  14.     SHIFT_S = "AddSetting{filename = 'Macros:/SaverPlus.setting'}",
  15.   },
  16. }
  17.  
You can read this thread on details about creating hotkey.fu files in Fusion 8/9:
viewtopic.php?f=16&t=724

Option 4:

It's handy for artists to have access to a custom menu for your Studio that is filled with the items they will use frequently.

You can add a custom menu to your copy of Fusion by adding a "Menus" entry in a Fusion .fu file.

This menu could run an Actions based code chunk in the .fu file to add the default Loader/Saver nodes for the shot you are working on. The Actions code chunk would be able to read the environment variables and set the custom values for the nodes so things are 100% setup and ready to go for the compositor with no wasted time.

This is a stacked pair of screenshots that show the custom "Pipeline-Lua" and "Pipeline-Python" menus that are created in Fusion Studio by the following two .fu examples below:
python-and-lua-pipeline-menus.png
This is a Python code based set of menu item actions (Notice the important Language = "Python2", tag near the top of the file):
Code: [Select all] [Expand/Collapse] [Download] (Menus_Python.fu)
  1. -- Menus_Python.fu Example - v1 2017-10-31
  2. -- By Andrew Hazelden <andrew@andrewhazelden.com>
  3.  
  4. -- This is a menus.fu file that would be placed in the fusion user prefs Config:/ folder.
  5. -- After you copy the .fu file in place, you need to restart Fusion to use these menu entries.
  6. -- This is due to the the fact the .fu files are only loaded during Fusion's startup phase.
  7.  
  8. {
  9.     Language = "Python2",
  10.  
  11.     Action {
  12.         ID = "AddSaverPlusPy",
  13.         Category = "Pipeline",
  14.         Name = "Add SaverPlus",
  15.        
  16.         Targets = {
  17.             Composition = {
  18.                 Execute = _Python [=[
  19.                     # Add your Python code here
  20.                     print("[Add SaverPlus] Using Python\n")
  21.                 ]=],
  22.             },
  23.         },
  24.     },
  25.  
  26.     Action {
  27.         ID = "AddLoaderPlusPy",
  28.         Category = "Pipeline",
  29.         Name = "Add LoaderPlus",
  30.        
  31.         Targets = {
  32.             Composition = {
  33.                 Execute = _Python [=[
  34.                     # Add your Python code here
  35.                     print("[Add LoaderPlus] Using Python\n")
  36.                 ]=],
  37.             },
  38.         },
  39.     },
  40.  
  41.     Menus {
  42.         Target = "ChildFrame",
  43.  
  44.         Before "Help" {
  45.             Sub "Pipeline-Python" {
  46.                 "AddLoaderPlusPy{}",
  47.                 "_",
  48.                 "AddSaverPlusPy{}",
  49.             },
  50.         },
  51.     },
  52. }
  53.  
  54.  
This is a Lua code based set of menu item actions:
  1. -- Menus_Lua.fu Example - v1 2017-10-31
  2. -- By Andrew Hazelden <andrew@andrewhazelden.com>
  3.  
  4. -- This is a menus.fu file that would be placed in the fusion user prefs Config:/ folder.
  5. -- After you copy the .fu file in place, you need to restart Fusion to use these menu entries.
  6. -- This is due to the the fact the .fu files are only loaded during Fusion's startup phase.
  7.  
  8. {
  9.     Action {
  10.         ID = "AddSaverPlusLua",
  11.         Category = "Pipeline",
  12.         Name = "Add SaverPlus",
  13.        
  14.         Targets = {
  15.             Composition = {
  16.                 Execute = _Lua [=[
  17.                     -- Add your Lua code here
  18.                     print("[Add SaverPlus] Using Lua\n")
  19.                 ]=],
  20.             },
  21.         },
  22.     },
  23.    
  24.     Action {
  25.         ID = "AddLoaderPlusLua",
  26.         Category = "Pipeline",
  27.         Name = "Add LoaderPlus",
  28.        
  29.         Targets = {
  30.             Composition = {
  31.                 Execute = _Lua [=[
  32.                     -- Add your Lua code here
  33.                     print("[Add LoaderPlus] Using Lua\n")
  34.                 ]=],
  35.             },
  36.         },
  37.     },
  38.    
  39.    
  40.     Menus {
  41.         Target = "ChildFrame",
  42.  
  43.         Before "Help" {
  44.             Sub "Pipeline-Lua" {
  45.                 "AddLoaderPlusLua{}",
  46.                 "_",
  47.                 "AddSaverPlusLua{}",
  48.             },
  49.         },
  50.     },
  51. }
  52.  
  53.  
After you run the different Pipeline-Lua and Pipeline-Python menu items you would see output in the Fusion Console tab that looks like this:
Console-after-running-hotkeys.png
Option 5:

You could add your studio's own custom Lua/Python scripts to the Fusion user prefs "Scripts:/Comp/YourStudioName/" folder. These custom scripts would then be visible in Fusion's Script > YourStudioName > menu section.

You could add a script that would ingest the environment variables you want to use for the current shot, create the nodes to load and save your media in the foreground composite, and auto setup the SaverPlus options you need.

You could also add a "note" node to the Fusion composite automatically that has comments from a supervisor or client on what needs to be done.

Option #4 and Option #5 are pretty much identical to the end user with the difference being in Option #4 a custom menu defined in a .fu file is used to launch the commands vs in Option #5 a plain Python/Lua script is added to the "Scripts:/Comp" folder with no extra configuration steps being required.

Option 6:

The Save Defaults option on a node is a handy thing you can use if you want all artists to use only your custom modified SaverPlus node and never accidentally be able to add a stock "Saver" node to a Fusion comp.
tools-view-setting-a-node-default.png
When a node is selected in Fusion's flow area, you can right click in the blank space on attributes in Fusion's Tools view.

In the contextual menu that appears select the Settings > Save Default menu item.

Note: You may have to try adjusting where you right click inside of tools view area since the pop-up menu is context sensitive to the element/zone you clicked on/over.

After you do run "Save Defaults" menu item, Fusion will save this customized node as the preset in the Fusion preferences that will be used automatically when a new node of that same type is added to a composite in the future.

In the case of the SaverPlus node, running the Save Defaults command on it will make any new stock "Saver" node added to the composite be a SaverPlus macro node that automatically has all of your customizations and UserControls applied.
You do not have the required permissions to view the files attached to this post.

User avatar
AndrewHazelden
Fusionator
Posts: 1387
Joined: Fri Apr 03, 2015 3:20 pm
Answers: 4
Location: West Dover, Nova Scotia, Canada
Been thanked: 59 times
Contact:

Re: Migrating from Nuke to Fusion. Need help in recreating Nuke gizmo

#10

Post by AndrewHazelden » Fri Nov 03, 2017 6:08 am

pete3d wrote: - What I would like to happen is when I create the SaverPlus node, the default values like for example 'task' to be populated with a environment values. (E.g. os.getenv("A_TASK"), A_SEQ, A_SHOT ). All those and other environment variables are available and just need to be filled into the fields automatically upon creation of SaverPlus.
Hi pete3d.

Sure. I can make an example Config:/hotkeys.fu file that sets everything up automatically when a SaverPlus node is added to the comp using the data coming from your from environment variables.

If you can post a list with all of the "A_" style named environment variables formatted exactly as you need them to be, it should only take me ~20 minutes to create the example .fu file scripted entries.

Cheers,
Andrew

User avatar
pete3d
Posts: 18
Joined: Thu Oct 12, 2017 4:50 am
Location: Sydney, Australia

Re: Migrating from Nuke to Fusion. Need help in recreating Nuke gizmo

#11

Post by pete3d » Sun Nov 05, 2017 5:13 am

thanks Andrew for all your amazing help. I was able to take on board all of the help you posted and migrate our nuke pipeline over to fusion.
I will present it very soon in some comparison screenshots (between nuke <-> fusion) Its really awesome how fast I was able to recreate my workflow from nuke in fusion.... THANKS to you ANDREW in very short time. :)

User avatar
pete3d
Posts: 18
Joined: Thu Oct 12, 2017 4:50 am
Location: Sydney, Australia

Re: Migrating from Nuke to Fusion. Need help in recreating Nuke gizmo

#12

Post by pete3d » Sun Nov 05, 2017 5:17 am

AndrewHazelden wrote:
pete3d wrote: - What I would like to happen is when I create the SaverPlus node, the default values like for example 'task' to be populated with a environment values. (E.g. os.getenv("A_TASK"), A_SEQ, A_SHOT ). All those and other environment variables are available and just need to be filled into the fields automatically upon creation of SaverPlus.
Hi pete3d.

Sure. I can make an example Config:/hotkeys.fu file that sets everything up automatically when a SaverPlus node is added to the comp using the data coming from your from environment variables.

If you can post a list with all of the "A_" style named environment variables formatted exactly as you need them to be, it should only take me ~20 minutes to create the example .fu file scripted entries.

Cheers,
Andrew
I managed to create a lua file which is linked to a hotkey and prefills the SaverPlus the way I want it.

Code: Select all

 toolpath=[[P:\fusion_pipeline\custom\Macros\SaverPlus.setting]]
 local tool = bmd.readfile(toolpath)
 if tool and tool["Tools"] ~= nil then
    comp:Paste(tool)
 end

if os.getenv("A_TASK") ~= nil then
  -- Read the env var
  job = tostring(os.getenv("A_JOB"))
  seq = tostring(os.getenv("A_SEQ"))
  shot = tostring(os.getenv("A_SHOT"))
  task = tostring(os.getenv("A_TASK"))
  path = tostring(os.getenv('A_ROOT')) .. job .. "/3d/" .. seq .. "/" .. shot .. "/products/render/" 
  --
  -- List the selected Node in Fusion 
  selectedNode = comp.ActiveTool
  if selectedNode then
    -- Make sure a saver node is selected
    if selectedNode:GetAttrs().TOOLS_RegID == "Saver" then
      selectedNode.SequenceControl = seq
      selectedNode.ShotControl = shot
      selectedNode.TaskControl = task
      selectedNode.Clip = path
      selectedNode.ProjectPathControl = path

      print("[ " .. selectedNode.Name .. "] " .. task)
    else
      print("Please select a saver node.\n")
    end
  else
    print("Please select a saver node.\n")
  end
else
  print("[A_TASK Environment Variable] Nil\n")
end

User avatar
AndrewHazelden
Fusionator
Posts: 1387
Joined: Fri Apr 03, 2015 3:20 pm
Answers: 4
Location: West Dover, Nova Scotia, Canada
Been thanked: 59 times
Contact:

Re: Migrating from Nuke to Fusion. Need help in recreating Nuke gizmo

#13

Post by AndrewHazelden » Sun Nov 05, 2017 5:43 am

pete3d wrote:I managed to create a lua file which is linked to a hotkey and prefills the SaverPlus the way I want it.
That's great to hear! It looks like you're fully getting the hang of how Fusion's customization features work. :)

If you have any custom tool dialogs and complex UI's you'd like to port over from Nuke to Fusion I'd invite you to ask any questions you have on the WSL "Building GUIs With Fusion's UI Manager" thread.

Also if you have any custom nodes written in Nuke Blink script, they can be ported over to Fusion's approach called a Fuse. The CustomTool node in Fusion can also be used for simple math operations on the pixels in your imagery.

Cheers,
Andrew

User avatar
SecondMan
Site Admin
Posts: 3580
Joined: Thu Jul 31, 2014 5:31 pm
Answers: 5
Location: Vancouver, Canada
Been thanked: 104 times
Contact:

Re: Migrating from Nuke to Fusion. Need help in recreating Nuke gizmo

#14

Post by SecondMan » Sun Nov 05, 2017 8:12 am

pete3d wrote:thanks Andrew for all your amazing help. I was able to take on board all of the help you posted and migrate our nuke pipeline over to fusion.
I will present it very soon in some comparison screenshots (between nuke <-> fusion) Its really awesome how fast I was able to recreate my workflow from nuke in fusion.... THANKS to you ANDREW in very short time. :)
:cheer:

That is fantastic! Looking forward to your presentation! :)

User avatar
SirEdric
Fusionator
Posts: 1960
Joined: Tue Aug 05, 2014 10:04 am
Answers: 4
Real name: Eric Westphal
Been thanked: 136 times
Contact:

Re: Migrating from Nuke to Fusion. Need help in recreating Nuke gizmo

#15

Post by SirEdric » Sun Nov 05, 2017 9:35 am

Andrew...did I mention before that you totally rock?
If not: You Totally Rock!

Cheers.

Eric.