# Read/Write Vision Template Definition Scripturally

**URL:** <https://forum.inductiveautomation.com/t/read-write-vision-template-definition-scripturally/115351>\
**Category:** Ignition\
**Tags:** vision\
**Created:** [May 1, 2026, 4:27pm UTC](https://forum.inductiveautomation.com/t/read-write-vision-template-definition-scripturally/115351 "2026-05-01T16:27:17Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![channing](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/channing/32/85151_2.png) [@channing](https://forum.inductiveautomation.com/u/channing)\
**Post date:** [May 1, 2026, 4:27pm UTC](https://forum.inductiveautomation.com/t/read-write-vision-template-definition-scripturally/115351/1 "2026-05-01T16:27:17Z")

</div>

From my designer-scoped custom module, I'm able to get a reference to the FPMIWindow instance of my vision windows (see method below from my ResourceEditor class). From there I can do all sorts of mutations.

Is there a similar way to mutate vision template definitions? Trying to avoid parsing the saved XML and mutating that, 'cause it's a huge headache.

`private void test_debug2(){`  
` var script_manager = context.getScriptManager();`  
` PyStringMap locals = script_manager.createLocalsMap();`  
` String code = """`  
` system.vision.openWindow("%s")`  
` w = system.vision.getWindow("%s")`  
` """.formatted("test_3", "test_3");`  
` try {`  
` script_manager.runCode(code, locals, "<test_debug2>");`  
` } catch (JythonExecException e) {`  
` throw new RuntimeException(e);`  
` }`

` PyObject py_win = locals. __finditem__ ("w");`  
` if (py_win == null) {System.out.println("Fetching w from code locals returned null"); return;}`

` Object win = py_win. __tojava__ (FPMIWindow.class);`  
` System.out.println("Check it: " + win.getClass());`  
`}`

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [May 1, 2026, 6:11pm UTC](https://forum.inductiveautomation.com/t/read-write-vision-template-definition-scripturally/115351/2 "2026-05-01T18:11:55Z")

</div>

I think you want something like this, to get a VisionTemplate instance.

```java
          final VisionClientContext visionContext = root.getAdapterContext();

          VisionTemplate template =
              visionContext.getTemplateManager().getTemplateInstance(templateId.getFolderPath());

```

Where `root` is the `FPMIApp` instance.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [May 1, 2026, 6:16pm UTC](https://forum.inductiveautomation.com/t/read-write-vision-template-definition-scripturally/115351/3 "2026-05-01T18:16:12Z")

</div>

> [@paul-griffith](#):
>
> I think you want

Probably not, as changes to an isolated instance won't be captured by a designer save op, I would expect.

A mimic of the designer's "open template" operation (for editing), returning the instance, would be needed, I think.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [May 1, 2026, 6:22pm UTC](https://forum.inductiveautomation.com/t/read-write-vision-template-definition-scripturally/115351/4 "2026-05-01T18:22:01Z")

</div>

Probably `WindowWorkspace#openTemplate(com.inductiveautomation.ignition.common.resourcecollection.ResourcePath)` then.

`context.getWorkspaceManager()` can get you a WindowWorkspace (the key is `com.inductiveautomation.factorypmi.designer.workspace.WindowWorkspace#WINDOW_WORKSPACE_KEY` / `"windows"`. There's no O(1) lookup of a workspace.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [May 1, 2026, 6:28pm UTC](https://forum.inductiveautomation.com/t/read-write-vision-template-definition-scripturally/115351/5 "2026-05-01T18:28:14Z")

</div>

Someone owes you an adult beverage at ICC this year....

---

<div class="post-metadata">

**Author:** ![bschroeder](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bschroeder/32/13260_2.png) [@bschroeder](https://forum.inductiveautomation.com/u/bschroeder)\
**Post date:** [May 4, 2026, 12:21pm UTC](https://forum.inductiveautomation.com/t/read-write-vision-template-definition-scripturally/115351/6 "2026-05-04T12:21:20Z")

</div>

If we paid all those to @paul-griffith and yourself, y'all would never walk again.
