# Project Resources

**URL:** <https://forum.inductiveautomation.com/t/project-resources/29310>\
**Category:** Module Development\
**Created:** [October 23, 2019, 10:43am UTC](https://forum.inductiveautomation.com/t/project-resources/29310 "2019-10-23T10:43:44Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andrew\_P](https://avatars.discourse-cdn.com/v4/letter/a/ce73a5/32.png) [@Andrew\_P](https://forum.inductiveautomation.com/u/Andrew_P)\
**Post date:** [October 23, 2019, 10:43am UTC](https://forum.inductiveautomation.com/t/project-resources/29310/1 "2019-10-23T10:43:44Z")

</div>

Hi,  
I’m trying to develop a simple module with ignition 8, but this is my first attempt as I never did any module dev on 7. There is a section in the sdk documentation on project resources, however this seems to have very little if any relevance to ignition 8 (eg concrete classes that are now abstract, there is no lock manager anymore, the ProjectResource builder doesn’t expose the setters to replace all constructor parameters in the sdk documentation’s way of instantiating resource objects etc etc). Obviously there have been significant changes around this in 8. As a result I can’t even get started with a simple resource. My plan is to create a resource which will be a special script-like object that I can access in the project browser. I have been able to guess my way to getting a folder into the browser (this has also changed). But I can’t get any further. The question is are there any resources or examples for ignition 8 that I can use to understand the intended architecture of project resources, so that I can use them the way I have described?

---

<div class="post-metadata">

**Author:** ![KathyApplebaum](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kathyapplebaum/32/7261_2.png) [@KathyApplebaum](https://forum.inductiveautomation.com/u/KathyApplebaum)\
**Post date:** [October 23, 2019, 2:08pm UTC](https://forum.inductiveautomation.com/t/project-resources/29310/2 "2019-10-23T14:08:34Z")

</div>

Did you check the examples at [https://github.com/inductiveautomation/ignition-sdk-examples](https://github.com/inductiveautomation/ignition-sdk-examples) ?

---

<div class="post-metadata">

**Author:** ![connor.elison](https://avatars.discourse-cdn.com/v4/letter/c/e495f1/32.png) [@connor.elison](https://forum.inductiveautomation.com/u/connor.elison)\
**Post date:** [October 23, 2019, 3:48pm UTC](https://forum.inductiveautomation.com/t/project-resources/29310/3 "2019-10-23T15:48:45Z")

</div>

You will need to use the ProjectResourceBuilder to build the resources  
[http://files.inductiveautomation.com/sdk/javadoc/ignition80/8.0.1/com/inductiveautomation/ignition/common/project/resource/ProjectResourceBuilder.html](http://files.inductiveautomation.com/sdk/javadoc/ignition80/8.0.1/com/inductiveautomation/ignition/common/project/resource/ProjectResourceBuilder.html)

From the designer you can use the createOrModify method on the designableProject to add resources to the project (note this needs the project to be saved for the changes to persist)  
[http://files.inductiveautomation.com/sdk/javadoc/ignition80/8.0.1/com/inductiveautomation/ignition/designer/project/DesignableProject.html](http://files.inductiveautomation.com/sdk/javadoc/ignition80/8.0.1/com/inductiveautomation/ignition/designer/project/DesignableProject.html)

From the gateway you can use the ProjectManager to push change operations to project resources  
[http://files.inductiveautomation.com/sdk/javadoc/ignition80/8.0.1/com/inductiveautomation/ignition/gateway/project/ProjectManagerBase.html](http://files.inductiveautomation.com/sdk/javadoc/ignition80/8.0.1/com/inductiveautomation/ignition/gateway/project/ProjectManagerBase.html)

To create the change operations you use the static methods from ChangeOperation  
[http://files.inductiveautomation.com/sdk/javadoc/ignition80/8.0.1/com/inductiveautomation/ignition/common/project/ChangeOperation.html](http://files.inductiveautomation.com/sdk/javadoc/ignition80/8.0.1/com/inductiveautomation/ignition/common/project/ChangeOperation.html)

An example of creating a resource in the designer

```
		DesignableProject project = context.getProject();
		ProjectResourceId resourceId = new ProjectResourceId(project.getName(), new ResourcePath(new ResourceType(<MODULE_ID>, <RESOURCE_TYPE>), <RESOURCE_PATH));

		XMLSerializer serializer = context.createSerializer();
		serializer.addObject(<YOUR_OBJECT>);

		Map<String, byte[]> data = new HashMap<>();
		data.put(ProjectResource.DEFAULT_DATA_KEY, serializer.serializeBinary(true));
		ProjectResource resource = ProjectResource
			.newBuilder()
			.setResourceId(resourceId)
			.setData(data)
			.build();
		project.createOrModify(resource);

```

or from the gateway create the resource the same way but

```
gatewayContext.getProjectManager().push(List.of(ChangeOperation.newCreateOp(projectResource)));

```

Good luck!

---

<div class="post-metadata">

**Author:** ![mazeyrat](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mazeyrat/32/10955_2.png) [@mazeyrat](https://forum.inductiveautomation.com/u/mazeyrat)\
**Post date:** [October 23, 2019, 6:21pm UTC](https://forum.inductiveautomation.com/t/project-resources/29310/4 "2019-10-23T18:21:58Z")

</div>

Do you know if we can search if a template exist from its path with the ressource manager in V8 ?

---

<div class="post-metadata">

**Author:** ![connor.elison](https://avatars.discourse-cdn.com/v4/letter/c/e495f1/32.png) [@connor.elison](https://forum.inductiveautomation.com/u/connor.elison)\
**Post date:** [October 23, 2019, 7:00pm UTC](https://forum.inductiveautomation.com/t/project-resources/29310/5 "2019-10-23T19:00:57Z")

</div>

Yeah, I would probably use either the getResource or browse methods on the project depending on if you are looking for one or many templates.

[http://files.inductiveautomation.com/sdk/javadoc/ignition80/8.0.1/com/inductiveautomation/ignition/common/project/Project.html](http://files.inductiveautomation.com/sdk/javadoc/ignition80/8.0.1/com/inductiveautomation/ignition/common/project/Project.html)

example for designer

```
boolean templatePresent = context.getProject().getResource(new ResourcePath(new ResourceType("com.inductiveautomation.vision", "templates"), "Test Template")).isPresent();

```

or with browse

```
List<ProjectResource> templates = context.getProject().browse(new ResourcePath(new ResourceType("com.inductiveautomation.vision", "templates"), "")).orElseGet(Collections::emptyList);
```

---

<div class="post-metadata">

**Author:** ![mazeyrat](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mazeyrat/32/10955_2.png) [@mazeyrat](https://forum.inductiveautomation.com/u/mazeyrat)\
**Post date:** [October 23, 2019, 7:19pm UTC](https://forum.inductiveautomation.com/t/project-resources/29310/6 "2019-10-23T19:19:18Z")

</div>

Thanks, do you know if it is possible in client scope ?

---

<div class="post-metadata">

**Author:** ![connor.elison](https://avatars.discourse-cdn.com/v4/letter/c/e495f1/32.png) [@connor.elison](https://forum.inductiveautomation.com/u/connor.elison)\
**Post date:** [October 23, 2019, 7:41pm UTC](https://forum.inductiveautomation.com/t/project-resources/29310/7 "2019-10-23T19:41:52Z")

</div>

The ClientContext also has a getProject so it should work exactly the same way, though I haven’t tested it.

[http://files.inductiveautomation.com/sdk/javadoc/ignition80/8.0.1/com/inductiveautomation/ignition/client/model/ClientContext.html](http://files.inductiveautomation.com/sdk/javadoc/ignition80/8.0.1/com/inductiveautomation/ignition/client/model/ClientContext.html)

---

<div class="post-metadata">

**Author:** ![mazeyrat](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mazeyrat/32/10955_2.png) [@mazeyrat](https://forum.inductiveautomation.com/u/mazeyrat)\
**Post date:** [October 23, 2019, 7:43pm UTC](https://forum.inductiveautomation.com/t/project-resources/29310/8 "2019-10-23T19:43:11Z")

</div>

Thanks, I will try asap !

---

<div class="post-metadata">

**Author:** ![Andrew\_P](https://avatars.discourse-cdn.com/v4/letter/a/ce73a5/32.png) [@Andrew\_P](https://forum.inductiveautomation.com/u/Andrew_P)\
**Post date:** [October 24, 2019, 12:24am UTC](https://forum.inductiveautomation.com/t/project-resources/29310/9 "2019-10-24T00:24:03Z")

</div>

Hi @KathyApplebaum,

I did scan through these projects but couldn’t find an example of working with project resources (unless i was not looking in the correct places for where resources are likely to be used). Do you know of a specific example, maybe i am not recognising it?

---

<div class="post-metadata">

**Author:** ![Andrew\_P](https://avatars.discourse-cdn.com/v4/letter/a/ce73a5/32.png) [@Andrew\_P](https://forum.inductiveautomation.com/u/Andrew_P)\
**Post date:** [October 24, 2019, 12:25am UTC](https://forum.inductiveautomation.com/t/project-resources/29310/10 "2019-10-24T00:25:23Z")

</div>

Thanks, @connor.elison, for the detailed response, I will try this and see how I go.
