Vision - Script Custom Properties (w/default values) onto UDT Definitions

Vision Project (v8.1.42)

I have several large (nested) UDT structures ... and I need to add several custom properties to each UDT member of given types.

Is there a way to script the addition of the custom properties (with default values) to the UDT defs?

OTW ... manual additions are a slow process...

Example:

udtA
udtA1
udtA2
...
udtAx

needs the following structure

udtA
udtA1
udtA1.cp11
udtA1.cp12
...
udtA1.cp1y

udtA2
udtA2.cp21
udtA2.cp22
...
udtA2.cp2y
...

udtAx
udtAx.cpx1
udtAx.cpx2
...
udtAx.cpxy

Thanks!

This is not Vision related at all; you can use scripting to do this using simple tag writes (system.tag.write*). Don't have time for an example atm though sorry

1 Like

Do you need to write to a custom property that already exists, or do you need to add the custom property to the UDT?

For just writing to them you can create a script that will write to them all. It would be a combination of a loop possibly if you have multiple folders to get all of the tag paths, or if you have all of them in the same place you can get all the tag paths with system.tag.browse('pathToUDTs') and then just use system.tag.write like @nminchin said.

For writing to custom properties, you do it the same way as a normal tag value. so, if I had a udt called furnace_1 and it has a member called state I could have a custom property on that called codeScale and it has a value of 5 and I need it to be a value of 10 I could use system.tag.writeBlocking(['[default]furnace_1/state.codeScale'],[10])

The same would apply to your instances but you can pass them into the array params and handle it that way for multiples.

If you just want to add them to the UDTs in general updating the definition of the UDT will add the custom properties to every instance.

Thanks Nick!

...you are correct, if the custom property doesn't exist; a write* to the UDT def will create and assign the default value...