Jump to: Board index » General » Fusion

Set a Render Range from a variable on a custom button

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

bentheanimator

  • Posts: 431
  • Joined: Mon May 13, 2019 10:38 pm
  • Location: Minneapolis, MN
  • Real Name: Ben Hall

Set a Render Range from a variable on a custom button

PostWed Jun 07, 2023 7:53 pm

I've tried a few different ways to get the value from the Render Frame In and pass it to a script on another button. Tried GetAttribs, set the tool to implicitly be a number before adding it into the script but it's not working. What am I missing here?

Screenshot 2023-06-07 145230.png
Screenshot 2023-06-07 145230.png (40.23 KiB) Viewed 849 times


Code: Select all
{
   Tools = ordered() {
      RangeSaver_1 = Saver {
         Inputs = {
            Blend = Input {
               Value = 0,
            },
            ProcessWhenBlendIs00 = Input { Value = 0, },
            Clip = Input {
               Value = Clip {
                  Length = 0,
                  Saving = true,
                  TrimIn = 0,
                  ExtendFirst = 0,
                  ExtendLast = 0,
                  Loop = 1,
                  AspectMode = 0,
                  Depth = 0,
                  TimeCode = 0,
                  GlobalStart = -2000000000,
                  GlobalEnd = -2000000000
               },
            },
            OutputFormat = Input { Value = FuID { "OpenEXRFormat" }, },
            ["Gamut.SLogVersion"] = Input { Value = FuID { "SLog2" }, },
            renderFrameIn = Input { Value = 10, },
            renderFrameOut = Input { Value = 20, },

         },
         ViewInfo = OperatorInfo {
            Pos = { 11110, 1897.5 },
            Flags = {
               ShowPic = true
            }
         },
         UserControls = ordered() {
            renderFrameIn = {
               INP_Integer = true,
               INP_MinAllowed = 0,
               LINKID_DataType = "Number",
               ICS_ControlPage = "File",
               INPID_InputControl = "ScrewControl",
               LINKS_Name = "Render Frame In",
            },
            renderFrameOut = {
               INP_Integer = true,
               INP_MinAllowed = 0,
               LINKID_DataType = "Number",
               ICS_ControlPage = "File",
               INPID_InputControl = "ScrewControl",
               LINKS_Name = "Render Frame Out",

            },
            SOLO = {
               LINKS_Name = "Solo",
               ICS_ControlPage = "File",
               BTNCS_Execute = "    \n        function check_selected(tool)\n            return tool:GetAttrs('TOOLB_Selected')\n        end\n\n        function check_enabled(tool)\n            return tool:GetAttrs('TOOLB_PassThrough')\n        end\n\n        local comp = fu:GetCurrentComp()\n        local selectedSavers = comp:GetToolList(true, \"Saver\")\n        local allSavers = comp:GetToolList(false, \"Saver\")\n\n        comp:StartUndo(\"Solo Saver\")\n        \n        for _, currentSaver in pairs(allSavers) do\n            if not check_selected(currentSaver) then\n                currentSaver:SetAttrs( { TOOLB_PassThrough = true } )\n            end\n        end\n        \n        for _, sel in pairs(selectedSavers) do\n            if check_enabled(sel) then\n                sel:SetAttrs({ TOOLB_PassThrough = false})\n            end\n        end \n        comp:EndUndo()\n    ",
               LINKID_DataType = "Number",
               INPID_InputControl = "ButtonControl",
               INP_Default = 0,
            },
            RENDER = {
               LINKS_Name = "Render",
               ICS_ControlPage = "File",
               BTNCS_Execute = "composition:Render(true, 23, 53, 1)",
               LINKID_DataType = "Number",
               INPID_InputControl = "ButtonControl",
               INP_Default = 0,
            }
            
         }
      }
   }
}
Resolve & Fusion Studio 18.6.5
Windows 10
Intel Xeon CPU 2699A @ 2.40GHz | 128GB RAM | 2xRTX3090 | 512NVME System | 8TB NMVE Scratch | 80TB 8Gbps Fiber

MacOS 12.7.2
MacBook Pro 13,3 | 16GB | Radeon 460 4GB | 256GB System | 256GB Scratch
Offline

bentheanimator

  • Posts: 431
  • Joined: Mon May 13, 2019 10:38 pm
  • Location: Minneapolis, MN
  • Real Name: Ben Hall

Re: Set a Render Range from a variable on a custom button

PostThu Jun 08, 2023 8:58 pm

It works!

Here is a Saver Node that allows you to set the Frame In and Frame out of the Render Range and render from the Node. There is also a Solo button to disable all other Saver but the one you are on.

This is a pick up off a previous node created by Guacamole on WSL. Here's the thread it came from.
https://www.steakunderwater.com/wesuckless/viewtopic.php?t=1890&hilit=RangeSaver_1

