Generating 3D Topography from a 2D DWG file

Being an MEP guy, topography is one of those things in Revit I don’t deal with too often but the general concept of working with topography isn’t tremendously difficult.

The two main options you have for automagically generating a topography surface are to either import from a DWG file that contains 3D surfaces – generally these would be topography triangles, or to generate from a list of points in a CSV file.


The problem is, sometimes you won’t get a DWG file with 3D surfaces and you don’t have a CSV file either.. in fact the surveyor sent you a DWG file with surface points at a 0 elevation. Useless right? Well maybe not quite. Before you jump up and down telling the surveyor to “Do your job properly” and demanding the file in 3D you might be able to impress everyone with your skills and get quicker results.

Step 1 – Extracting the data from AutoCAD

Firstly you want to extract the usable information from AutoCAD. You need to have a really clear understanding of the data you’ve been given. Survey drawings could contain spot information for elements such as buildings, trees, fences and other non-surface information so you need to make sure that you’re grabbing only the information that is relevant to the topography surface. The last thing you want to be doing is telling everyone that the data is rubbish because “these random spots I decided to look at are 5m higher than the surrounding surface, the surveyor must be wrong”

Using your preferred workflow, strip out all the information from the DWG file not related to the surface. My method is to freeze off unrelated layers and then copy and paste what remains to a new DWG file


This will more than likely leave behind linework that isn’t required to generate your topography. You can remove anything from the DWG that isn’t a point or text if you like, but leaving the information in the DWG won’t affect the process. If there is any MTEXT in the file, select it and explode it so it becomes regular text (DTEXT).

If you’re removing the redundant linework and only leaving points and text, once finished the before and after should look something like this


The next step is to use a lisp routine to generate 3D points from the text that identifies the elevations throughout the drawing. You might already have a lisp routine that does the job, but if not a quick search on Google and the top result is this page from CADTutor which has the source for a lisp routine from the user Geobuilder. This is why we had to explode our MTEXT as the lisp routine only works on single line DTEXT.

Text to Points LISP
(defun C:Convert_Text_to_Point (/ ss Z_value temp koord)
  (if (setq ss (ssget "_:L" '((0 . "Text"))))
      (initget "Koord Value")
	Z_value	(getkword "\nTake Z from [Koord/Value]? <Value>:")
	Z_value	(if Z_value
	ss	(vl-remove-if-not
		  '(lambda (x) (= (type x) 'ENAME))
		  (mapcar 'cadr (ssnamex ss))
      (foreach item ss
	(setq temp  (entget item)
	      koord (cdr (assoc 10 temp))
	      koord (if	(eq Z_value "Value")
		      (list (car koord)
			    (cadr koord)
			    (atof (cdr (assoc 1 temp)))
	(entdel item)
	    '(0 . "POINT")
	    (cons 10 koord)

Copy and paste the lisp code into Notepad and save it as something you’ll remember. I’ve saved mine as txt2point.lsp


In case you were unaware, the command for a lisp routine is defined after the code (defun C: so in the instance of Geobuilder’s lisp routine, the command is Convert_Text_to_Point

Load the lisp into AutoCAD and run the command. When I run the command, I simply selected all text.


Once done, your DWG file will look something like this. To change the display of your points from dots to crosses, you can change the PDMODE variable. In the screenshot below my PDMODE is set to 2.


The next step just as a is to remove all points that have a Z value that is equal to 0.0. Remember the information we received from the surveyor had points at 0,0 and we’ve now just generated a new set of points from the text labels. This means we’ll have duplicate points, some with a Z value of 0.0 and some at the correct Z value. Removing these points is simple to achieve by using the Quick Select tool.


Once done, these will leave us with points at the roughly the correct spatial coordinates and elevations. The reason why I say ‘roughly correct’ is that the text insertion point may be offset from that of the original point, in the example I’m using the accuracy was to within 100mm.

The final step in AutoCAD is the DATAEXTRACTION tool. You need to make sure your DWG has been saved before you run the data extraction. The data extraction tool is fairly straight forward, however if you want step by step instructions, you can expand the section below.

Step by Step - Using the data extraction tool
1 & 2. Select ‘Create a new data extraction’ and click next.

3. If you only need to extract data from one DWG file, click next. If you need to extract data from multiple files, add them to the list and then click next.

4 & 5 Make sure that you only have points selected, click next.

6 & 7. Uncheck all items except for Position x, Position Y and Position Z

8 & 9. Uncheck combine identical rows, show count column and show name column. Click next.

10 & 11. Select the output location and file type. You can select either CSV or XLS as we need to make some changes to the file in Excel before importing the file into Revit.

12. Click finish and the file will export.

Maniptulation of the Data in Excel

The next step is manipulating the data in Excel so that the points import in to Revit correctly. A lot of people misunderstand how Revit’s coordinate system works which often leads to problems  when working with data between AutoCAD and Revit. Even if your project is in shared coordinates and you can link your DWG file in by shared/world coordinates, imports such as this one where we are bringing topography in via CSV file will not drop in the topography in the correct location.


In Revit your project base point is exactly that – your project base point. The 0,0 of your project. This means to process our data in Excel we need to subtract the coordinates of the project base point from the survey point we exported from AutoCAD.


Once you’ve subtracted the base point coordinates from the coordinates of the survey points, the end result should look similar to the screenshot below which lists out all the points in coordinates that are relevative to the project base point.



Finishing Up – Importing The Topography into Revit

The final step of the process is to import the CSV file itself. Again the import process itself is quite simple, but if you’re after step by step instructions you can expand the section below.




Step by Step - Importing the CSV to Revit
1. From the Massing & Site select ‘Create from import’ and then ‘Specify points file’ an open file dialogue box will open, select the CSV file that you created.

2. Select Select the correct units of the file.

3. Finish up the topography generation.

Tidying up the output

To finish up, you’ll need to review the imported topography and tidy up the output. You can see here that in my example a few 0 z elevation points made it through into the CSV file.


You can modify the topography using the edit surface tool, it’s up to you how you handle it, in this instance I chose to delete the 0 elevation points however you may want to fix up the elevations of the points to make sure all the gaps have been filled in and the topography is as complete as possible.


Although it was a fairly lengthy how to, the entire process from start to finish should take no longer than 10-15mins which in most cases is much quicker and far less painful than going into battle with the surveyor over a bunch of 0 elevation points.

4 thoughts on “Generating 3D Topography from a 2D DWG file

  1. avatar Kittisak Arpornwicharnop says:

    Thank you so much for sharing.

  2. avatar Keith says:

    This was a very useful explanation for someone who has never had to do this though has wondered how it could be done. Thank-you and much appreciated.

  3. avatar Pierre Venter says:

    Its easier to get the Surveyor to provide the data. But, using this its been interesting to see how easy its to generate a suitable site. I’m looking at adaptation for cross-hairs as the “actual” coordinate point not the Spot-Height Text, and generating the topography at the same time.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.