Jump to: Board index » General » Fusion

Scripting to control text

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

audiocage

  • Posts: 180
  • Joined: Tue Jul 20, 2021 1:51 pm
  • Location: France
  • Real Name: Doug Dina

Scripting to control text

PostSun Feb 09, 2025 12:57 am

Hi All,
The comp I am trying to create is basically a timeline of years, like 1999, 2000, 2001 … 2025. It would be a linear left to right “sentence” basically with little tick marks under each year. I’ve easily created the tick mark series using Duplicate. However, I don’t know how to generate all the years in a row. I can’t figure out how to script it such that it creates the sequence based on the value of the first year.

I think the scripting is done in Lua. But, I don’t know how to create the sequence of years.

Ultimately, this “year scale” will be used over video to show the year of that particular moment. It can slide backwards and forwards a number of years, likely using Time Stretcher.

Any ideas?
------------------
Doug Dina
Davinci Resolve Studio 19.1.4
Speed Editor
Apple STUDIO Max
PROCESSOR AND GRAPHICS M1 MAX WITH 10C CPU, 32C GPU
MEMORY 64GB UNIFIED MEMORY
MONITOR ASUS VP28UQG 28 "4K UHD 3840 x 2160
Offline

Sander de Regt

  • Posts: 4130
  • Joined: Thu Nov 13, 2014 10:09 pm

Re: Scripting to control text

PostSun Feb 09, 2025 10:18 am

Since I don't know much about scripting, I always fall back to the question: why scripting in the first place? What's wrong with just typing in these values in a Text+ tools and take it from there?
That's probably less work to type than a scripted solution.
Sander de Regt

ShadowMaker SdR
The Netherlands
Offline

Sander de Regt

  • Posts: 4130
  • Joined: Thu Nov 13, 2014 10:09 pm

Re: Scripting to control text

PostSun Feb 09, 2025 10:22 am

This took literally less than 5 minutes to set up. I think it might be close to what you need.

Code: Select all
{
   Tools = ordered() {
      Text1 = TextPlus {
         CtrlWZoom = false,
         Inputs = {
            Width = Input { Value = 1920, },
            Height = Input { Value = 1080, },
            ["Gamut.SLogVersion"] = Input { Value = FuID { "SLog2" }, },
            Center = Input {
               SourceOp = "Path1",
               Source = "Position",
            },
            LayoutRotation = Input { Value = 1, },
            SelectTransform = Input { Value = 1, },
            WordSpacing = Input { Value = 12, },
            TransformRotation = Input { Value = 1, },
            SelectElement = Input { Value = 1, },
            Select = Input { Value = 1, },
            Name2 = Input { Value = "TICKS", },
            Enabled2 = Input { Value = 1, },
            Softness1 = Input { Value = 1, },
            StyledText = Input { Value = "2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025", },
            Font = Input { Value = "Open Sans", },
            Style = Input { Value = "Bold", },
            Size = Input { Value = 0.0244, },
            VerticalJustificationNew = Input { Value = 3, },
            HorizontalJustificationNew = Input { Value = 3, },
            ElementShape2 = Input { Value = 2, },
            Level2 = Input { Value = 2, },
            Green2 = Input { Value = 1, },
            Blue2 = Input { Value = 1, },
            Softness2 = Input { Value = 1, },
            Offset2 = Input { Value = { 0, -0.017 }, },
            Size2 = Input { Value = 1, },
            SizeX2 = Input { Value = 0.05, }
         },
         ViewInfo = OperatorInfo { Pos = { 220, 16.5 } },
      },
      Path1 = PolyPath {
         DrawMode = "InsertAndModify",
         CtrlWZoom = false,
         Inputs = {
            Displacement = Input {
               SourceOp = "Path1Displacement",
               Source = "Value",
            },
            PolyLine = Input {
               Value = Polyline {
                  Points = {
                     { Linear = true, LockY = true, X = 0.447, Y = -0.214814814814815, RX = -0.458, RY = 0 },
                     { Linear = true, LockY = true, X = -0.927, Y = -0.214814814814815, LX = 0.458, LY = 0 }
                  }
               },
            }
         },
      },
      Path1Displacement = BezierSpline {
         SplineColor = { Red = 255, Green = 0, Blue = 255 },
         CtrlWZoom = false,
         NameSet = true,
         KeyFrames = {
            [0] = { 0, RH = { 333.333333333333, 0.333333333333333 }, Flags = { LockedY = true } },
            [1000] = { 1, LH = { 666.666666666667, 0.666666666666667 }, Flags = { Linear = true, LockedY = true } }
         }
      }
   }
}
Sander de Regt

ShadowMaker SdR
The Netherlands
Offline

Sander de Regt

  • Posts: 4130
  • Joined: Thu Nov 13, 2014 10:09 pm

Re: Scripting to control text

PostSun Feb 09, 2025 10:27 am

Or this with an actual line underneath. All done in a single tool.

