Pass UDT to a Window via python script

I want to pass a UDTProperty parameter to a Window via script, but I can’t work out how to convert the UDT tagpath string to a UDTProperty type.
I have at the moment this script on the mouse release action of a button:

[code]tanknum = event.source.parent.getComponent(‘List’).getSelectedValue()
tankUDT = ‘Deep South Tank Farm/Tank 9008’ #set to a static string for testing only. this is the UDT tagpath

system.nav.swapTo(‘Main Windows/Tank Detail’, {‘TankUDT’ : tankUDT})
[/code]

This results in the error:

How do I resolve this?

PS Still very new to Ignition so apologies in advance!

Thanks

Nick

nminchin

I would do this differently
on your page or template have a string that is the UDT tagpath, then have the UDT read that path using indirection.

All you have to do is pass the tagpath as a string to the page or template and it will work. this is so much more flexible as the trigger can be UDT independent and used across the project.

Thanks Chris! I actually recently found another post that said to do the exact same thing. I’ve converted my page to use this instead and it’s working great :slight_smile:

Edit: it’s also worth noting for future reference, that it’s actually far better in terms of performance to avoid passing UDTs around, and instead - as Chris suggests - passing the path to the UDT object instead.
Linking objects to UDT instances directly can cause significant performance issues on the client, as I saw on my very first Ignition project…

1 Like