Graphics

 View Only
  • 1.  Setting Keyframes from Value in Text Object

    Posted 05-14-2016 02:05
    I've built a pie chart from ten cylinders by using Visual Logic to set the starting angle of subsequent cylinders from the ending angle of the previous. I have a scene director with ten animation controllers, which animate each pie slice cylinder on. The cylinders are Cylinder1 through 10. Each cylinder has a corresponding Quad whose BoundingBox.WidthScaled feeds the logic to set start and end angles. I have text objects Cyl01End through Cyl10End which I want to use to assign a keyframe on each of my ten animation controllers.

    I have gotten the following script to compile, but I cannot tell that it is doing what I'm hoping for.

    Dim Quad as xpBaseObject
    Self.GetObjectByName("Quad1", Quad)
    Self.GetObjectByName("Quad2", Quad)
    Self.GetObjectByName("Quad3", Quad)
    Self.GetObjectByName("Quad4", Quad)
    Self.GetObjectByName("Quad5", Quad)
    Self.GetObjectByName("Quad6", Quad)
    Self.GetObjectByName("Quad7", Quad)
    Self.GetObjectByName("Quad8", Quad)
    Self.GetObjectByName("Quad9", Quad)
    Self.GetObjectByName("Quad10", Quad)
    Dim Cyl01End as xpTextObject
    Self.GetObjectByName("Cyl01End", Cyl01End)
    Dim Cyl02End as xpTextObject
    Self.GetObjectByName("Cyl02End", Cyl02End)
    Dim Cyl03End as xpTextObject
    Self.GetObjectByName("Cyl03End", Cyl03End)
    Dim Cyl04End as xpTextObject
    Self.GetObjectByName("Cyl04End", Cyl04End)
    Dim Cyl05End as xpTextObject
    Self.GetObjectByName("Cyl05End", Cyl05End)
    Dim Cyl06End as xpTextObject
    Self.GetObjectByName("Cyl06End", Cyl06End)
    Dim Cyl07End as xpTextObject
    Self.GetObjectByName("Cyl07End", Cyl07End)
    Dim Cyl08End as xpTextObject
    Self.GetObjectByName("Cyl08End", Cyl08End)
    Dim Cyl09End as xpTextObject
    Self.GetObjectByName("Cyl09End", Cyl09End)
    Dim Cyl10End as xpTextObject
    Self.GetObjectByName("Cyl10End", Cyl10End)
    Dim AnimCtl as xpAnimController
    Self.GetAnimControllerByName("AnimController1", AnimCtl)
    AnimCtl.SetKeyFrameValue(Quad, 30, "Scale.X", "Cyl01End")
    Self.GetAnimControllerByName("AnimController2", AnimCtl)
    AnimCtl.SetKeyFrameValue(Quad, 30, "Scale.X", "Cyl02End")
    Self.GetAnimControllerByName("AnimController3", AnimCtl)
    AnimCtl.SetKeyFrameValue(Quad, 30, "Scale.X", "Cyl03End")
    Self.GetAnimControllerByName("AnimController4", AnimCtl)
    AnimCtl.SetKeyFrameValue(Quad, 30, "Scale.X", "Cyl04End")
    Self.GetAnimControllerByName("AnimController5", AnimCtl)
    AnimCtl.SetKeyFrameValue(Quad, 30, "Scale.X", "Cyl05End")
    Self.GetAnimControllerByName("AnimController6", AnimCtl)
    AnimCtl.SetKeyFrameValue(Quad, 30, "Scale.X", "Cyl06End")
    Self.GetAnimControllerByName("AnimController7", AnimCtl)
    AnimCtl.SetKeyFrameValue(Quad, 30, "Scale.X", "Cyl07End")
    Self.GetAnimControllerByName("AnimController8", AnimCtl)
    AnimCtl.SetKeyFrameValue(Quad, 30, "Scale.X", "Cyl08End")
    Self.GetAnimControllerByName("AnimController9", AnimCtl)
    AnimCtl.SetKeyFrameValue(Quad, 30, "Scale.X", "Cyl09End")
    Self.GetAnimControllerByName("AnimController10", AnimCtl)
    AnimCtl.SetKeyFrameValue(Quad, 30, "Scale.X", "Cyl10End")


    I am even close to the right track?


  • 2.  RE: Setting Keyframes from Value in Text Object

    Posted 05-16-2016 17:46
    There are quite a few issues in your script.

    This block will keep overwriting the value in the Quad baseobject because you keep getting different objects and storing it in quad.

    Self.GetObjectByName("Quad1", Quad)
    Self.GetObjectByName("Quad2", Quad)
    Self.GetObjectByName("Quad3", Quad)
    Self.GetObjectByName("Quad4", Quad)
    Self.GetObjectByName("Quad5", Quad)
    Self.GetObjectByName("Quad6", Quad)
    Self.GetObjectByName("Quad7", Quad)
    Self.GetObjectByName("Quad8", Quad)
    Self.GetObjectByName("Quad9", Quad)
    Self.GetObjectByName("Quad10", Quad)


    This line,

    AnimCtl.SetKeyFrameValue(Quad, 30, "Scale.X", "Cyl01End")


    should be more like this:


    dim textobj as xpTextObject
    self.GetObjectByName("Cyl01End", textobj)
    AnimCtl.SetKeyFrameValue(Quad, 30, "Scale.X", CDbl(textobj.text))


    You need to retrieve the text object by name, then gets the text objects text, convert it to a double and pass it in as the value to the SetKeyFrameValue call.
    #XPression


  • 3.  RE: Setting Keyframes from Value in Text Object

    Posted 05-17-2016 04:05
    I decided I should get the script successfully setting one keyframe, so I left the parts I thought you meant were functional and added your corrections and got it to compile, but it doesn't set the keyframe. I have each of ten pie slices wiping on through ten Animation Controllers on one Scene Director. Should I rebuild with a single Animation Controller? If I set the keyframes manually, my slices wipe on correctly.

    dim Quad1 as xpBaseObject
    dim Cyl01End as xpTextObject
    dim AnimCtl as xpAnimController
    dim textobj as xpTextObject
    self.GetObjectByName("Cyl01End", textobj)
    self.GetAnimControllerByName("AnimController1", AnimCtl)
    AnimCtl.SetKeyFrameValue(Quad1, 30, "Scale.X", CDbl(textobj.text))
    #XPression


  • 4.  RE: Setting Keyframes from Value in Text Object

    Posted 05-17-2016 13:03
    By eye, that looks relatively correct.. I think if you post a sample XPF it would be easier to check it for you. Can you make a simple example of just one cylinder, textobject and slice..
    I could try it later today.
    #XPression


  • 5.  RE: Setting Keyframes from Value in Text Object

    Posted 05-17-2016 13:05
    Just realized nowhere in that new snippet do you get the Quad1 object. You need a Self.GetObjectByName to get the Quad.
    #XPression


  • 6.  RE: Setting Keyframes from Value in Text Object

    Posted 05-17-2016 20:04
    I tried inserting that and I couldn't get it to compile. I uploaded PieChartForBrianFord.xpp to rossbrickftp.com. I forgot username and password, so I just uploaded.
    #XPression


  • 7.  RE: Setting Keyframes from Value in Text Object

    Posted 05-18-2016 00:07
    I changed your OnOnline script to this (just added the GetObjectByName for the Quad1 as previously mentioned)


    dim Quad1 as xpBaseObject
    dim Cyl01End as xpTextObject
    dim AnimCtl as xpAnimController
    dim textobj as xpTextObject
    self.GetObjectByName("Quad1", Quad1)
    self.GetObjectByName("Cyl01End", textobj)
    self.GetAnimControllerByName("AnimController1", AnimCtl)
    AnimCtl.SetKeyFrameValue(Quad1, 30, "Scale.X", CDbl(textobj.text))


    I also removed the script from OnSetText.

    I also removed the Visual Logic block that copied the value from Cyl01End to Quad1.Scale.X (you dont want this in VL, since the script/anim ctl need to modify it).

    Once making all those changes, the scene worked as you want.
    #XPression


  • 8.  RE: Setting Keyframes from Value in Text Object

    Posted 05-18-2016 02:06
    Thank you so much, Brian. I took another look on my dinner break and found that I had left something out of GetObjectByName...and made it work. To make all ten slices work, the script got pretty bulky but it works beautifully. The Visual Logic error was a holdover from when I was testing setting the keyframes manually. I wasn't sure about where to put the script. I now have it in OnOnline and OnPreviewRender. I haven't published to my project server yet because I am still working on labeling the pie slices, but I am afraid that I won't be able to see the final chart in ENPS. Any ideas on that? Should I include something like SceneDirector.Play in OnPreviewRender? ...but that will pause for my pauses, hmm.
    #XPression


  • 9.  RE: Setting Keyframes from Value in Text Object

    Posted 05-18-2016 23:37
    The script shouldn't get bulkier if you use a loop instead of duplicating that section over and over; it should only be a few extra lines of code in total.

    I'm not too sure about the preview in ENPS part; that would take some extra though... ENPS should call the OnPreviewRender, so you might just be able to do a scene.scenedirector.position=100 or something like that.
    #XPression