Add and remove curve to/from trend dynamically

<< Click to Display Table of Contents >>

Navigation:  Examples > Trends >

Add and remove curve to/from trend dynamically

Previous pageReturn to chapter overviewNext page

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:

 

 

addremovecurvetags

 

2. Create 2 Buttons “Add curve” and “Remove curve” and bind them to the Add and Remove tags, respectively, through the Control Property:

 

clip0048

addcontrolbutton

removebutton

 

3. Create a ComboBox object and bind the Number tag to it through the “Selector” property and fill the “Collection” with tag names:

 

clip0049

combobox

rangecollection

 

4. Now let's create 2 scripts to add and remove a curve:

 

addcurve

removecurve

 

Let's write a script to add a curve using the addcurve function from the Trend's curve library:

 

addcurvetext

After you have recorded the script, be sure to launch it by clicking the button on the toolbar: runsimulation

 

Let's write a script to delete a curve using the removecurve function from the Trend's curve library:

 

removecurvetext

After you have recorded the script, be sure to launch it by clicking the button on the toolbar: runsimulation

 

5. Link the scripts to the tags - Add and Remove:

 

addtagscript

removetagscript

 

Now when we click the Add and Remove buttons we call the corresponding scripts.

 

6. Run simulation to check the settings:

 

trendaddremovecurve

 

You can download this project here.