Announcement

Collapse
No announcement yet.

Animating on changed value

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

  • Animating on changed value

    Hello again everyone,

    I am trying to animate a director every time a text value changes. The value is coming from a data reader that loads every 5 seconds. What is happening is that the director animates every 5 seconds even though the value has not changed. The script below is what i have so far. How can i get the director to animate only when the value changes NOT every 5 seconds.

    Thanks in advance,
    Shotski

    dim Glow_2_PCT as container
    dim G2 as string

    dim G2Anim as director

    sub OnInit()

    Glow_2_PCT = Scene.FindContainer("Percent_2")
    G2Anim = stage.Finddirector("PCT_2_GLOW")

    Glow_2_PCT.geometry.RegisterTextChangedCallback()

    end sub

    sub OnGeometryChanged(geom As Geometry)

    G2 = Glow_2_PCT.geometry.text

    this.geometry.text = G2

    RunAnim()

    end sub


    sub RunAnim()
    G2Anim.startanimation()
    end sub

  • #2
    You could register a callback on the text container .. Place this on a script plugin that is on the font container you want to trigger the director....and click compile

    'code
    '-------------------
    Dim G2Anim as Director = Stage.FindDirector("PCT_2_GLOW")
    sub OnInit()
    This.geometry.RegisterTextChangedCallback()
    end sub

    sub OnGeometryChanged(geom As Geometry)
    G2Anim.StartAnimation()
    end sub
    '---------------------

    Comment


    • #3
      Hi Novacane,

      The script works when i enter the numbers manually but it still animates every 5 seconds because of the data reader. Any other ideas??

      Thanks,
      Shotski

      Comment


      • #4
        Are the values changing everytime ? Or are you saying that the script triggers animation even if the text pulled from the Datareader is the same? If it for some reason animates every time datareader does a refresh even tho values have not changed then it can be fixed with an IF statement...

        Try this script

        '-------------------
        Dim initialString as string
        Dim newString as string
        Dim G2Anim as Director = Stage.FindDirector("PCT_2_GLOW")
        sub OnInit()
        This.geometry.RegisterTextChangedCallback()
        initialString = this.geometry.text
        end sub

        sub OnGeometryChanged(geom As Geometry)

        newString = This.geometry.text

        If newString = initialString Then
        'Data is stiill the same.....Dont Animate
        else
        G2Anim.StartAnimation()
        initialString = this.geometry.text
        end sub
        '---------------------
        Last edited by Novacane89; 08-14-2018, 08:40 PM.

        Comment


        • #5
          Thanks,

          Novacane,

          I will report back.

          Comment


          • #6
            Hi again,

            I need to clear the outgoing information from all the text containers so it does not interfere with the incoming information. is there a way to clear it by ID?

            For example, each text container has its own ID (#27126*TEXT_FROM_GUI SET xxxxxs). Is there a script to clear each individual text container? I can get this to work in VizSend but not in scripting.

            Comment


            • #7
              There are 2 ways that come to mind, Using native viz script or System.SendCommands(Both of which is using viz script plugin and viz script events).
              Paste this into a vizscript plugin and click compile,
              There will be an empty container slot, you can drag a font container into that slot. The "Clear" button clears the text. Its just meant to be as an example you can use to apply in your own work
              There are two examples of clearing the text,
              Uncomment the system command line and comment out the 'GetParameterContainer("Text1").geometry.text = "".... then you will see the other command in effect when hitting clear. check the console. Cheers

              '-----------
              sub OnInitParameters()
              RegisterPushButton("Clear","Clear",1)
              RegisterParameterContainer("Text1","Text1")
              RegisterPlugin("ClearTextScript")
              end sub

              sub OnExecAction(buttonId As Integer)

              If buttonId = 1 then
              'You clean clear the text with native Vizscript commands or System.Send Commands

              'Native Viz script
              GetParameterContainer("Text1").geometry.text = ""

              'System.SendCommand
              'System.SendCommand("#" & GetParameterContainer("Text1").VizId & "*GEOM*TEXT SET ")
              end if

              end sub

              '-----------

              Comment


              • #8
                Thanks Novacane for all your help. It is very much appreciated!!!!.

                Comment


                • #9
                  No problem Shotski,

                  Cheers

                  Comment

                  Working...
                  X