Graphics

 View Only
Expand all | Collapse all

Changing Image Based on XML feed Text

  • 1.  Changing Image Based on XML feed Text

    Posted 02-16-2016 05:32
    Hey Forum!

    I'm guessing there's a way, via scripting, to put an image on a quad based off text pulled from an RSS feed (XML), but I don't even know where to begin.

    Here's what I'm trying to do... I've got a scene built for NHL standings, specifically the Atlantic Division. The scene pulls the team name, Wins, Losses, OT Losses, and Points. There are also quads in place for the team logos.

    How do I populate those quads with the correct logo, based off the team name that I'm pulling from the RSS feed?\

    Thanks!


  • 2.  RE: Changing Image Based on XML feed Text

    Posted 02-17-2016 19:44
    The process for using the content of a text object to assign an image to a material is described in this XPression Project:
    http://transfer.rossvideo.com/f/9b10f9ced

    There may be ways to do it with Visual Logic, but I haven't tried it yet.
    #XPression


  • 3.  RE: Changing Image Based on XML feed Text

    Posted 02-17-2016 20:17
    Thanks Garner! I'll check that out as soon as I can. I'd love to try visual logic, but I'm not sure I'd know where to begin. I've done one thing visual logic so far, and it was just a basic "centering" of lines of text vertically on the screen as the number of lines gets bigger.
    #XPression


  • 4.  RE: Changing Image Based on XML feed Text

    Posted 02-17-2016 20:20
    I think for this application scripting is the best option.
    #XPression


  • 5.  RE: Changing Image Based on XML feed Text

    Posted 02-19-2016 03:36
    Man, I looked at that script, and I can not for the life of me figure it out. I tried changing it to 'Team' instead of 'Cand' to fit my scene, but it doesn't seem to work with that.

    What I don't understand is how it even finds the right image if the images aren't named Candidate 1.jpg ... which they aren't in that sample scene. Also, they've directed each of the texture shaders to a specific file. How does it know which texture shader to use for which line? It's all very confusing.
    #XPression


  • 6.  RE: Changing Image Based on XML feed Text

    Posted 02-19-2016 19:19
    Here's a much simplified version of the script:
    http://transfer.rossvideo.com/f/33ab69aaa

    This is the most basic way the script can be written. It doesn't have some of the cool features as the one I originally posted though. The one I posted as the following built in:
    - (i) loops to shorten the length of the script when being used on multiple objects
    - making the image invisible if the script couldn't find an image
    - not updating materials that are already online on different channels
    #XPression


  • 7.  RE: Changing Image Based on XML feed Text

    Posted 02-20-2016 14:19
    Whoops! No it wasn't the right link!
    Here it is:
    http://transfer.rossvideo.com/f/33ab69aaa
    #XPression


  • 8.  RE: Changing Image Based on XML feed Text

    Posted 02-23-2016 05:41

    Hey Garner...

    I was able to get the script in that scene to work by changing the file path of the image and what-not, but when I try to do basically the same thing on my scene, it doesn't work.

    Does it matter if the text that it is looking to is coming from a datalinq source?

    Here's my code:



    'defines the text objects and quads that the script will
    dim Team1 as xpTextObject
    dim Team2 as xpTextObject
    dim Team3 as xpTextObject
    dim Team4 as xpTextObject
    dim Team5 as xpTextObject
    dim Team6 as xpTextObject
    dim Logo1 as xpBaseObject
    dim Logo2 as xpBaseObject
    dim Logo3 as xpBaseObject
    dim Logo4 as xpBaseObject
    dim Logo5 as xpBaseObject
    dim Logo6 as xpBaseObject
    dim material as xpMaterial
    dim shader as xpBaseShader
    dim FilePath as string

    'Find the text obect with the image name in it and the quad that will have the image assigned
    self.GetObjectByName("Team1", Team1)
    self.GetObjectByName("Logo1", Logo1)
    self.GetObjectByName("Team2", Team1)
    self.GetObjectByName("Logo2", Logo2)
    self.GetObjectByName("Team3", Team1)
    self.GetObjectByName("Logo3", Logo3)
    self.GetObjectByName("Team4", Team1)
    self.GetObjectByName("Logo4", Logo4)
    self.GetObjectByName("Team5", Team1)
    self.GetObjectByName("Logo5", Logo5)
    self.GetObjectByName("Team6", Team1)
    self.GetObjectByName("Logo6", Logo6)


    'the file path of the directory containing the images & the image format
    'put the content of the text object above into the file path
    FilePath = "I:\Sports Logos\NHL\Atlantic Division" + Team1.text + ".png"
    'find a material and change the file path of the texture in it
    engine.GetMaterialByName("Logo1", material)
    material.GetShader(0, shader)
    shader.SetFileName(FilePath)

    'the file path of the directory containing the images & the image format
    'put the content of the text object above into the file path
    FilePath = "I:\Sports Logos\NHL\Atlantic Division" + Team2.text + ".png"
    'find a material and change the file path of the texture in it
    engine.GetMaterialByName("Logo2", material)
    material.GetShader(0, shader)
    shader.SetFileName(FilePath)

    'the file path of the directory containing the images & the image format
    'put the content of the text object above into the file path
    FilePath = "I:\Sports Logos\NHL\Atlantic Division" + Team3.text + ".png"
    'find a material and change the file path of the texture in it
    engine.GetMaterialByName("Logo3", material)
    material.GetShader(0, shader)
    shader.SetFileName(FilePath)

    'the file path of the directory containing the images & the image format
    'put the content of the text object above into the file path
    FilePath = "I:\Sports Logos\NHL\Atlantic Division" + Team4.text + ".png"
    'find a material and change the file path of the texture in it
    engine.GetMaterialByName("Logo4", material)
    material.GetShader(0, shader)
    shader.SetFileName(FilePath)

    'the file path of the directory containing the images & the image format
    'put the content of the text object above into the file path
    FilePath = "I:\Sports Logos\NHL\Atlantic Division" + Team5.text + ".png"
    'find a material and change the file path of the texture in it
    engine.GetMaterialByName("Logo5", material)
    material.GetShader(0, shader)
    shader.SetFileName(FilePath)

    'the file path of the directory containing the images & the image format
    'put the content of the text object above into the file path
    FilePath = "I:\Sports Logos\NHL\Atlantic Division" + Team6.text + ".png"
    'find a material and change the file path of the texture in it
    engine.GetMaterialByName("Logo6", material)
    material.GetShader(0, shader)
    shader.SetFileName(FilePath)





    So, I've got text objects named Team1, Team2, etc., and I have empty quad objects named Logo1, Logo2, etc.

    I've got files in the I:\Sports Logos\NHL\Atlantic Division folder, which is a shared network drive. Each file is just the Team City, which is what gets populated through the RSS feed and datalinq.

    Can you see anything wrong with what I'm doing?

    Thanks!


    #XPression


  • 9.  RE: Changing Image Based on XML feed Text

    Posted 02-23-2016 14:57
    Looks like some copy paste bugs here.. Everything is using the Team1 variable..

    self.GetObjectByName("Team1", Team1)
    self.GetObjectByName("Logo1", Logo1)
    self.GetObjectByName("Team2", Team1)
    self.GetObjectByName("Logo2", Logo2)
    self.GetObjectByName("Team3", Team1)
    self.GetObjectByName("Logo3", Logo3)
    self.GetObjectByName("Team4", Team1)
    self.GetObjectByName("Logo4", Logo4)
    self.GetObjectByName("Team5", Team1)
    self.GetObjectByName("Logo5", Logo5)
    self.GetObjectByName("Team6", Team1)
    self.GetObjectByName("Logo6", Logo6)

    #XPression


  • 10.  RE: Changing Image Based on XML feed Text

    Posted 02-23-2016 15:01
    Try this script in OnOnline.. It should do the same as yours but in a lot less lines of code. You also don't need to create any global materials called "Logo1, Logo2, etc." because it uses temporary "volatile" materials..

    dim Team as xpTextObject
    dim Logo as xpBaseObject
    dim FilePath as string

    dim i as integer

    for i = 1 to 6
    self.GetObjectByName("Team" + i.ToString, Team)
    self.GetObjectByName("Logo" + i.ToString, Logo)
    FilePath = "I:\Sports Logos\NHL\Atlantic Division" + Team.text + ".png"
    Logo.SetVolatileTextureFile(0, FilePath)
    next

    #XPression


  • 11.  RE: Changing Image Based on XML feed Text

    Posted 02-23-2016 15:25
    Thank you! I'll try that today. Even though I had Team1 in all of them, I couldn't get even 1 to work. But I'll try your script. I'm all about minimizing scripting, but the only thing I know about coding is what I've learned from people on here and the great guys at Ross :)
    #XPression


  • 12.  RE: Changing Image Based on XML feed Text

    Posted 02-29-2016 02:18
    It doesn't matter if they are coming from a datalinq source; OnOnline is run when the scene actually goes on air, which is after it has already pulled in the datalinq values.. I think the only way to help from here is for you to post a link (google drive or dropbox) to your scene so we can see what might be wrong.. It is often a small typo somewhere which stops everything from working..
    #XPression


  • 13.  RE: Changing Image Based on XML feed Text

    Posted 02-29-2016 18:21
    Is "Atlantic Division" a folder? If so, you're missing a backslash from your script (and from mine).. It should be like this:


    dim Team as xpTextObject
    dim Logo as xpBaseObject
    dim FilePath as string
    dim i as integer
    for i = 1 to 6
    self.GetObjectByName("Team" + i.ToString, Team)
    self.GetObjectByName("Logo" + i.ToString, Logo)
    FilePath = "I:\Sports Logos\NHL\Atlantic Division\" + Team.text + ".png"
    Logo.SetVolatileTextureFile(0, FilePath)
    next

    #XPression


  • 14.  RE: Changing Image Based on XML feed Text

    Posted 03-01-2016 02:40
    Eureeka! I also had to change the names of the text fields to Team1, Team2, etc., (instead of Team 1, Team 2, etc.), and the quads to Logo1, Logo2, etc. (instead of Team 1 Logo, Team 2 Logo, etc.).

    Thank you so much!!!
    #XPression