Calculate simple Example

<< Click to Display Table of Contents >>

Navigation:  PlantExpressTools > How to use > Calculations >

Calculate simple Example

Previous pageReturn to chapter overviewNext page

In this simple example we calculate the property "MesasuringType" by using the first character from the property "Type". In this example Type shows PI ao the MeasuringType will be "P".

Calculations 01

To create a new calculation we click on the "Edit Calculations" button.

Calculations 02

In the following dialog we click on "New...".

Calculations 03

In the next dialog we define the class, the property which should be calculated and the calculation expression itself.

Calculations 04

We select "General Instrument Symbols" class and the "MeasuringType" property.

Calculations 05

Next we click on the "Edit" button.

Calculations 06

The blank "Expression Editor" will be opened. In the top part you will see the calculation expression which can also be manually typed in or edited.

For details on the Calculation function and the Expression Editor have a look here.

Calculations 07

First we need the function to subtract the first character of a string. We click on "String" under "Functions" and then we scroll down to "Substring". There are two different types and we use the first one. On the right side you see the details of the selected function.

Calculations 08

You can also type in parts of the function which filters the available functions.

Calculations 09

If you double-click on substring it will land in the expression window at the position of the cursor. We see the general error message "Syntax error.".

Calculations 10

We remove the two ' characters, click on "Columns" and then double-click on "Type".

The project and drawing properties are available also.

Calculations 11

The property will also land in the expression window in [ ].

Calculations 12

The next two parameters are 0 and 1. 0 is the start position (the counting starts at 0 for the first position). And 1 is the length of the string. We need only 1 character from the start.

Calculations 13

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

Calculations 14

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

Calculations 15

After closing the dialog and saving the drawing we see an update info in the command line. If there are any issues during the update, we would see it here.

Calculations 16

In the Properties Palette we see the calculated value.

Calculations 17

Next Chapter: Calculate AutoCAD Properties