The Solo button code came from Saver Plus made by Molavex that is available on Reactor.
https://www.steakunderwater.com/wesuckless/viewtopic.php?p=34832&hilit=Solo+Saver#p34832

The code to reference the property needed a time to call it from so:
ActiveTool.renderFrameIn doesn't work but ActiveTool.renderFrameIn[comp.CurrentTime] does.

You can also use ActiveTool.renderFrameIn[TIME_UNDEFINED].

This video was what showed me the solution. It's the first scripting video I watched back 5 years ago and I completely forgot about it...
I am Fusion - Stefan Ihringer's Scripting 101


Here's the node. Save it in your Macros folder as a ".setting" file.
Screenshot 2023-06-08 155036.png
Screenshot 2023-06-08 155036.png (48.94 KiB) Viewed 747 times

Code: Select all
{
   Tools = ordered() {
      RangeSaver_1 = Saver {
         CtrlWZoom = false,
         CustomData = {
            Path = {
               Map = {
                  ["Setting:"] = "Macros:\\"
               }
            },
         },
         Inputs = {
            Blend = Input {
               Value = 0,
               Expression = "iif(time < renderFrameIn, 0, iif(time > renderFrameOut, 0, 1))",
            },
            ProcessWhenBlendIs00 = Input { Value = 0, },
            Clip = Input {
               Value = Clip {
                  Length = 0,
                  Saving = true,
                  TrimIn = 0,
                  ExtendFirst = 0,
                  ExtendLast = 0,
                  Loop = 1,
                  AspectMode = 0,
                  Depth = 0,
                  TimeCode = 0,
                  GlobalStart = -2000000000,
                  GlobalEnd = -2000000000
               },
            },
            OutputFormat = Input { Value = FuID { "OpenEXRFormat" }, },
            ["Gamut.SLogVersion"] = Input { Value = FuID { "SLog2" }, },
            renderFrameIn = Input { Value = 10, },
            renderFrameOut = Input { Value = 20, },
         },
         ViewInfo = OperatorInfo {
            Pos = { 660, 181.5 },
            Flags = {
               ShowPic = true
            }
         },
         UserControls = ordered() {
            renderFrameIn = {
               INP_Integer = true,
               INP_MinAllowed = 0,
               LINKID_DataType = "Number",
               ICS_ControlPage = "File",
               INPID_InputControl = "ScrewControl",
               LINKS_Name = "Render Frame In",
            },
            renderFrameOut = {
               INP_Integer = true,
               INP_MinAllowed = 0,
               LINKID_DataType = "Number",
               ICS_ControlPage = "File",
               INPID_InputControl = "ScrewControl",
               LINKS_Name = "Render Frame Out",
            },
            SOLO = {
               LINKS_Name = "Solo",
               ICS_ControlPage = "File",
               BTNCS_Execute = "    \n        function check_selected(tool)\n            return tool:GetAttrs('TOOLB_Selected')\n        end\n\n        function check_enabled(tool)\n            return tool:GetAttrs('TOOLB_PassThrough')\n        end\n\n        local comp = fu:GetCurrentComp()\n        local selectedSavers = comp:GetToolList(true, \"Saver\")\n        local allSavers = comp:GetToolList(false, \"Saver\")\n\n        comp:StartUndo(\"Solo Saver\")\n        \n        for _, currentSaver in pairs(allSavers) do\n            if not check_selected(currentSaver) then\n                currentSaver:SetAttrs( { TOOLB_PassThrough = true } )\n            end\n        end\n        \n        for _, sel in pairs(selectedSavers) do\n            if check_enabled(sel) then\n                sel:SetAttrs({ TOOLB_PassThrough = false})\n            end\n        end \n        comp:EndUndo()\n    ",
               LINKID_DataType = "Number",
               INPID_InputControl = "ButtonControl",
               INP_Default = 0,
            },
            RENDER = {
               LINKS_Name = "Render",
               ICS_ControlPage = "File",
               BTNCS_Execute = "rfi = ActiveTool.renderFrameIn[comp.CurrentTime] \n rfo = ActiveTool.renderFrameOut[comp.CurrentTime] \n composition:Render(true, rfi, rfo, 1)",
               LINKID_DataType = "Number",
               INPID_InputControl = "ButtonControl",
               INP_Default = 0,
            }
         }
      }
   }
}
Resolve & Fusion Studio 18.6.5
Windows 10
Intel Xeon CPU 2699A @ 2.40GHz | 128GB RAM | 2xRTX3090 | 512NVME System | 8TB NMVE Scratch | 80TB 8Gbps Fiber

MacOS 12.7.2
MacBook Pro 13,3 | 16GB | Radeon 460 4GB | 256GB System | 256GB Scratch

Return to Fusion

Who is online

Users browsing this forum: No registered users and 52 guests