<< Click to Display Table of Contents >> Calculate AutoCAD Properties |
Please make sure you read through the Calculate simple Example chapter, because we will keep the explanations shorter and you may miss some details.
In this example, the color of a General Instrument Symbol is supposed to be changed to red if the Tag contains a "?". This can be cause when copying a symbol or if the properties of the Tag are incomplete.
If we look at the Tag property we see a ? at the end of the Tag.
We create a new calculation where we select "General Instrument Symbols" class and we calculate the "Color (Index-no.)". As you can see you can create many other AutoCAD properties like Layer or HyperLink URL.
We use the following expression:
Iif(Contains([Tag], '?'), 1, [#ObjectColorIndex_DefaultValue])
Contains([Tag], '?') checks if the Tag property contains a ?.
Iif(Contains([Tag], '?'), 1, [#ObjectColorIndex_DefaultValue])
The [#ObjectColorIndex_DefaultValue] expression statement returns the value from the symbol's property settings. Besides the Color you can also get all other AutoCAD Properties.
The Iif(..., 1, [#ObjectColorIndex_DefaultValue]) statement returns 1 (red) if the Tag contains a ?. Otherwise it'll returns the value from the symbol properties. Which is the color you would expect if there would be no calculation.
After clicking on OK we see the expression in the calculation setup dialog.
If we click on OK again, we see that the calculation is defined without any error and it is active.
We save the drawing and see the calculation has been updated without fail.
When we copy the right instrument to the left the instrument will become red instantly.
If we now change the Tag, the symbol will become yellow.
Next Chapter: Calculate Annotations