Editing Custom Properties of Templates Through Script

Hello!

Hoping this will be a simple but having a hard time finding what I need online.

I'm trying to create a pushbutton within a template that will increment/decrement the custom property integer that I created in the template.

Here is what I tried, which worked for OPC tags and such. How can I do this same thing with custom properties in a template?

path = "event.source.parent.Clear_Numeric_Input"
value = system.tag.readBlocking(path)[0].value

if value < 2:
print("Only Recipes 1 - 99 available.")
else:
system.tag.writeBlocking(path, value - 1)

Thanks!

You wouldn't use a tag write for a custom property.
Just increment the property itself.
I am assuming Clear_Numeric_Input is the custom property name on the template?

event.source.parent.Clear_Numeric_Input=event.source.parent.Clear_Numeric_Input+1

2 Likes

Doy, lol I knew it would be something extremely simple. Thank you very much!

You should be able to shorten this to:

event.source.parent.Clear_Numeric_Input+=1
1 Like