# UDT in script

**URL:** <https://forum.inductiveautomation.com/t/udt-in-script/5688>\
**Category:** Ignition\
**Created:** [January 16, 2013, 5:29pm UTC](https://forum.inductiveautomation.com/t/udt-in-script/5688 "2013-01-16T17:29:40Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![flux](https://avatars.discourse-cdn.com/v4/letter/f/ce7236/32.png) [@flux](https://forum.inductiveautomation.com/u/flux)\
**Post date:** [January 16, 2013, 5:29pm UTC](https://forum.inductiveautomation.com/t/udt-in-script/5688/1 "2013-01-16T17:29:40Z")

</div>

Is there a way to access UDT properties inside a script. Basically I want to pass a UDT as a parameter in a script so I could check the properties and do some logic…

Instead of doing this

```auto
def getStatus(tagPath):
        import system
	exist = system.tag.exists(tagPath)
	
	if exist:
		fault = system.tag.read(tagPath + "/Fault").value
		vfdFault = system.tag.read(tagPath + "/VFDFault").value
		pe1 = system.tag.read(tagPath + "/PE1").value
		pe2 = system.tag.read(tagPath + "/PE2").value
		running = system.tag.read(tagPath + "/Running").value
		inbound = system.tag.read(tagPath + "/Inbound").value
		outbound = system.tag.read(tagPath + "/Outbound").value

                #Do some logic
```

I’ll just have to do this

```auto
       def getStatus(udt):
                if udt.fault:
                   return 0
                elif udt.vfdFault:
                   return 1
                #.......... and so on
```

Thanks…

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [January 16, 2013, 11:04pm UTC](https://forum.inductiveautomation.com/t/udt-in-script/5688/2 "2013-01-16T23:04:45Z")

</div>

No, the only way to get a UDT object is by having a property with the UDT datatype somewhere on the window. You can’t get the UDT object through scripting right now.

---

<div class="post-metadata">

**Author:** ![flux](https://avatars.discourse-cdn.com/v4/letter/f/ce7236/32.png) [@flux](https://forum.inductiveautomation.com/u/flux)\
**Post date:** [January 22, 2013, 9:43pm UTC](https://forum.inductiveautomation.com/t/udt-in-script/5688/3 "2013-01-22T21:43:19Z")

</div>

Thanks Travis…

---

<div class="post-metadata">

**Author:** ![danFromNj](https://avatars.discourse-cdn.com/v4/letter/d/76d3ee/32.png) [@danFromNj](https://forum.inductiveautomation.com/u/danFromNj)\
**Post date:** [September 27, 2017, 7:09pm UTC](https://forum.inductiveautomation.com/t/udt-in-script/5688/4 "2017-09-27T19:09:15Z")

</div>

Is it still not possible to access a UDT object from a script?

I assume that since ignition can grab a UDT tag and pass it as a parameter, there must be a function (albeit hidden) that can take a tag path and return an list object that contains the UDT values. Does anyone know what this function would be called?

Thanks  
Dan

---

<div class="post-metadata">

**Author:** ![Kyle\_Chase](https://avatars.discourse-cdn.com/v4/letter/k/9de0a6/32.png) [@Kyle\_Chase](https://forum.inductiveautomation.com/u/Kyle_Chase)\
**Post date:** [September 27, 2017, 9:45pm UTC](https://forum.inductiveautomation.com/t/udt-in-script/5688/5 "2017-09-27T21:45:40Z")

</div>

Give this a whirl

```auto
def getAllTheTagz(udtPath):
	
	tagPaths = [tag.fullPath for tag in system.tag.browseTags(parentPath = udtPath, recursive = True) if not tag.isFolder() and not tag.isUDT()]
	_results = system.tag.readAll(tagPaths)
	theTagz = {}
	for i in range(len(tagPaths)):
		theTagz[str(tagPaths[i][len(udtPath):])] = _results[i]
	return theTagz
myUDT = getAllTheTagz("[provider]path/to/the/udt")
print myUDT["propertyPath"].value

```

You can then access the values in an easy manor, such as the last line. If you only need the values, change the \_results[i] in the for loop to \_results[i].value
