Accessing Template Internal Properties from Script Module?

Is one able to access internal properties of a template instance via scripting? I searched here and didn’t quite find the answer I was hoping to… Basically I have a situation where my script module routine iterates through open windows and then iterates through each component. It does a try/except to get the .templatePath, and if it does, it looks to see if it is an instance of a specific type of template. At that point, I have a reference to the component object. I can do comp.getPropertyValue("[A TEMPLATE PARAMETER]") and it works fine. But it is not working when I give it an internal property. Am I supposed to be able to get at that? I hope!

In the end, I need to be able to get at internal custom properties as I create a GUID for each instance of this particular template, and I need to compare a known value with each of these GUIDs as I iterate through as described above.

You’ll have to do the following, assuming that you already have a reference to your template called “comp”, and that template has an internal property called “test”:

print comp.getComponent(0).getPropertyValue("test")

Hope this helps


Yes, that indeed did it. Can you explain what component layering is going on there that it didn’t just work ‘the usual way’? I take it there is some additional layer (hence that component index of 0) since it is a template? Thanks.

What we do with our templates is create a mirror UDT to match the template. If the template has, say, a label, a check box and a numeric text field, then the UDT has a string tag, a Boolean tag, and a float tag to match. These tags can be expression tags that reference some other standard tag or some other tag in another UDT instance, and can be bi-directional.

When we input to the numeric text field in an instance of the template, and it is set to bi-directional, the value in the float tag of the mirror UDT instance will change, as will the value of the tag that is referenced by the float tag in the mirror UDT, assuming that reference is also bi-directional. And likewise if something else sets the Boolean tag referenced by the Boolean tag in the mirror UDT instance, the checkbox in the template instance will change accordingly.

It may sound like a bit of overkill, but if you have everything referenced properly, and a drop target set up for the master template, all you have to do is drag your target to the window, drop it, and you’re done. And if you need to know anything about that template instance, it’s in the mirror UDT and can be easily referenced from expressions or scripting.

This may not be your cup of tea, but it works well for us.

1 Like