Graphics

 View Only
Expand all | Collapse all

Scripting A Key Frame Change

  • 1.  Scripting A Key Frame Change

    Posted 11-18-2024 09:53

    I'm sorry if this is the wrong place to ask or if this is extremely simple but I'm extremely new to scripting. I need to be able to change the last Key Frame of an animation with a text input. The script I have right now is:

    Dim Wheel as xpBaseObject
    Dim EndFrame as xpTextObject
    Self.GetObjectByName("Row Wheel", Wheel)
    Self.GetObjectByName("End Frame", EndFrame)
    Function as Wheel.SetKeyFrameRotation (ByVal 180 as Integer,ByVal 0 as Double,ByVal 0 as Double,ByVal EndFrame as Integer)

    I'm getting errors on both the Wheel and EndFrame Variables. Error BC42030 because they're passed by reference before it has been assigned a value. Line 5 also has the error BC30289 Where Statement cannot appear within a method body. Thank you in advance!



    ------------------------------
    Emilio Lopez
    ------------------------------


  • 2.  RE: Scripting A Key Frame Change

    Posted 11-18-2024 10:11

    There's some good threads on this subject, perhaps one like this might get you on the right path. 

    https://rossvideo.community/communities/community-home/digestviewer/viewthread?GroupId=199&MID=21401&CommunityKey=91812bfd-9393-4a3f-8a74-7f8035df130e 



    ------------------------------
    Simon Redmile
    Senior Graphic Programmer & Designer
    Ross Video
    Bristol United Kingdom
    ------------------------------



  • 3.  RE: Scripting A Key Frame Change

    Posted 11-20-2024 09:44

    Hello

    The errors are due to uninitialized variables and syntax issues.

    Dim Wheel As xpBaseObject
    Dim EndFrame As xpTextObject

    If Not Self.GetObjectByName("Row Wheel", Wheel) Then Exit Sub
    If Not Self.GetObjectByName("End Frame", EndFrame) Then Exit Sub

    Dim endFrameValue As Integer
    If Integer.TryParse(EndFrame.Text, endFrameValue) Then
        Wheel.SetKeyFrameRotation(180, 0, 0, endFrameValue)
    End If

    This should resolve your issues. 

    Thank you !

     



    ------------------------------
    steve diaz
    Software Developer
    Walmart
    ------------------------------



  • 4.  RE: Scripting A Key Frame Change

    Posted 11-22-2024 20:47

    This works! Thank you! I also had set up a Bezier Spline on the keyframes. Would you know how to maintain the spline? In the SDK help, in says I should be able to add 

    Optional ByVal 
    Interpolation
     As 
    KeyInterpolation
     = 0

    How would I be able to add this to the script to keep the Spline? Thank you in advance



    ------------------------------
    Emilio Lopez
    ------------------------------



  • 5.  RE: Scripting A Key Frame Change

    Posted 11-25-2024 16:16

    Do you try playing with TCB keyframe type, you have bias and tension etc. 



    ------------------------------
    Simon Redmile
    Senior Graphic Programmer & Designer
    Ross Video
    Bristol United Kingdom
    ------------------------------



  • 6.  RE: Scripting A Key Frame Change

    Posted 11-27-2024 23:46

    I've tried TCB Spline and Bezier Spline but when it gets to the end of the animation, it stops suddenly without taking the spline. In the SDK Help file, it says that I should be able to use "Interpolation As KeyInterpolation = 0" but I'm struggling with how to write it as a script.



    ------------------------------
    Emilio Lopez
    ------------------------------



  • 7.  RE: Scripting A Key Frame Change

    Posted 11-28-2024 06:35

    Do you have an example of what you would like the motion to look like and how it is behaving in XPression that you don't like as a comparison?



    ------------------------------
    Simon Redmile
    Senior Graphic Programmer & Designer
    Ross Video
    Bristol United Kingdom
    ------------------------------



  • 8.  RE: Scripting A Key Frame Change

    Posted 11-29-2024 22:11

    I should be able to get a test file but I'm using this to create a wheel and I want the wheel to slow down at the end of the rotation, using the Bezier. However, this script has the wheel end on the last frame instantly. No slow down, no Bezier. Is there a way to add a Bezier to this script?



    ------------------------------
    Emilio Lopez
    ------------------------------



  • 9.  RE: Scripting A Key Frame Change

    Posted 12-01-2024 15:18

    What does your script look like currently? Are you using SetKeyFrameValueTCB (or SetKeyFrameVectorTCB)?



    ------------------------------
    Zachary Fradette
    United States
    ------------------------------



  • 10.  RE: Scripting A Key Frame Change

    Posted 12-08-2024 17:28
      |   view attached

    This is my current script:

    Dim Wheel As xpBaseObject
    Dim EndFrame As xpTextObject

    If Not Self.GetObjectByName("Row Wheel", Wheel) Then Exit Sub
    If Not Self.GetObjectByName("End Frame", EndFrame) Then Exit Sub

    Dim endFrameValue As Integer
    If Integer.TryParse(EndFrame.Text, endFrameValue) Then
        Wheel.SetKeyFrameRotation(200, 0, 0, endFrameValue)

    Wheel.SetKeyFrameTCB (200, 32, 1, 4, 1)
    End If

    In the layout, it plays out properly but when I play in sequence, the ending jumps to the last frame instead of slowing. I put a project file here if you'd have any insight.



    ------------------------------
    Emilio Lopez
    ------------------------------

    Attachment(s)

    xpf
    Spinners.xpf   255 KB 1 version


  • 11.  RE: Scripting A Key Frame Change

    Posted 12-02-2024 02:33
      |   view attached

    Hi everyone
    Emilio look the attached project



    ------------------------------
    Roman Yaroshenko
    chief specialist
    RBC-TV
    Moscow Russian Federation
    ------------------------------

    Attachment(s)

    xpf
    wheel.xpf   37 KB 1 version


  • 12.  RE: Scripting A Key Frame Change

    Posted 12-05-2024 19:21

    This is exactly what I need! I'm struggling to see how to change the scripting so I can use different materials.



    ------------------------------
    Emilio Lopez
    ------------------------------