# UDT OPC Item Path from Parts of Name

**URL:** <https://forum.inductiveautomation.com/t/udt-opc-item-path-from-parts-of-name/55058>\
**Category:** Ignition\
**Created:** [January 15, 2022, 10:53pm UTC](https://forum.inductiveautomation.com/t/udt-opc-item-path-from-parts-of-name/55058 "2022-01-15T22:53:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![DSandy](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dsandy/32/29409_2.png) [@DSandy](https://forum.inductiveautomation.com/u/DSandy)\
**Post date:** [January 15, 2022, 10:53pm UTC](https://forum.inductiveautomation.com/t/udt-opc-item-path-from-parts-of-name/55058/1 "2022-01-15T22:53:01Z")

</div>

We have 15 identical devices whose data comes to us from a data concentrator, so on the OPC side there is one device definition/connection. We have a UDT for the devices. When creating the tags the structure looks like this:

```auto
Site_ID (folder)
   Device_1 (UDT Instance)
       Tag_x
       Tag_y
   Device_2
   ....
   Device_n

```

the structure in the concentrator is organized, so it is easy to calculate the address in the OPC space. But the only way I’ve found to do that is using a parameter, which adds an extra step, and room for error. Also having trouble setting the OPC device name for the same reason. What I would like to do is create the OPC Item Path from **parts** of the Instance:

`ns=1,s=[Site_ID]AnalogInput:value(right(InstanceName,1))*baseaddress+y....`

The closest I can come using the default parameter bindings is to use {PathtoParentFolder}, but that results in “Site\_ID\Device\_n”. So I need left something like:

```auto
[.]../

```

or

`left({PathtoParentFolder}, len({PathtoParentFolder})-find("/",{PathtoParentFolder})`

I can’t seem to find a syntax for the relative path that seems to work in the OPC Item Path definition, and expression functions don’t fly.

And trying to pull the device number off the right side of the instance name (in the OPC Item Path binding) is like pulling teeth. All of the examples show using a parameter to set the device number (Motor Number:1), is there any way I can read that from the InstanceName instead? Having to put the number at the end of the tagname, and then enter in a parameter of the same tag is just an extra step I’d like to avoid.

Suggestions?

---

<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:** [January 15, 2022, 11:21pm UTC](https://forum.inductiveautomation.com/t/udt-opc-item-path-from-parts-of-name/55058/2 "2022-01-15T23:21:55Z")

</div>

Use parameters. Then use a script to set/audit your parameter values.

---

<div class="post-metadata">

**Author:** ![Allison\_Manhard](https://avatars.discourse-cdn.com/v4/letter/a/bcef8e/32.png) [@Allison\_Manhard](https://forum.inductiveautomation.com/u/Allison_Manhard)\
**Post date:** [January 20, 2025, 8:42pm UTC](https://forum.inductiveautomation.com/t/udt-opc-item-path-from-parts-of-name/55058/3 "2025-01-20T20:42:07Z")

</div>

> [@DSandy](#):
>
> And trying to pull the device number off the right side of the instance name (in the OPC Item Path binding) is like pulling teeth. All of the examples show using a parameter to set the device number (Motor Number:1), is there any way I can read that from the InstanceName instead? Having to put the number at the end of the tagname, and then enter in a parameter of the same tag is just an extra step I’d like to avoid.

Hi, I know this is an old topic, but could you expand on what you mean by this? I'm currently trying do this, but I am unable to set an item path with parameters that ignition likes.

---

<div class="post-metadata">

**Author:** ![DSandy](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dsandy/32/29409_2.png) [@DSandy](https://forum.inductiveautomation.com/u/DSandy)\
**Post date:** [January 20, 2025, 9:24pm UTC](https://forum.inductiveautomation.com/t/udt-opc-item-path-from-parts-of-name/55058/4 "2025-01-20T21:24:22Z")

</div>

I would guess it is syntax issue, getting an OPC path from parameters does work, I just couldn't get it to work from something that was not a parameter we defined for the purpose. Here's an OPC path that works:

```python
ns=1;s=[{Site_ID}]AnalogInput{9+DNP_Base+Device_Index*DNP_Size}

```

In this case Site\_ID is a string parameter and DNP\_Base, Device\_Index, and DNP\_Size are integer parameters.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/5/c572088d39d9d1dff6310358ef83b21e75355a1b.png)

(A newer version of Ignition has decided it does not like the underscore in parameter names, but this one still works).

This then resolves to something like:

```python
ns=1;s=[04981_Spring_St_BESS]AnalogInput509

```

My original quest was to derive what became Device\_Index from the tagname, so that if if this was Device\_Name\_4 I could just read the "4" from the end of the tagname, but I never got that to fly.

What specific issues are you running into?

---

<div class="post-metadata">

**Author:** ![Allison\_Manhard](https://avatars.discourse-cdn.com/v4/letter/a/bcef8e/32.png) [@Allison\_Manhard](https://forum.inductiveautomation.com/u/Allison_Manhard)\
**Post date:** [January 20, 2025, 9:44pm UTC](https://forum.inductiveautomation.com/t/udt-opc-item-path-from-parts-of-name/55058/5 "2025-01-20T21:44:54Z")

</div>

I figured it out! Thanks for replying! I wasn't using a parameter and was instead using a custom property because I am new to this and perhaps a little stupid
