# Creating parameterized UDT from existing tag structure

**URL:** <https://forum.inductiveautomation.com/t/creating-parameterized-udt-from-existing-tag-structure/41661>\
**Category:** Ignition\
**Tags:** ignition81\
**Created:** [December 18, 2020, 8:30pm UTC](https://forum.inductiveautomation.com/t/creating-parameterized-udt-from-existing-tag-structure/41661 "2020-12-18T20:30:20Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bronzebeard62](https://avatars.discourse-cdn.com/v4/letter/b/838e76/32.png) [@Bronzebeard62](https://forum.inductiveautomation.com/u/Bronzebeard62)\
**Post date:** [December 18, 2020, 8:30pm UTC](https://forum.inductiveautomation.com/t/creating-parameterized-udt-from-existing-tag-structure/41661/1 "2020-12-18T20:30:20Z")

</div>

Hi All,

I have an existing tag structure of about ~750 tags I want to create a UDT from, but I want the tag paths to be dynamic based on two parameters. I can easily do this through the GUI, but it will take me several hours to do it by hand.

Here’s what the tag looks like before changed:

```auto
      "valueSource": "opc",
      "opcItemPath": "ns\u003d1;s\u003d[Device1]Program:PRG1.ProductionDisplay.ActiveShiftNum",
      "dataType": "Int1",
      "historyProvider": "History",
      "name": "ActiveShiftNum",
      "historyEnabled": false,
      "tagType": "AtomicTag",
      "opcServer": "Ignition OPC UA Server"

```

I’m trying to parameterize the “Device1” and “PRG1” fields of the opcItemPath, which is easy enough, however adding a parameter binding also adds extra json code so it is not as simple as finding and replacing all Device 1 with my parameter binding, here’s what it looks like after:

```auto
      "opcItemPath": {
        "bindType": "parameter",
        "binding": "ns\u003d1;s\u003d[{device_name}]Program:{op_program_name}.ProductionDisplay.ActiveShiftNum"
      },
      "valueSource": "opc",
      "dataType": "Int1",
      "historyProvider": "History",
      "name": "ActiveShiftNum",
      "historyEnabled": false,
      "tagType": "AtomicTag",
      "opcServer": "Ignition OPC UA Server"

```

Does anyone know of a method of quickly editing all 750 tags to match this new structure? I’m using Ignition 8.1.0.

Note: The opcItemPath will be much different for each tag as some are in folders and some are in the root. I tried using regex in a text editor with wildcards but it was too complicated with all of the json indenting for each folder/directory.

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [December 20, 2020, 3:26am UTC](https://forum.inductiveautomation.com/t/creating-parameterized-udt-from-existing-tag-structure/41661/2 "2020-12-20T03:26:48Z")

</div>

Can’t you just find replace “device1” with your param, and do the same for your other params? From what you said last, you might have to do a few different find/replaces. Otherwise, what are some other examplea you have?

---

<div class="post-metadata">

**Author:** ![michael2](https://avatars.discourse-cdn.com/v4/letter/m/3e96dc/32.png) [@michael2](https://forum.inductiveautomation.com/u/michael2)\
**Post date:** [December 21, 2020, 5:07am UTC](https://forum.inductiveautomation.com/t/creating-parameterized-udt-from-existing-tag-structure/41661/3 "2020-12-21T05:07:13Z")

</div>

Ignition won’t automatically update the binding type to be parameter, even though the opc item path has a parameter in it. OP would need some way to add the parameter bind type text for each tag. You could find and replace

```auto
"opcItemPath":

```

with

```auto
"opcItemPath": {
        "bindType": "parameter",
        "binding":

```

and then find/replace

```auto
,"dataType":

```

with

```auto
},"dataType":

```

Not sure if this would work though.

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [December 21, 2020, 6:18am UTC](https://forum.inductiveautomation.com/t/creating-parameterized-udt-from-existing-tag-structure/41661/4 "2020-12-21T06:18:57Z")

</div>

Good point, i’ve run into this before and used regex to fix them up which I forgot about.

FWIW, this is what I use:  
For my tag addresses that are structured like this:  
`ns=1;s=[{PLCName}]{DeviceName}.rest_of_tag.address`  
In Notepad++, I use this to fix them up:  
Find:  
`("opcItemPath": )("ns\\u003d1;s\\u003d\[{PLCName}]{DeviceName}.)([\w.]+")`  
Replace:  
`$1{"bindType": "parameter","binding": $2$3}`

---

<div class="post-metadata">

**Author:** ![Bronzebeard62](https://avatars.discourse-cdn.com/v4/letter/b/838e76/32.png) [@Bronzebeard62](https://forum.inductiveautomation.com/u/Bronzebeard62)\
**Post date:** [December 21, 2020, 3:34pm UTC](https://forum.inductiveautomation.com/t/creating-parameterized-udt-from-existing-tag-structure/41661/5 "2020-12-21T15:34:52Z")

</div>

Thank you, Thank you, Thank you. I had to modify the regex a bit to fit my tag structure, some of the tags ended in an array specifier like tag[7] so I just made group 3 of the regex a `(.*")`. This saved me hours of work, I appreciate it.
