Annotation Blocks Manipulation

Do you need to use annotation blocks to label some of your features and want to combine different values. For example you want a label with the value coming from an object data table field 1 & field 3 and maybe you want to add extra text at the end of the value. Maybe you want to use the area property of a polygon but need to round the value up.

Well you can with using a couple LISP functions in the value expression. Do not worry about having to write a lisp routine, it’s not that hard just keep in mind the parentheses matching must follow a set of rules. Sort of like in a math expression you need the same number of right parentheses to match the number of left parentheses and AutoCAD process them in matching groups or list. The one important item of using object data or object properties in an annotation block expression is the field or property type. Integers, character, real or point for object data type and integer or strings for the object properties.

In my example I have OD with a field for house number (house_num) and a field for the street name (street_nam) in an OD table named Parcels. I want to create a label with the complete address such as 123 Main. To do this with a lisp expression I use the STRCAT function like so:

(STRCAT :house_num@parcel “ “:street_nam@parcel)

What this means in layman terms or something you might understand is the first part is the left parentheses ( followed by STRCAT, strcat stands for string concatenation, the next part :house_num@parcel get the house_num field value from the parcel OD table. Next we have two double quotes with a space between, this will place a space between the two OD field values, otherwise we have 123Main, next we have :street_nam@parcel, this returns the street name from the parcel OD table, last we close it out with the right parentheses.

Now let’s say we need a label that lists the area of a polygon but instead of having all those places behind the decimal we want to round it up or down to the closest whole number. In this case we use the lisp function RTOS, RTOS stands for Real TO String, with the area property of a polygon the value type is a REAL so we convert it to a string and tell it what format and the number of decimal places to use for the string. It would look like this:

(RTOS .area 2, 0)

We start again with the left parenthesis ( followed by RTOS then .area. The (dot) .area will return the property area of the object. Next we have two numbers separated by the comma, the first number is for the unit format we want the value to be converted to.

1-Scientific 2-Decimal 3-Engineering (feet and decimal inches) 4-Architectural (feet and fractional inches) 5-Fractional

The second number is for the precision, if we use 0 it rounds the value to the nearest whole number, 1 will be one decimal place,2 will be two decimal places, and etc. Then we close it with the right parenthesis

How if you want to combine the STRCAT and RTOS functions together we can, say we want the area of the polygon and a suffix of Sq Ft. We can use something like this:

(STRCAT (RTOS .area 2, 0) “ Sq Ft”)

Notice the (RTOS .area 2, 0) is grouped together then it is grouped inside the STRCAT “ Sq Ft” list. This returns the area in decimal format with no decimal places and then concocts it with the Sq Ft string.

So there you have it a few simple lisp expressions that will allow you to manipulate your expressions values to create some labels with out having to fiddle with multiple attribute tags and text justification. Note these work in the annotation blocks and if you try using them in the style editor for data connect (FDO) data they do not work, I’ll post a few tips to get good looking labels using FDO later.



Readers Locations

Top Rated posts

Chat room


%d bloggers like this: