Getting value from tag's ExtendedProperties without iterating

Howdy,

I’m trying to do something like

propertiesList = system.tag.read( '%s.ExtendedProperties' % tag )
propertiesList.value.contains("foo")

or

system.tag.read( '%s.ExtendedProperties.SomeParameter' % tag )

Or something to that effect. I see that propertiesList is an ExtendedPropertySet, which according to the SDK has a .contains() method, but I can’t seem to figure that out

If I didn’t have to pull the entire extended properties list that would be even better, just search to see if one exists and what the value is

Thanks

You can read most properties using

system.tag.read("path/to/tag.property")

Already. unless I am missing something.

But not the ExtendedProperties, which are really the custom parameters. When you do

system.tag.read("path/to/tag.ExtendedProperties")

You get a com.inductiveautomation.ignition.common.config.BasicPropertySet object back, and apparently the only way to read those is to iterate over or coerce it into a giant string

I found another answer on here that says must iterate… I suppose you could use a regex instead but I’m not sure which way is goofier

A contains method, or even a .toPythonDictionary method would be ideal, then you could use the data in a normal Python way

Some solutions buried in here

There is a contains method, but it expects an argument of type com.inductiveautomation.ignition.common.config.Property not a string

from com.inductiveautomation.ignition.common.config import Property, BasicProperty
tag = "New"
propertiesList = system.tag.read( '%s.ExtendedProperties' % tag ).value

print propertiesList.contains(BasicProperty('New', Property))

2 Likes

Right, I got that far, I couldn’t figure out how to coerce what I was looking for into a “property” and I’m not sure how I get from the Java SDK docs to what you’ve whipped up. I guess I should learn Java?

Unfortunately I can’t use this because it returns true even if the property’s value is null. So I guess my question now is how to read a single value

I tried to use .get, which, according to the docs also takes a property, but I’m being told

Cannot coerce value '' into type: interface com.inductiveautomation.ignition.common.config.Property

I would think

print propertiesList.get(BasicProperty('Foo', Property))

would just work, same arguments, right?

And if you have any advice on what to read so I can pick up this stuff, I’d appreciate it. I’ve been programming a long time, many languages, but there’s definitely a missing link here

Thanks

It doesn’t matter if the property’s value is null, the property still exists right?

I’m still a little unsure what you are trying to do. If you want to check to see if a tag contains a property, you can use my code above. If you want to check the actual value, you can either iterate or use .get but you need to specify the type. I created a new instance of a UDT on my machine with a property called “Animal” of type String and used the following code to get the value:

tag = "Animal1"
from com.inductiveautomation.ignition.common.config import *
from java.lang import String

propertiesList = system.tag.read( '%s.ExtendedProperties' % tag ).value

prop = BasicProperty('Animal', String)

print propertiesList.getLocal().get(prop)

The following code returns true, telling me that my Tag has the property “Animal”, regardless of if it has an actual value or not:

tag = "Animal1"
from com.inductiveautomation.ignition.common.config import *
from java.lang import String

propertiesList = system.tag.read( '%s.ExtendedProperties' % tag ).value

prop = BasicProperty('Animal', String)

print propertiesList.getLocal().contains(prop)

If I go into the tag and delete this property, the code above returns false as expected.

Does this clear things up at all? Maybe it would help if you provided more details on your application.

1 Like

Ayy, I was actually looking at getLocal() as well. I just needed some Java voodoo but at least I was on the right path

I’m enabling and disabling UDT sub tags / child tags based on if they have a parameter with data. The parameters are named the same as the tags for scriptability

To me, contains typically means that a key contains a value, but from the ExtendedProperties as a dataset point of view, contains returning true on null properties makes sense, it’s just not what I needed for this application

Either way, I appreciate the help and clarification