Geospatial Analysis with AutoCAD Map 3D, Part 316 Feb, 2010 By: Michael Schlosser
Query your CAD drawings to access the wealth of data they contain: points, lines, text, and more.
It is said, "A picture is worth a thousand words." Now, imagine what we could do with a picture if it were more than a drawing — what if that picture were data too? In engineering and architectural design, CAD drawings are often treated as pictures and used to illustrate a design for construction purposes. However, CAD drawings, such as those created with AutoCAD software, contain a wealth of information that can be used for additional benefit. For example, a DWG file can consist of points, lines, text, and other CAD entities, as well as numerous CAD properties such as layer, line style, color, block name, and more.
With AutoCAD Map 3D software, this information can be queried and analyzed in much the same way that a spreadsheet or database can be queried. We can use this capability to help create new drawings, generate material lists and reports, find specific CAD features, and otherwise reveal new patterns in the data. With AutoCAD Map 3D we can use CAD data queries to help answer questions such as "How many power poles are in a proposed subdivision?" and "Where are all the fluorescent light fixtures in a specific building renovation?"
In this article, we will show how to use AutoCAD Map 3D to query your CAD drawings and explore why AutoCAD Map 3D is a great tool for analyzing your CAD data. A video demonstrating the techniques discussed below is available via my blog.
CAD Data Queries
In AutoCAD Map 3D, you can use four types of CAD data queries to help analyze DWG files:
- Location queries are used to define a spatial filter. For example, search for all objects that fall within a rectangular window.
- Property queries are used to create a filter based on an object's CAD properties. For example, find all objects on a certain layer or of a specific color.
- Data queries are used to define a filter based on object data. For example, if an object data field named Pipe Diameter is attached to lines representing water mains, we can find all water mains with a pipe diameter greater than 8 inches.
- SQL queries are used to create a filter based on an object's external data. For example, if our polygon objects are linked to an external database containing assessment information, we can find all polygons with assessed land values greater than $50,000.
For discussion purposes, we will query a DWG file containing a municipal water main network. Specifically, as part of a municipal water main replacement program, we need to determine the location of all cast-iron water mains and the total length of all cast-iron pipe to be replaced.
To query CAD data, we must first attach the DWG file containing our water main network to the current drawing. By attaching a DWG file rather than opening the file directly, we allow multiple users to work with multiple DWG files simultaneously — an efficient workflow that helps minimize bottlenecks when more than one person needs to work with the same file.
In the Map Task Pane, activate the Map Explorer tab then click Data > Attach Source Drawings to reveal the Select Drawings to Attach window. In the upper pane of this window, navigate to the appropriate folder, select the DWG file containing the water mains, click the Add button, and then click OK.
Now that the water mains drawing is attached, we can create our queries. In Map Explorer, click Data > Query Source Drawing to reveal the Define Query window.
Define a location query by clicking on the Location button to reveal the Location Condition window. Several types of spatial locations can be defined to filter our water mains by location. Select the All option and then click OK to return to the Define Query window. Ensure that the Query Mode is set to Preview, and then click Execute Query.
If necessary, use Zoom Extents to reveal the query results; namely, all water lines from our attached water main drawing. Note that in Preview mode the drawing entities are displayed, but not actually pulled into the current drawing; the Preview query mode is a faster way of reviewing a drawing's contents. Note that a Redraw command will remove the water lines from the screen.
Now let's modify our query so that only the cast-iron water mains are displayed. In Map Explorer, click Data > Query Source Drawing to reactivate the Define Query window. Click the Properties button to reveal the Property Condition window. At this point, several types of CAD properties can be used to refine our query. Since our water mains are organized by layer according to their material type, select the Layer option and then click the Values button to reveal a list of layers. Select the CAST IRON layer and then click OK.
Click OK again to return to the Define Query window. Ensure that the Query Mode is now set to Draw, then click Execute Query.
Note that our drawing now shows a subset of the water mains; namely, only those water mains where the layer name equals CAST IRON. Also, note that in Draw mode, our drawing entities are now part of our current drawing; a Redraw command will not cause the entities to disappear.
Now that we know the location of all cast-iron water mains, we can create a report that lists their lengths and corresponding pipe diameters. Reactivate the Define Query window, set the Query Mode to Report, and click the Options button to reveal the Output Report options window. Click the Expression button and expand the Properties branch to reveal the various drawing properties, such as color and layer, which can be added to our report. We need the pipe length, so select the LENGTH property and click OK. Next, click the Add button to add this property to the report. Specify a suitable file name for the report in the Output File Name area.
Click OK to return to the Define Query window, and OK again to create the text file containing the length value of each cast-iron water main. To determine the total length of cast-iron pipe identified through our query, we can open our text file in Microsoft Excel and use Excel's summation tool (look for the sigma symbol) to quickly arrive at a total length.
This article has examined the creation of a simple CAD data query of an attached DWG file using AutoCAD Map 3D, a helpful tool for analyzing your CAD data. A video of this example, showing how to categorize water mains by their pipe diameters in order to determine the length of pipe needed for each pipe size, is available via my blog.