2025-02-09 TimelineInText.jpg
2025-02-09 TimelineInText.jpg (108.94 KiB) Viewed 1562 times



Code: Select all
{
   Tools = ordered() {
      Text1 = TextPlus {
         CtrlWZoom = false,
         Inputs = {
            Width = Input { Value = 1920, },
            Height = Input { Value = 1080, },
            ["Gamut.SLogVersion"] = Input { Value = FuID { "SLog2" }, },
            Center = Input {
               SourceOp = "Path1",
               Source = "Position",
            },
            LayoutRotation = Input { Value = 1, },
            SelectTransform = Input { Value = 1, },
            WordSpacing = Input { Value = 12, },
            TransformRotation = Input { Value = 1, },
            SelectElement = Input { Value = 2, },
            Select = Input { Value = 2, },
            Name2 = Input { Value = "TICKS", },
            Enabled2 = Input { Value = 1, },
            Name3 = Input { Value = "LINE", },
            Enabled3 = Input { Value = 1, },
            Softness1 = Input { Value = 1, },
            StyledText = Input { Value = "2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025", },
            Font = Input { Value = "Open Sans", },
            Style = Input { Value = "Bold", },
            Size = Input { Value = 0.0244, },
            VerticalJustificationNew = Input { Value = 3, },
            HorizontalJustificationNew = Input { Value = 3, },
            ElementShape2 = Input { Value = 2, },
            Level2 = Input { Value = 2, },
            Green2 = Input { Value = 1, },
            Blue2 = Input { Value = 1, },
            Softness2 = Input { Value = 1, },
            Offset2 = Input { Value = { 0, -0.017 }, },
            Size2 = Input { Value = 1, },
            SizeX2 = Input { Value = 0.05, },
            ElementShape3 = Input { Value = 2, },
            Level3 = Input { Value = 0, },
            Red3 = Input { Value = 1, },
            Green3 = Input { Value = 1, },
            Blue3 = Input { Value = 1, },
            Softness3 = Input { Value = 1, },
            SoftnessX3 = Input { Value = 0, },
            SoftnessY3 = Input { Value = 0, },
            Offset3 = Input { Value = { 0, -0.027 }, },
            Size3 = Input { Value = 1, },
            SizeY3 = Input { Value = 0.109, }
         },
         ViewInfo = OperatorInfo { Pos = { 220, 16.5 } },
      },
      Path1 = PolyPath {
         DrawMode = "InsertAndModify",
         CtrlWZoom = false,
         Inputs = {
            Displacement = Input {
               SourceOp = "Path1Displacement",
               Source = "Value",
            },
            PolyLine = Input {
               Value = Polyline {
                  Points = {
                     { Linear = true, LockY = true, X = 0.447, Y = -0.214814814814815, RX = -0.458, RY = 0 },
                     { Linear = true, LockY = true, X = -0.927, Y = -0.214814814814815, LX = 0.458, LY = 0 }
                  }
               },
            }
         },
      },
      Path1Displacement = BezierSpline {
         SplineColor = { Red = 255, Green = 0, Blue = 255 },
         CtrlWZoom = false,
         NameSet = true,
         KeyFrames = {
            [0] = { 0, RH = { 333.333333333333, 0.333333333333333 }, Flags = { LockedY = true } },
            [1000] = { 1, LH = { 666.666666666667, 0.666666666666667 }, Flags = { Linear = true, LockedY = true } }
         }
      }
   },
   ActiveTool = "Text1"
}
Sander de Regt

ShadowMaker SdR
The Netherlands
Offline
User avatar

KrunoSmithy

  • Posts: 4562
  • Joined: Fri Oct 20, 2023 11:01 pm
  • Warnings: 1
  • Real Name: Kruno Stifter

Re: Scripting to control text

PostSun Feb 09, 2025 11:40 am

Sander de Regt wrote:Or this with an actual line underneath. All done in a single tool.


I started doing something else, but that is pretty brilliant set up. Will steal this. Hope you don't mind. I was trying to add spacing between years, but when spacing is recognized as Tab space, it activates the tab feature in the Text+ allowing only 8 tab spacing. Didn't realize there is word spacing feature built into it. Cool. I remember once you answered my question about a doted line on a path, also with a text +. It may not be always the most intuitive tool to use , but it is certianly jam packed with features. I made a lower third with it, just one tool. Pretty cool.
Offline
User avatar

audiocage

  • Posts: 180
  • Joined: Tue Jul 20, 2021 1:51 pm
  • Location: France
  • Real Name: Doug Dina

Re: Scripting to control text

PostSun Feb 09, 2025 2:06 pm

