Wednesday, January 23, 2013

Creating AutoCAD Text from Geospatial Datasets

This is a reprint from an earlier blog (August 9, 2010) that is no longer online.

In this tip, I’m going to convert attribute information from a data set in ESRI Shape format, and create a text label from that attribute. There are a couple of techniques, but in this case, I’ll show a quick and easy technique to create AutoCAD text labels from a connected shape dataset using an FDO connection.
Start with a new drawing, assign the coordinate system and create a connection to the data set to label.

Add the data to the map, and the dataset will show up in my Display Manager.

Once the data connection established, create a style and hit the feature label option. This will open the Style Label dialog box where all the settings are to get the labels to look the way you want.

Going down the dialog box, set the Multiline Option (the Advanced Placement option will set the text to follow the line, which you may want for certain conditions, but the text can end up in separate text entities for every letter – that may be ok – it depends on what you are looking for).
The next item is to identify what property (attribute item) you want to use for your label. If you have an attribute that is exactly what you want, you can set it and be done. In some cases, you may want to modify the value or even combine several elements of the text. To add pipe sizes, take the size and add an inch symbol (the double quote) – so an 8” line will read 8”. You could add material so the label reads 12” PVC, or if doing street names, you might want to combine the street number, direction, name and type to get a complete street name. To modify this, select expression here. This will open the Map Expression Builder dialog box.

There are a lot of options for creating text labels from data, calculations, or other elements. In this case, I want to place some text elements together. The function to combine text is concatenate, which I can find under the text functions under Concat.

Selecting the function places the text and format in the expression window. The function works on the elements contained in the following parenthesis, and the bracketed text property are place holders for the text elements. To get the pipe size and combine it with an inch symbol, replace the first Text Property with the value for the size, and the second with the “ symbol (surrounded by single quotes to show it’s a text value – ‘”’). You can continue to add pieces of text until you get the desired label. To add attribute values, such as the size, use the Property menu and the list of attributes will be there sorted by the type of field. I’ll select the size, and complete the expression – Concat ( SIZE , ‘”‘ ). For street names, an expression might be concat( ST_DIR, “ “, ST_NAME, “ “, ST_TYPE) where the “ “ is used to add spaces between the fields.

You can use any combination of data fields and other elements to create a label with this expression process.
Once the expression is set, you can set the display parameters such as size, color and font. Remember with the size, Map Space is scale relative to the model and set the height to a specific value, while device space is relative to the monitor, or view, and will change the physical height based on the zoom scale.

Once the labels are set how we want them, we can go to the Display Manager and select Save Current Map to DWG from the Tools menu.

After saving to a new drawing file, we can open the file and the labels are now standard AutoCAD text items along with the roads. The process actually takes more to write about than to actually do.

Next post, I’ll go the other direction. I’ll show how to grab labels and turn them into attributes.

No comments: