I'm using ignition edge 8.1 and creating a template for a robot. I have a Label that I would like to copy and paste multiple times and was hoping to change the label text using a generic binding expression and a single custom property (string type) named 'index'.
Currently, using no custom properties, I just use:
I then created my custom property and assigned it a value of 2 (again, string type) in order to replace the 2's in the expression above. I created my new expression:
Currently this is not working at all. I'm very new to Ignition but have seen syntax like {this.index} used in a similar ways other places. I feel like I'm missing something...can you not use custom properties in binding expressions?
If I were to use the indirect tag method like you're saying, then I would not be able to concatenate the "1. ", "2. ", etc. in a single label, no? Are you saying that should be a separate label? I guess the more general form of the question would be: if you ever have a case where you don't want to bind it to the tag value but rather use the tag value as part of the expression in the binding, then what would the preferred method be?
One custom property with an indirect binding to hold the tag value that you want to use in the label display. This property could be on the label or on the template root.
Then on the label text have a binding of {self.index} + '.' + {self.tagValue}.
The indirect binding would look something like {1}/HMI/LocalName/LocalName{2} with the two sources being {EpsonRobot.RobotTagPath} and {self.index}
Also, vision components reference themselves using self, perspective components use this.
So, I created two custom properties:
index - string type
tagValue - string type
For tagValue, I did an indirect tag binding. Reference {1} took the EpsonRobot.RobotTagPath no problem. However, for Reference {2}, it does not seem to accept self.index. I get the error:
I'm guessing EpsonRobot is the name of the template? In that case, self.index should be EpsonRobot.index, assuming the index property is defined on the template base. Capitlization is important, make sure it matches what you have defined.
I created index as a custom property of the label. The goal being I can copy and paste this and the change the index. Does 'self" reference the individual object (label, button, etc.) or the template?
Did you add the custom property while the binding popup was open? That may cause issues.
Also, with the second item of the indirect binding selected, you can click the list icon to the right to manually navigate the item structure and select a property. See if it shows up there.
ok, yeah, this only works in perspective. in Vision, you'll have to pick the label by name. But once you get it set up correctly, Ignition will automatically update the reference when you copy it.
in your 2nd reference, You can try EpsonRobot.Label.index instead of self.index. self is a reference to the whole template and not the label component that you're selecting.
@vtran, you are correct. It looks like self is looking at the whole template. You are also correct that ignition will automatically update the references that are pointing to itself in the tree. That was the key I was missing.
After correcting the instances of "self" in all of my bindings and expressions everything is working right! And I can copy and paste it and only update the index and everything links up correctly.