Sometimes when using vertical versions of AutoCAD (like AutoCAD Map, Civil 3D, Architecture, etc), is that you can get entrenched in the vertical tools and forget that it is still AutoCAD, and so you have all those rich AutoCAD tools available. Recently while working with a client, one of these came up. The tool in question was QSelect. Now, I don’t know when QSelect initially showed up – for years I used LISP routines to do advanced selection, and one day several releases ago I stumbled across QSelect. It has been a great friend to me ever since – particularly working in the GIS world.
In this case, they have a drawing with areas defined as numbered zones. The drawing was created to show boundaries in individual sheets rather than build polygon data sets. There are labels along the lines throughout the data, duplicating where they will show on the sheets.
These drawings have been in use for some time, and they wanted to turn these into a polygon feature class. Generating a polygon feature class is pretty basic, and there are several ways. I like to get a clean data set without slivers or gaps, so using Map’s topology tools are a great way to get clean data and converting to a feature set is easy. The process forces you to clean the polygon data, and then create the topology. One challenge is that you can only have one centroid in each polygon. The text labels already exist, so they are perfect to use as centroids. The problem is there are too many. Erasing them individually is painful as well. You could write, or find, a LISP routine to prune down the number of labels. Or you can use the QSelect. With QSelect, I can build a selection set by querying various properties of the objects. In this case, select an object type (MText), a property (contents=the actual value of the text) and set an equals operator to find MText objects whose contents = Zone 36a (you don’t use a text identifier such as “” here).
Now I have a selection set of all the text labels in Zone 36a (you can see by all the grips on the selected text). The next step is to escape to drop the selection set (so we can manipulate it later). Now start the erase command, and when it prompts to select objects, type P to get the previous selection set (this grabs all of the queried text labels). Now change the selection prompt to remove mode (removes objects from the selection set) by typing R, and pick one of the labels to remove it from the selection set and enter to complete the command. At this point, there will only be one label for that polygon. Do this for each polygon, and you will be ready to use them for labels.
Now, I wouldn’t use this for a dataset with thousands of polygons, but it is a quick and easy way to remove some tedium when preparing a relatively small dataset.