Every once in a while, I run across an AutoCAD drawing with contour lines that are 2d polylines with an elevation of zero, but the actual elevation is the layer name. While they appear as contour lines, that’s not a very useful format for the modeling world – particularly for Civil 3D users that want to use the polyline contours to create a surface. These files usually come from a GIS conversion process, typically where the GIS provider doesn’t understand DWGs and AutoCAD modeling. Often the data started as a shape file, and someone converts it to a DWG and sets the elevation property as the layer name.
There’s a relatively simple way to change it to a more useful format. The trick is to use AutoCAD Map 3D’s Drawing Attach command (found on the task Pane under the Map Explorer tab).
Select the DWG with contours and add them to the selection set shown in the bottom box and hit OK. The DWG file will show up under the Drawings folder on the Map Explorer.
You can select the Drawings folder, right click and select Quick View, make sure the Zoom to the Extents button is flagged, and hit enter. That will set your drawing extents to match the contour drawing extents – it becomes a visual to check progress. Remember, a Quick View is only a view, and will disappear with a regen.
When that is finished, select the Current Query under the Query Library on the Map Explorer.
On the Define Query dialog, hit the Location Query Type and set to All, and then under Options, select Alter Properties.
On the Set Property Alterations dialog, select the Elevation property (this is the property we want to change) and then select the Expression button.
Expand the Properties folder (this is all of the objects AutoCAD properties) and select Layer. This will set the Layer name as the data source.
Select the Add and it will create the expression in the box at the top of the dialog. This will tell the query command to copy the value from the Layer name to the Elevation. In this case it will work because the layer name is a number. If it was not a number, this wouldn’t work the same way.
When you get ready to run the query, be sure to set the Query Mode to Draw. The when you execute the query, the contour lines will be copied into your current drawing and the elevations should now match the layer name.
Check out my video on this on the CADsoft YouTube channel: