Find UDT instance name from full tagPath

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.

Been covered in

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.

You can't use your solution here?

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

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'.

		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

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

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

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