Using template and patch technique
- Last UpdatedApr 24, 2024
- 1 minute read
Another way to perform class-based configuration is to use templates for patching.
The trade off of this technique is that if the template definition and instancing are not in the Graphic Context logic file, the configuration is not visible in the graphic context itself.
Also, this could cause misunderstanding as patches are always applied after node definition. The value set into the graphic context would be always overridden by the patch value.
Code example
This is a code example for patch technique.
<deftemplate name="niceValve">
<patch name="%valve%" displayName="Position" displayValue="[*'{0:P1}',n:@%valve%.value@]" invertRotation="false" />
</deftemplate> <usetemplate valve="RF0800-001" />
<usetemplate valve="RF0800-002" />
<usetemplate valve="RF0800-003" />
<!--...--->