Accessing Components Inside a Template Instance
When working with a Template Instance, the components inside that instance or normally hidden, and otherwise inaccessible. However, you can access these components via scripting. It helps to think of Template Instances as multi-layer containers. In most cases, users interact with only the Outer Layer, which contains the Template parameters, and the other default Template Instance properties. A Python script can access the Inner Layer, which then provides access to the components within.
A script can traverse to the Inner Layer from the Outer Layer with a
From the Inner Layer, a script can then call
getComponent again to access any components within. Assuming a Template with a Label component named "Label", we could access the Text property with the following:
Let’s import a template from the Cloud.
- From the Project Browser expand Project.
- Right-click on Templates and select Cloud Templates Browser from the popup menu.
The Cloud Templates Browser is displayed.
The list of categories of Cloud templates for download are located on the left of the browser. This list is divided into Private and Public templates. The Public templates are displayed by default, but to see your Private templates, you must sign in with your Inductive Automation account.
Select Alarms from the Public list.
All publicly available templates for the Alarms category are displayed along with a description for the selected template.
Select the Alarm Indicator template and click Import Template.
A new popup appears allowing you to confirm import on the template.
Click Import to confirm importing the template.
The template is now imported and available for use within the Templates section of your Project Browser. You can drag your new template on a window or modify it however you like!