<< Click to Display Table of Contents >> Add and remove curve to/from trend dynamically |
![]() ![]() ![]() |
If you want to add or remove curves to/from a trend dynamically, you should use scripts. Let's look at an example how to do this. Let's take the project from the previous example as a basis, where we have already created and configured tags and graphic objects.
1. Suppose we want to see the dynamics of two more parameters on the same trend. In this case, having copied Tag1, we will additionally create Tag2 and Tag3,
2. Let's create 2 intermediate tags - Add and Remove. When the values of these tags change from FALSE to TRUE, we will add or remove a curve.
3. Let's create an intermediate tag Number, it will contain information about which tag we want to add or remove. All our tags look like below:
2. Create 2 Buttons “Add curve” and “Remove curve” and bind them to the Add and Remove tags, respectively, through the Control Property:
3. Create a ComboBox object and bind the Number tag to it through the “Selector” property and fill the “Collection” with tag names:
4. Now let's create 2 scripts to add and remove a curve:
Let's write a script to add a curve using the addcurve function from the Trend's curve library:
After you have recorded the script, be sure to launch it by clicking the button on the toolbar:
Let's write a script to delete a curve using the removecurve function from the Trend's curve library:
After you have recorded the script, be sure to launch it by clicking the button on the toolbar:
5. Link the scripts to the tags - Add and Remove:
Now when we click the Add and Remove buttons we call the corresponding scripts.
6. Run simulation to check the settings:
You can download this project here.