Calculate AutoCAD Properties

<< Click to Display Table of Contents >>

Navigation:  PlantExpressTools > How to use > Calculations >

Calculate AutoCAD Properties

Previous pageReturn to chapter overviewNext page

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.

Calculations 18

If we look at the Tag property we see a ? at the end of the Tag.

Calculations 19

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.

Calculations 20

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.

Calculations 61

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.

Calculations 21

After clicking on OK we see the expression in the calculation setup dialog.

Calculations 22

If we click on OK again, we see that the calculation is defined without any error and it is active.

Calculations 23

We save the drawing and see the calculation has been updated without fail.

Calculations 37

When we copy the right instrument to the left the instrument will become red instantly.

Calculations 18

If we now change the Tag, the symbol will become yellow.

Calculations 24