Sander,
I’ve done a bunch of coding years ago so I think I can figure it out. I believe that Fusion uses Lua. However, where can I find all the Fusion commands and such? Is there a resource guide that you can suggest, please?
------------------
Doug Dina
Davinci Resolve Studio 19.1.4
Speed Editor
Apple STUDIO Max
PROCESSOR AND GRAPHICS M1 MAX WITH 10C CPU, 32C GPU
MEMORY 64GB UNIFIED MEMORY
MONITOR ASUS VP28UQG 28 "4K UHD 3840 x 2160
Offline

Sander de Regt

  • Posts: 4130
  • Joined: Thu Nov 13, 2014 10:09 pm

Re: Scripting to control text

PostSun Feb 09, 2025 2:12 pm

Just copy paste this in the node area and you're done.
Sander de Regt

ShadowMaker SdR
The Netherlands
Offline

birdseye

  • Posts: 480
  • Joined: Fri Jun 12, 2020 2:36 pm
  • Real Name: Iain Fisher

Re: Scripting to control text

PostSun Feb 09, 2025 2:34 pm

I don't understand your desire to use coding for such a basic function. My understanding is that you want to jump back and forth in years not tied to the forward progess of the video.
In that case you could do this sort of thing, keyframing the delay at the desired frames or add an extra control to the Text node and link and keyframe that in a similar way to this.

Code: Select all
{
   Tools = ordered() {
      Merge1 = Merge {
         CtrlWZoom = false,
         Inputs = {
            Background = Input {
               SourceOp = "Background1",
               Source = "Output",
            },
            Foreground = Input {
               SourceOp = "Text1",
               Source = "Output",
            },
            PerformDepthMerge = Input { Value = 0, },
         },
         ViewInfo = OperatorInfo { Pos = { 552, 66.1515 } },
      },
      Text1 = TextPlus {
         CtrlWZoom = false,
         Inputs = {
            GlobalOut = Input { Value = 500, },
            Width = Input { Value = 1920, },
            Height = Input { Value = 1080, },
            ["Gamut.SLogVersion"] = Input { Value = FuID { "SLog2" }, },
            StyledText = Input { Expression = "TimeSpeed1.Delay", },
            Font = Input { Value = "Open Sans", },
            Style = Input { Value = "Bold", },
            VerticalJustificationNew = Input { Value = 3, },
            HorizontalJustificationNew = Input { Value = 3, },
         },
         ViewInfo = OperatorInfo { Pos = { 552.667, 17.6667 } },
      },
      Background1 = Background {
         Inputs = {
            GlobalOut = Input { Value = 500, },
            Width = Input { Value = 1920, },
            Height = Input { Value = 1080, },
            ["Gamut.SLogVersion"] = Input { Value = FuID { "SLog2" }, },
            TopLeftRed = Input { Value = 1, },
         },
         ViewInfo = OperatorInfo { Pos = { 438, 65.5454 } },
      },
      TimeSpeed1 = TimeSpeed {
         NameSet = true,
         Inputs = {
            Delay = Input {
               SourceOp = "TimeSpeed1Delay",
               Source = "Value",
            },
            InterpolateBetweenFrames = Input { Value = 0, },
            SampleSpread = Input { Disabled = true, },
         },
         ViewInfo = OperatorInfo { Pos = { 296, 68.5758 } },
      },
      TimeSpeed1Delay = BezierSpline {
         SplineColor = { Red = 32, Green = 113, Blue = 253 },
         CtrlWZoom = false,
         NameSet = true,
         KeyFrames = {
            [0] = { 1962, RH = { 33, 1962 }, Flags = { Linear = true } },
            [99] = { 1962, LH = { 66, 1962 }, RH = { 99.3333333333333, 1964.33333333333 }, Flags = { Linear = true } },
            [100] = { 1969, LH = { 99.6666666666667, 1966.66666666667 }, RH = { 133, 1969 }, Flags = { Linear = true } },
            [199] = { 1969, LH = { 166, 1969 }, RH = { 199.333333333333, 1970.66666666667 }, Flags = { Linear = true } },
            [200] = { 1974, LH = { 199.666666666667, 1972.33333333333 }, RH = { 233, 1974 }, Flags = { Linear = true } },
            [299] = { 1974, LH = { 266, 1974 }, RH = { 299.333333333333, 1971 }, Flags = { Linear = true } },
            [300] = { 1965, LH = { 299.666666666667, 1968 }, RH = { 333, 1965 }, Flags = { Linear = true } },
            [399] = { 1965, LH = { 366, 1965 }, RH = { 399.333333333333, 1971.33333333333 }, Flags = { Linear = true } },
            [400] = { 1984, LH = { 399.666666666667, 1977.66666666667 }, RH = { 433, 1984 }, Flags = { Linear = true } },
            [499] = { 1984, LH = { 466, 1984 }, RH = { 499.333333333333, 1989 }, Flags = { Linear = true } },
            [500] = { 1999, LH = { 499.666666666667, 1994 }, Flags = { Linear = true } }
         }
      }
   },
   ActiveTool = "Merge1"
}

Return to Fusion

Who is online

Users browsing this forum: Chad Capeland and 24 guests