logo

Live Production Software Forums


Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
seve.anderson  
#1 Posted : Wednesday, November 2, 2022 6:37:40 AM(UTC)
seve.anderson

Rank: Newbie

Groups: Registered
Joined: 10/8/2022(UTC)
Posts: 4
United States
Location: Moline, IL

Hi Everyone!

I am attempting to create an election full screen graphic with various data fields. The fields will auto populate and advance to the next set of results after a certain time, like 5-6 seconds. Once it reaches the end of the active list, it will start out at race data index 0 and go again.

My data source is an auto appending XML document. Using a script I am able to read the xml document, extract, order, and populate the data into corresponding GT Title fields. Where I am getting hung up is making it happen in an automated way.

Is there a way to pass changing data to DynamicValue1 automatically? All I need to do is change the values in the fields at an equal interval and change the ActiveRace value for DynamicValue1

Currently, for testing purposes I am making the script work by manually changing the Value1 by using shortcuts.

Current shortcuts:
Key Q SetDynamicValue1 Value= 0
Key W SetDynamicValue1 Value= 1
Key E SetDynamicValue1 Value= 2
Key R SetDynamicValue1 Value= 3
Key T SetDynamicValue1 Value= 4
Key Y SetDynamicValue1 Value= 5
PageDown = ScriptStartDynamic

I press "Q" key, then the PageDown key , view Race 0 data. Press "W", then press the PageDown key, view Race 1 data. etc. I have a total of 73 races to do this with.

I was actually thinking about making 73 Key shortcuts and running a SendKeys script with a timer to execute them but there has to be an easier way to do it.

What I am thinking, to script inline some kind of a "counter" to incrementally pass a number through the script to update the ActiveRace?

Here is the script being run through "ScriptStartDynamic".

Code:

' Set up access to the vMix XML model

dim VmixXML as new system.xml.xmldocument
VmixXML.loadxml(API.XML)
' Open the file with the Polling Question Results

dim PollDataFolder As String = "c:\election2022"
dim XMLRaceData As New XmlDataDocument()
dim ResultsFileStream As New Filestream(PollDataFolder+"\election_10_06_22.xml", FileMode.Open, FileAccess.Read)

' Pull out the question/response details as an XML Node List

dim xmlRaceNodeList As XMLNodeList
dim RaceCount as Integer

' Load the file with the Race Results and build Node List

XMLRaceData.Load(ResultsFileStream)
xmlRaceNodeList = XMLRaceData.selectSingleNode("/File").SelectNodes("Entry")

If ( xmlRaceNodeList Is Nothing ) Then 
      Console.WriteLine("NodeList Failed - No Questions Found") 
End If
RaceCount = xmlRaceNodeList.count	' This is the number of Races in the list

' The Question/Response being displayed is in DynamicValue1  NOTE: Index runs from 0 to Count-1
dim ActiveRace as Integer = CInt(VmixXML.selectSingleNode("/vmix/dynamic/value1").InnerText)


' Store the details for the active response

dim RaceName3 as String
dim CandName1 as String
dim CandName2 as String
'dim CandPercent1 as String
'dim CandPercent2 as String
'dim PrecintPercentage as String
'dim CandVotes1 as String
'dim CandVotes2 as String
dim CandParty1 as String
dim CandParty2 as String

' Pull out the data from the XML Node and assign it

RaceName3 = xmlRaceNodeList(ActiveRace).SelectSingleNode("RaceName3").InnerText
CandName1 = xmlRaceNodeList(ActiveRace).SelectSingleNode("CandName1").InnerText
CandName2 = xmlRaceNodeList(ActiveRace).SelectSingleNode("CandName2").InnerText
CandName2 = xmlRaceNodeList(ActiveRace).SelectSingleNode("CandName2").InnerText
CandName2 = xmlRaceNodeList(ActiveRace).SelectSingleNode("CandName2").InnerText
CandParty1 = xmlRaceNodeList(ActiveRace).SelectSingleNode("CandParty1").InnerText
CandParty2 = xmlRaceNodeList(ActiveRace).SelectSingleNode("CandParty2").InnerText


' Use extracted data to populate

API.Function("SetText",Input:="results",SelectedName:="RaceName3.Text",Value:=RaceName3)
API.Function("SetText",Input:="results",SelectedName:="CandName1.Text",Value:=CandName1)
API.Function("SetText",Input:="results",SelectedName:="CandName2.Text",Value:=CandName2)
API.Function("SetText",Input:="results",SelectedName:="CandParty1.Text",Value:=CandParty1)
API.Function("SetText",Input:="results",SelectedName:="CandParty2.Text",Value:=CandParty2)



Sorry for the long post and hope my ideas here aren't too long of a shot. I am not even sure I asked my question properly.

Any insights or topics to research would be helpful. I am so far ahead of where I was 2 weeks ago, I can't even believe it!

Thank you all for reading my post!
Henny  
#2 Posted : Wednesday, November 2, 2022 9:43:18 AM(UTC)
Henny

Rank: Advanced Member

Groups: Registered
Joined: 5/14/2013(UTC)
Posts: 136
Man
Location: uk

Thanks: 2 times
Was thanked: 23 time(s) in 20 post(s)
What's wrong with just pulling in the XML as a data source that auto-advances?
seve.anderson  
#3 Posted : Wednesday, November 2, 2022 1:47:12 PM(UTC)
seve.anderson

Rank: Newbie

Groups: Registered
Joined: 10/8/2022(UTC)
Posts: 4
United States
Location: Moline, IL

Originally Posted by: Henny Go to Quoted Post
What's wrong with just pulling in the XML as a data source that auto-advances?


Well Henny, thanks for reminding me of that!! Haha. As a matter of fact, I already have a preset with a graphic with those data elements linked to a datasource that auto advances, just as a fall back if I cannot get the DynamicScript to work.

