Using a Tagpath as a variable in a Expression

Hi All

I am learning ignition and am trying to do something to simplify repeat object. In this case, I have 10 x labels that I want to link to 10 x tags. I am trying to avoid (if possible) having to link each one manually so set their name to “LinkTag_0”, “LinkTag_1” ect and they need to link to a mamory tag formatted “[default]SC_Track/LinkedTag 0/ItemID”

I have had some partial success with a script:

def transform(self, value, quality, timestamp):
	name = self.meta.name.replace("LinkTag_", "")
	return system.tag.readBlocking(["[default]SC_Track/LinkedTag {}/ItemID".format(name)])[0].value

This script sets the value but when I change my memory tag, it doesn’t update my label. Is there a better way to handle this?

The reason behind this is that the plan is to have multiple objects on screen, each linked to a set of tags, but I am trying to avoid having to setup multiple links against these.

Hope this makes sens

S

Given the script is used to only read the value of one tag I would recommend using an indirect tag binding. If you want this setup to read and write I will make the binding bidirectional.

Bit something like this (check the Bidirectional checkbox if you want to read and write to that tag).

With an indirect tag binding you can build the tag path dynamically. You can find more info here: Tag Bindings in Perspective | Ignition User Manual

Script transforms in Ignition are event-driven, not continuously evaluated. This distinction is key to understanding why your value did not update and why the script did not re‑run when you manually changed the memory tag.

A script transform only executes when one of its input values changes. What counts as an “input” depends entirely on how the binding is configured:

  • If you are using an expression binding with a script transform, the script transform will only run when any input referenced by the expression changes.
  • If you are using a property binding or tag binding followed by a script transform, the script transform will only run when that bound property or tag value changes.

In your case, changing the value of a memory tag did not cause the script transform to re-run because that memory tag was not part of the binding’s input path. Simply referencing other tags or custom properties inside the script body does not make them inputs. Ignition does not track values that are read imperatively inside the script.

1 Like