Graphics

 View Only
  • 1.  Scripting Help

    Posted 10-02-2024 11:23

    We have a script to load/overwrite the images of about 10 materials in one take id, to update the materials across our entire project. Here is the script we have entered, but the files are not updating as they should. The scripting is place on a Text Object that we would manually enter, or datalinq, say "DAL", for the Dallas Mavericks, and files in our NBA folder labeled to match. 90% of the time we use a datalinq to load the team Tricode, but for special games, we need to manually enter a 4 digit code, IE "OKCN" (vs, "OKC") for a secondary set of logos and colors. 

    File name protocol: 

    DAL_L0.png

    DAL_L1.png

    DAL_L2.png

    DAL_C1.png

    DAL_C2.png

    DAL_C3.png

    DAL_C4.png

    Script on AWAY text object:

    dim L0, L1, L2, C1, C2, C3, C4 as xpBaseObject
    dim L0mat, L1mat, L2mat, C1mat, C2mat, C3mat, C4mat as xpMaterial
    dim L0shade, L1shade, L2shade, C1shade, C2shade, C3shade, C4shade as xpBaseShader


    scene.GetObjectByName("AWAY_L0", L0)
    L0.GetMaterial(0,L0mat)
    L0.GetShader(0, L0shade)

    scene.GetObjectByName("AWAY_L1", L1)
    L1.GetMaterial(0,L1mat)
    L1.GetShader(0, L1shade)

    scene.GetObjectByName("AWAY_L2", L2)
    L2.GetMaterial(0, L2mat)
    L2mat.GetShader(0, L2shade)

    scene.GetObjectByName("AWAY_C1", C1)
    C1.GetMaterial(0, C1mat)
    C1mat.GetShader(0, C1shade)

    scene.GetObjectByName("AWAY_C2", C2)
    C2.GetMaterial(0, C2mat)
    C2mat.GetShader(0, C2shade)

    scene.GetObjectByName("AWAY_C3", C3)
    C3.GetMaterial(0, C3mat)
    C3mat.GetShader(0, C3shade)

    scene.GetObjectByName("AWAY_C4", C4)
    C4.GetMaterial(0, C4mat)
    C4mat.GetShader(0, C4shade)

    L0shade.SetFileName("D:\NBA\" & text & "_L0.PNG")
    L1shade.SetFileName("D:\NBA\" & text & "_L1.PNG")
    L2shade.SetFileName("D:\NBA\" & text & "_L2.PNG")
    C1shade.SetFileName("D:\NBA\" & text & "_C1.PNG")
    C2shade.SetFileName("D:\NBA\" & text & "_C2.PNG")
    C3shade.SetFileName("D:\NBA\" & text & "_C3.PNG")
    C4shade.SetFileName("D:\NBA\" & text & "_C4.PNG")

    Script on HOME text object:

    dim L0, L1, L2, C1, C2, C3, C4 as xpBaseObject
    dim L0mat, L1mat, L2mat, C1mat, C2mat, C3mat, C4mat as xpMaterial
    dim L0shade, L1shade, L2shade, C1shade, C2shade, C3shade, C4shade as xpBaseShader


    scene.GetObjectByName("HOME_L0", L0)
    L0.GetMaterial(0,L0mat)
    L0.GetShader(0, L0shade)

    scene.GetObjectByName("HOME_L1", L1)
    L1.GetMaterial(0,L1mat)
    L1.GetShader(0, L1shade)

    scene.GetObjectByName("HOME_L2", L2)
    L2.GetMaterial(0, L2mat)
    L2mat.GetShader(0, L2shade)

    scene.GetObjectByName("HOME_C1", C1)
    C1.GetMaterial(0, C1mat)
    C1mat.GetShader(0, C1shade)

    scene.GetObjectByName("HOME_C2", C2)
    C2.GetMaterial(0, C2mat)
    C2mat.GetShader(0, C2shade)

    scene.GetObjectByName("HOME_C3", C3)
    C3.GetMaterial(0, C3mat)
    C3mat.GetShader(0, C3shade)

    scene.GetObjectByName("HOME_C4", C4)
    C4.GetMaterial(0, C4mat)
    C4mat.GetShader(0, C4shade)

    L0shade.SetFileName("D:\NBA\" & text & "_L0.PNG")
    L1shade.SetFileName("D:\NBA\" & text & "_L1.PNG")
    L2shade.SetFileName("D:\NBA\" & text & "_L2.PNG")
    C1shade.SetFileName("D:\NBA\" & text & "_C1.PNG")
    C2shade.SetFileName("D:\NBA\" & text & "_C2.PNG")
    C3shade.SetFileName("D:\NBA\" & text & "_C3.PNG")
    C4shade.SetFileName("D:\NBA\" & text & "_C4.PNG")

    Template Preview:

    Files on backend: 



    ------------------------------
    Sara Groover
    Graphics Producer
    Oklahoma City United States
    ------------------------------


  • 2.  RE: Scripting Help

    Posted 10-02-2024 13:53

    L0 and L1 need to be L0mat and L1mat on their last lines.

    Otherwise, I don't see anything wrong, but this is a hazy area of scope between xpEngine, xpScene, and xpProject, and where the final execution is. Sequencer syntax operates differently from MOS/iNews/production box sometimes.

    Here are two possible middleman steps that might work:

    L2.GetMaterial(0, L2mat)
    Engine.GetMaterialByName(L2mat.Name,L2mat)
    L2mat.GetShader(0, L2shade)
    
    'or try this
    
    L2.GetMaterial(0, L2mat)
    Scene.Project.GetMaterialByName(L2mat.Name,L2mat)
    L2mat.GetShader(0, L2shade)

    What you are doing will change the shader.

    Here is an alternate method. Add the following to your global scripts:

    Sub setFile(Scene as xpScene, objectName as String, theFile as String)
      Dim obj as xpBaseObject
      Scene.GetObjectByName(objectName,obj)
      obj.SetVolatileTextureFile(0,theFile)
    End Sub

    Now on your text object you can use the following syntax:

    setFile(Scene,"HOME_L0","D:\NBA\"&text&"_L0.PNG")

    This method will only change that object's texture, not the shader's texture. Very different behavior.

    Hope this helps and I didn't miss any syntax errors.



    ------------------------------
    Azathoth
    Son of Cthulhu
    ------------------------------



  • 3.  RE: Scripting Help

    Posted 10-02-2024 17:33

    The most common issue with this kind of thing is file path issues, have you checked an absolute path and worked backwards from that? 



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