Having trouble adding pens to EastChart in script

The following visionWindowOpened script clears the pens in the Easy Chart but fails to add pens:
Can’t figure it out? Any help is appreciated…

I have downloaded Click TO Graph.zip. Renamed to gwbk. When tried to restore, got the following error:
Error writing to restore file: java.io.IOException: Can not retrieve file ‘backupinfo.xml’ from Gateway backup

pyDataSet = system.dataset.toPyDataSet(easyChart.tagPens)
index = 0
for row in pyDataSet:
try:
easyChart.tagPens = system.dataset.deleteRow(easyChart.tagPens, index)
except:
print(“Exception while removing from East Chart in History window %”, sys.exc_info()[1])

tagNames = [“Machine Code”]

tagPaths = ["[.]" + “Factory/” + selectedStation + “/MachineCode”]

num = 0
for tag in tagPaths:
try:
row = list(pyDataSet[0])
row[“NAME”] = tagNames[num]
row[“TAG_PATH”] = tagPaths[num]
easyChart.tagPens = system.dataset.addRow(easyChart.tagPens, row)
num = num + 1
except:
print(“Exception while adding new pen to East Chart in History window %”, sys.exc_info()[1])

I’m assuming the mention of Click To Graph is a separate issue, is that correct? Note that the Click To Graph is not a gateway backup: unzipping the file contains instructions on how to use the files within.

As for the script, it looks like the visionWindowOpened event is only triggering when the window is opened in the client, and not the designer. Are you testing this in the designer or client?

Thank for info on Click to Graph. I am testing by launching a client and not in the designer.

When it fails, are you getting an error? You should see something in the console, if not an error box appearing when it fails. If it is actually clearing the pens, then there should be an error reporting which line it failed on.

Side note: the example you posted is a bit difficult to read since it lost the formatting/indentation. I could guess at it, but you could try posting your code again with the indentation: paste your code into the reply box, select the code, and click the Preformatted Text button at the top of the reply box (or wrap your code in triple backtick ` characters

Hi Scott,
here is the formatted code. It won’t show any errors on console or won’t logs any messages “myLogger” on Gateway …
Any help is appreciated.

# This script was generated automatically by the property set
# script builder. You may modify this script, but if you do,
# you will not be able to use the property set builder to update
# this script without overwriting your changes.

global system,app
import system
import sys
import app

logger = system.util.getLogger("myLogger")
logger.info("Hello, world.")

selectedStation = system.gui.getParentWindow(event).getComponentForPath('Root Container').SelectedStationName

easyChart = system.gui.getParentWindow(event).getComponentForPath('Root Container').getComponent('Easy Chart')

pyDataSet = system.dataset.toPyDataSet(easyChart.tagPens)
index = 0
for row in pyDataSet:
	try:
		easyChart.tagPens = system.dataset.deleteRow(easyChart.tagPens, index)
	except:
		logger.info("Exception while removing from East Chart in History window")

tagNames = ["Machine Code"]

tagPaths = ["[.]" + "Factory/" + selectedStation + "/MachineCode"]

num = 0
for tag in tagPaths:
	try:
		row = list(pyDataSet[0])
		row["NAME"] = tagNames[num]
		row["TAG_PATH"] = tagPaths[num]
		easyChart.tagPens = system.dataset.addRow(easyChart.tagPens, row)
		num = num + 1
	except:
		logger.info("Exception while adding new pen to East Chart in History window")