# Find UDT instance name from full tagPath

**URL:** <https://forum.inductiveautomation.com/t/find-udt-instance-name-from-full-tagpath/40845>\
**Category:** Ignition\
**Created:** [November 20, 2020, 4:20pm UTC](https://forum.inductiveautomation.com/t/find-udt-instance-name-from-full-tagpath/40845 "2020-11-20T16:20:55Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![nader.chinichian](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nader.chinichian/32/9261_2.png) [@nader.chinichian](https://forum.inductiveautomation.com/u/nader.chinichian)\
**Post date:** [November 20, 2020, 4:20pm UTC](https://forum.inductiveautomation.com/t/find-udt-instance-name-from-full-tagpath/40845/1 "2020-11-20T16:20:55Z")

</div>

Hi  
I want to find the UDT instance name from the full tag path(include Atomic member)  
For example if I have PUMP UDT Class with following member:

- run
- Motor1/FLT
- Motor2/FLT  
and instance of Pump01 from it and put in Area1 folder. Now if I have Area1/Pump01/Motor1/FLT how can I find the UDT instance name from it which is Area1/Pump01.  
Note: I don’t any clue how UDT structure when I receive the full tag Path: ‘Area1/Pump01/Motor1/FLT’, so like this example I may have some nested level of folder inside of my UDT.

---

<div class="post-metadata">

**Author:** ![MMaynard](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mmaynard/32/3366_2.png) [@MMaynard](https://forum.inductiveautomation.com/u/MMaynard)\
**Post date:** [November 20, 2020, 8:35pm UTC](https://forum.inductiveautomation.com/t/find-udt-instance-name-from-full-tagpath/40845/2 "2020-11-20T20:35:56Z")

</div>

Been covered in

> [@Retrieving the UDT tag path from instance tag path](http://forum.inductiveautomation.com/t/retrieving-the-udt-tag-path-from-instance-tag-path/35810/2):
>
> I’m assuming you are in Ignition v7.9.x, but you might be able to do something like this: tagPath = "[default]Path/To/Tag/Line 2/Filler.typeId" typeId = system.tag.read(tagPath).value print typeId I don’t have 7.9 on-hand to test that out, but I am curious as to the solution. I found that in Ignition 8.0, this seemed to work: tags = system.tag.getConfiguration(tagPath) for tag in tags: tagType = tag['tagType'] if str(tagType) == 'UdtInstance': typeId = str(tag['typeId']) print typeI…

---

<div class="post-metadata">

**Author:** ![nader.chinichian](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nader.chinichian/32/9261_2.png) [@nader.chinichian](https://forum.inductiveautomation.com/u/nader.chinichian)\
**Post date:** [November 21, 2020, 4:51am UTC](https://forum.inductiveautomation.com/t/find-udt-instance-name-from-full-tagpath/40845/3 "2020-11-21T04:51:33Z")

</div>

Hi  
I want to get the instance name not typeId.  
For example I have UDT called PUMP, and I create an instance called P01.  
So if I have P01/Motor1/FLT how can I get the P01.  
I can’t use split("/") to extract first part because the instance may be place in folder structure.

---

<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:** [November 21, 2020, 8:41am UTC](https://forum.inductiveautomation.com/t/find-udt-instance-name-from-full-tagpath/40845/4 "2020-11-21T08:41:19Z")

</div>

You can't use your solution here?

> [@Grab the UDT instance name and parent folder name](http://forum.inductiveautomation.com/t/grab-the-udt-instance-name-and-parent-folder-name/20521/2):
>
> I find some solution by using {InstanceName} and {TagName} pre-define parameters. {PathToParentFolder} is return folder path with \ as seperator which i need dot . instead Does anyone know a solution to replace \ with . for {PathToParentFolder}? Thanks.

Otherwise, I think you'll have to use a script, as @mmaynard said.

```auto
tags = system.tag.getConfiguration(tagPath)
for tag in tags:
  tagType = tag['tagType']
  if str(tagType) == 'UdtInstance':
    imstanceName = str(tag['name'])

```

---

<div class="post-metadata">

**Author:** ![nader.chinichian](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nader.chinichian/32/9261_2.png) [@nader.chinichian](https://forum.inductiveautomation.com/u/nader.chinichian)\
**Post date:** [November 21, 2020, 10:27am UTC](https://forum.inductiveautomation.com/t/find-udt-instance-name-from-full-tagpath/40845/5 "2020-11-21T10:27:28Z")

</div>

> [@nminchin](#):
>
> tags = system.tag.getConfiguration(tagPath) for tag in tags: tagType = tag['tagType'] if str(tagType) == 'UdtInstance': imstanceName = str(tag['name'])

For my case because I have always reach Atomic Tag non of the solution work for me. I think of every dirty solution and it works me now. As you see in code below I'm trying to reach some Parameters of my Parent UDT which is called 'HMI'.

```auto
		UDT = tagPath
		HMI = ''
		
		while True:
			p = UDT.rfind('/')
			if p == -1:
				break
			UDT = UDT[0:p]
			if system.tag.exists(UDT+'/Parameters.HMI'):
				HMI = system.tag.read(UDT+'/Parameters.HMI').value
				break

```

---

<div class="post-metadata">

**Author:** ![MMaynard](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mmaynard/32/3366_2.png) [@MMaynard](https://forum.inductiveautomation.com/u/MMaynard)\
**Post date:** [November 21, 2020, 2:38pm UTC](https://forum.inductiveautomation.com/t/find-udt-instance-name-from-full-tagpath/40845/6 "2020-11-21T14:38:58Z")

</div>

In the linked script just change up the return to bring back the tag name instead of the type.

```auto
# we found the UDT definition tag path, return it
     #sRet = tagConfig.get(prop)
     sRet=tagName
     return sRet

```

---

<div class="post-metadata">

**Author:** ![nader.chinichian](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nader.chinichian/32/9261_2.png) [@nader.chinichian](https://forum.inductiveautomation.com/u/nader.chinichian)\
**Post date:** [November 21, 2020, 5:28pm UTC](https://forum.inductiveautomation.com/t/find-udt-instance-name-from-full-tagpath/40845/7 "2020-11-21T17:28:00Z")

</div>

Hi  
Can you explain it a little more or show the code?
