Announcement

Collapse
No announcement yet.

TextBG with transition Logic

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • TextBG with transition Logic

    Hello All,

    I found the attached scene on the forum but cant get it to work with transition logic. It works fine when loaded at start but when text changes it does not update on Geometry changed. I have attached the scene. It only updates if i go in and out of the text field twice. Strange. Any help is greatly appreciated.
    Attached Files
    Last edited by Shotski2; 06-21-2019, 06:54 PM.

  • #2
    i checked your script and added these few lines. Try it out, it now has more direct references to your director. It wont be able to find it via the stage.finddirector("Default")

    Code:
    sub OnInit()
    this.geometry.RegisterTextChangedCallback()
    end sub
    
    
    sub OnGeometryChanged(geom As Geometry)
        dim width =    cdbl(system.SendCommand("0 #" & this.nextcontainer.vizID & "*GEOM*width GET"))
        dim dDir as Director
            dDir = this.GetDirector()
            dDir.findkeyframe("width").floatValue = width
            system.SendCommand("0 #" & this.LastChildContainer.vizID & "*GEOM*width SET " & width)
            println width
    
      'Update Preview    
        dim OldTime = dDir.time
            dDir.show(0)
            dDir.show(OldTime)
    end sub

    Comment


    • #3
      Hi Lars,

      Still having the issue where the mask width does not update on geometry changed. I have to go into the text field twice to get it to adjust to the correct length. I am not sure why it is doing that. It seems like it is referencing the mask container but i am not trying to get the width of the mask but the next container. which is the text BG. It looks like the script skips the next container and goes to the last automatically but the script does not tell it to do that. I'm confused.
      Last edited by Shotski2; 06-24-2019, 03:11 PM.

      Comment


      • #4
        Your code tells it to look for the mask container with this command this.LastChildContainer.vizID
        I changed the way you reference your elements in the script. This is the way I usually refer to things with scripting and TL. Hopefully this works for you.
        https://www.dropbox.com/s/ciz44599jr...Lower.via?dl=0

        Comment


        • #5
          Still does not work. The problem is that the mask is not updating to the length of the bg_text_master when the geometry changes.
          Attached are examples of when i first call up the scene then what happens when the text is changed.
          Attached Files

          Comment


          • #6
            Ahh I see it. it wasnt setting the keyframe value. Try and replace your code with this.

            Code:
            'Global variables
            dim cText as Container
            dim cBG as Container
            dim cMask as Container
            dim dDir as Director
            dim kWidth as Keyframe
            
            sub OnInit()
                cText = this.FindSubContainer("text")
                cBG = this.FindSubContainer("bg_text_master")
                cMask = this.FindSubContainer("mask_super")
                dDir = cText.GetDirector()
                kWidth = dDir.FindKeyframe("width")
                cText.geometry.RegisterTextChangedCallback()
            end sub
            
            
            sub OnGeometryChanged(geom As Geometry)
                dim width =    cdbl(system.SendCommand("0 #" & cBG.vizID & "*GEOM*width GET"))
                    kWidth.floatValue = width
                    'println (14, "Keyframe value is set to " & width)
                    system.SendCommand("0 #" & cMask.vizID & "*GEOM*width SET " & width)
                    'println (14, "Width of BG is set to " & width)
            
              'Update Preview    
                dim OldTime = dDir.time
                    dDir.show(0)
                    dDir.show(OldTime)
            end sub

            Comment


            • #7
              Hi Lars,

              Same result. The mask does not update when the text changes. attached is an image. It only updates when i go in to the text field twice and not when the geometry changes. The circled area shows what the mask should be set to 881, but it still stays at the old setting of 395.
              Attached Files

              Comment


              • #8
                This seemed to work for me.
                Code:
                'Global variables
                dim cText as Container
                dim cBG as Container
                dim cMask as Container
                dim dDir as Director
                dim kWidth as Keyframe
                
                sub OnInit()
                    cText = this.FindSubContainer("text")
                    cBG = this.FindSubContainer("bg_text_master")
                    cMask = this.FindSubContainer("mask_super")
                    dDir = cText.GetDirector()
                    kWidth = dDir.FindKeyframe("width")
                    cText.geometry.RegisterTextChangedCallback()
                end sub
                
                
                sub OnGeometryChanged(geom As Geometry)
                    dim bgWidth as Double
                        bgWidth = cBG.Geometry.GetParameterDouble("width")
                        'println(13, "bgWidth is " & bgWidth)
                        kWidth.floatValue = bgWidth
                        'println (14, "Width of BG is set to " & bgWidth)
                end sub

                Comment


                • #9
                  Still did not work for me. Does not update the mask until i either go in and out of the text field or in TL if i take it out then back in. Oh well, i will probably need to look for other ways to do this.
                  Attached Files

                  Comment


                  • #10
                    I was able to get this to work by triggering the script by a button push since it was not working when the geometry changed i just triggered it with a button.

                    Thanks Lars for the help in getting the correct director and everything else.

                    Shotski

                    Comment

                    Working...
                    X