# Adding templates dynamically

**URL:** <https://forum.inductiveautomation.com/t/adding-templates-dynamically/8683>\
**Category:** Module Development\
**Created:** [July 8, 2014, 3:38pm UTC](https://forum.inductiveautomation.com/t/adding-templates-dynamically/8683 "2014-07-08T15:38:45Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![marioquark](https://avatars.discourse-cdn.com/v4/letter/m/22d042/32.png) [@marioquark](https://forum.inductiveautomation.com/u/marioquark)\
**Post date:** [July 8, 2014, 3:38pm UTC](https://forum.inductiveautomation.com/t/adding-templates-dynamically/8683/1 "2014-07-08T15:38:45Z")

</div>

Hi,  
I asked some time ago about the possibility to develop a script that generates Templates dynamically at runtime.  
[viewtopic.php?f=70&t=12212](https://www.inductiveautomation.com/forum/viewtopic.php?f=70&t=12212)  
Now I’m thinking about a vision module to get this. In particular, i would like to have a module (hosting internally a TemplateHolder) in a vision module that displays generic Templates, whose paths, dimensions, positions ecc are specified as properties.  
So this module should have the capability to instantiate objects using code like this:

`from com.inductiveautomation.factorypmi.application.components.template import TemplateHolder
root = system.gui.getParentWindow(event).rootContainer
TemplateHolder newobj = new TemplateHolder()
newobj.initTemplate(root.getAppContext())
newobj.setTemplatePath("XXX")
newobj.setName("A Template")
newobj.getLoadedTemplate().setEnableLayout(1)
root.addComponent(newobj)`  
I know doing this using python is not recommended by Inductive. I’d like to know if there’s a good practice you could suggest me and a reference to design and develop properly such module.  
Thank you very much.
