Dynamic Custom Property Path

Hello I am fairly new to ignition and the scripting language. I have a project I am working on which involves a template with 45 custom properties I need to write values from an excel file. I’m using the mousePressed event handler to loop through an array of values from the excel file. Then I would like to iterate through the custom properties. Is this possible?
Example: I have the following tag path: event.source.parent.parent.parent.parent.parent.MixPage1_Line1

I would like to:
for i in range(45):
event.source.parent.parent.parent.parent.parent.MixPage1_Line{i} = value

Sure, this is simple to do. Here an example:

First a template with some custom properties:

Then add the script on mousePressed self template, but it can be anywhere as long it can refer to template properties:

properties = event.source.getDynamicProps().values()
newValues = {'property1':2,'property2':'newString','property3':False,'property4':7.1}#new values dictionary
for p in properties:
	property = p.toString()
	print property,' oldValue: ',event.source.getPropertyValue(property) #get old value
	event.source.setPropertyValue(property,newValues[property]) #set new value, must be same datatype
	print property,' newValue: ',event.source.getPropertyValue(property) #get new value

So basically I created a new values dictionary which keys are property names and new values.

Run the script and see results

1 Like

Thanks jespinmartin1 I will give that a try and let you know how it goes.

Worked like a charm thanks for the assistance.