Part of the reason I decided to not use the data source - I was unable to figure out how to access the data source to get info to change a graphic color. what I wanted to do was turn 2 layers on and off with Red and Blue indicators depending on what party value is assigned to Candidate1. (I have layer 1 of the title INPUT set to can1rcan2b.png (candidate1 field Red, candidate2 field Blue) and layer 2 of the title INPUT set to can1bcan2r.png (candidate1 field Blue, candidate2 field Red))

After reading your response, going for a drive then re-opening that preset with the datasource, I realized something; I don't need to read the data source, I can read the data from the text field!!

Here is how I am making the determination and layer switch. (I need to expand this to 5 layers.(Some races are yes/no, 2 blues or 2 reds)) That is where my next issue will be, trying to figure out how to combine Cand1Party.Text and Cand2Party.Text values to = "RR" or "DD". Let me know if anyone knows the proper syntax to do that.


Code:
dim Cand1Party as String
dim can1bcan2r as String
dim can1rcan2b as String

If Input.Find("results").Text("Cand1Party.Text") = "R" then
   API.Function("LayerOff",Input:=can1bcan2r,value:=(2))
   API.Function("LayerOn",Input:=can1rcan2b,value:=(1))
 Else
   API.Function("LayerOff",Input:=can1rcan2b,value:=(1))
   API.Function("LayerOn",Input:=can1bcan2r,value:=(2))
 end if


When the above script is set as a shortcut to StartScriptDynamic, it executes flawlessly and changes the layers on and off as desired.

How would I make this script "run" without having to press or execute a shortcut? Ah yes, a Loop!

Code:
dim Cand1Party as String
dim can1bcan2r as String
dim can1rcan2b as String

Do While true

If Input.Find("results").Text("Cand1Party.Text") = "R" then
   API.Function("LayerOff",Input:=can1bcan2r,value:=(2))
   API.Function("LayerOn",Input:=can1rcan2b,value:=(1))
 Else
   API.Function("LayerOff",Input:=can1rcan2b,value:=(1))
   API.Function("LayerOn",Input:=can1bcan2r,value:=(2))
 end if

Loop


As long as I start the Auto Next and Loop buttons first, then start the Script, the races populate one after another with the proper layers switched ON and OFF.

Thanks again for reminding me to go back and check that simple use case again. I just started down a road and never looked back. What a find!!

If anyone knows how to combine those two fields to make the double vlues, that would be awesome. I have a feeling I will get it though.

Thank you all for being part of our story!!





seve.anderson  
#4 Posted : Thursday, November 3, 2022 3:20:41 AM(UTC)
seve.anderson

Rank: Newbie

Groups: Registered
Joined: 10/8/2022(UTC)
Posts: 4
United States
Location: Moline, IL

Thank you everyone for reading my post! I really appreciate the simple input, exactly what I needed.

For that other issue I was trying to figure out, I came up with this to get the 2 Values combined and show the correct layer. When I loop this script, the next data source record applies the correct layer instantly.

Thanks again!

Code:
dim Cand1Party as String
dim Cand2Party as String
dim can1bcan2r as String
dim can1rcan2b as String
dim can1rcan2r as String
dim can1bcan2b as String

If Input.Find("results").Text("Cand1Party.Text") & Input.Find("results").Text("Cand2Party.Text") = "RR" then
   API.Function("LayerOff",Input:=can1bcan2r,value:=(2))
   API.Function("LayerOff",Input:=can1rcan2b,value:=(1))
   API.Function("LayerOn",Input:=can1rcan2r,value:=(3))
   API.Function("LayerOff",Input:=can1bcan2b,value:=(4))
   
 Elseif Input.Find("results").Text("Cand1Party.Text") & Input.Find("results").Text("Cand2Party.Text") = "DD" then
   API.Function("LayerOff",Input:=can1rcan2b,value:=(1))
   API.Function("LayerOff",Input:=can1bcan2r,value:=(2))
   API.Function("LayerOff",Input:=can1rcan2r,value:=(3))
   API.Function("LayerOn",Input:=can1bcan2b,value:=(4))
   
 Elseif Input.Find("results").Text("Cand1Party.Text") = "R" then
   API.Function("LayerOn",Input:=can1rcan2b,value:=(1))
   API.Function("LayerOff",Input:=can1bcan2r,value:=(2))
   API.Function("LayerOff",Input:=can1rcan2r,value:=(3))
   API.Function("Layeroff",Input:=can1bcan2b,value:=(4))
   
 Elseif Input.Find("results").Text("Cand1Party.Text") = "D" then
   API.Function("LayerOff",Input:=can1rcan2b,value:=(1))
   API.Function("LayerOn",Input:=can1bcan2r,value:=(2))
   API.Function("LayerOff",Input:=can1rcan2r,value:=(3))
   API.Function("Layeroff",Input:=can1bcan2b,value:=(4))
   
   Else 
   API.Function("LayerOff",Input:=can1rcan2b,value:=(1))
   API.Function("LayerOff",Input:=can1bcan2r,value:=(2))
   API.Function("LayerOff",Input:=can1rcan2r,value:=(3))
   API.Function("Layeroff",Input:=can1bcan2b,value:=(4))
 end if
seve.anderson  
#5 Posted : Thursday, November 3, 2022 4:31:24 AM(UTC)
seve.anderson

Rank: Newbie

Groups: Registered
Joined: 10/8/2022(UTC)
Posts: 4
United States
Location: Moline, IL

Hello, I have an issue with this script above.

The script loop works ONLY IN PREVIEW. When I cut the title input to program, the script does nothing but leave the previous current layer on.

What am I missing here?

Thanks for your help.
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.