# How to get project object using script

**URL:** <https://forum.inductiveautomation.com/t/how-to-get-project-object-using-script/7472>\
**Category:** Ignition\
**Created:** [October 26, 2013, 12:19pm UTC](https://forum.inductiveautomation.com/t/how-to-get-project-object-using-script/7472 "2013-10-26T12:19:23Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![nmudge](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nmudge/32/3394_2.png) [@nmudge](https://forum.inductiveautomation.com/u/nmudge)\
**Post date:** [December 27, 2013, 4:25pm UTC](https://forum.inductiveautomation.com/t/how-to-get-project-object-using-script/7472/3 "2013-12-27T16:25:32Z")

</div>

I dug into the Ignition and Java objects and found a way to get a list of all the template paths that exist in a project.

The following function can be used in an event handler to get a list of all the templates in the current project. It works in the client and designer:

```auto
def getProjectTemplates(event):
	import system
	comp = event.source
	if system.util.getSystemFlags() & system.util.DESIGNER_FLAG:
		from com.inductiveautomation.ignition.designer import IgnitionDesigner
		while not isinstance(comp,IgnitionDesigner):		
			comp = comp.parent
		context = comp.getContext()
	else:
		from com.inductiveautomation.factorypmi.application.runtime import ClientPanel
		while not isinstance(comp,ClientPanel):
			comp = comp.parent
		context = comp.getClientContext()
	project = context.getProject()
	templates = project.getResourcesOfType("fpmi","component-template")	
	templatePaths = [project.getFolderPath(template.getResourceId()) for template in templates]
	return templatePaths

l = []
templatePaths = getProjectTemplates(event)
for path in templatePaths:
	l.append([path])  

data = system.dataset.toDataSet(["Value"], l)

event.source.getComponent('Dropdown').data = data
```

After the function definition the code shows how to make a dataset out of the list of template paths and assigns the dataset to a dropdown.

By binding a template’s templatePath property to the dropdown’s selectedStringValue it is possible to switch a template in a window to any template that exists in the project by selecting different template paths in the dropdown.

Nick

---

_[View the full topic](https://forum.inductiveautomation.com/t/how-to-get-project-object-using-script/7472)._
