Delete Tag Alarm Configuration Jython Script

I’m trying to configure my alarms using a script looking something like this

for tag in selectedTags: system.tag.editTag(tagPath=tag, alarmConfig={'Alarm':propList})

I ran the script a few times while debugging it and each time it added a new alarm to each tag. Now I want to delete all the alarms I have configured and then run my alarm configuration script again so that there is only 1 correct alarm for each tag.

The only way I can think to do this is removing and remaking each tag without any alarms. Something like

#read every tag attribute here


system.tag.addTag(parentPath=tag.path, name=Name, tagType=TagType, dataType=DataType, accessRights=AccessRights, enabled=Enabled, value=Value, attributes=attribDict, parameters={}, overrides={}, alarmConfig={})

It seems like there should be an easier way to do this. Does anyone know of one?

You could export the entire tag database to XML, filter out the alarm sections with sed or awk or a suitably capable text editor, then import the “clean” tags.

In the future, export your tag database in its “clean” state before running an unproven script. Then you can import to restore it before your next attempt. And so on.

Thanks pturmel, this (export/edit/import) seems to be the best way, which is a pity because my favourite feature of Ignition is the ability to use scripting in Ignition for Project Configuration & Design as well as Runtime.

Hopefully a more complete set of methods for tag objects will be released as time passes.

Just a quick note about processing XML files:
Given that most who see this are familiar with Python, I suggest looking at the ElementTree (or better still lxml) module for fiddling with XML files. I’m not really familiar with SED/AWK, but understand that they are for text file processing (line by line), whereas the ElementTree API reads in the whole XML file as a data structure which can then be manipulated and written out to a new XML file.

I started out processing RSLogix L5K files line be line, and when I discovered ElementTree and L5X files it made a huge difference.