Adding Elevation Data to Flat Contours

Adding Elevation Data to Flat Contours

CColozza
Contributor Contributor
6,528 Views
18 Replies
Message 1 of 19

Adding Elevation Data to Flat Contours

CColozza
Contributor
Contributor

CColozza_0-1678205937191.png

 

I've got an interesting problem I keep running into; so far the only way I've been able to resolve it is by hours of brute force, and I'd like to see if there are any other options.

 

I often work with large "historical" contour data that comes from literally who knows where. I say "historical" because I am not able to contact the original creator/company of these contours. This contour data has all been saved in DWG format (not SHP) and appears always as a bunch of lines, not referencing some 3D imported object/source. Clearly all of the contours are marked and separated out into their own layers, but there is never any elevation data, meaning all of the contours are at 0 elevation. I'm currently solving this by clicking on each line and updating its elevation field, which takes hours for each file. Is there a smarter way that Map 3D can recognize these lines as contours and make injecting elevation data easier?

0 Likes
Accepted solutions (1)
6,529 Views
18 Replies
Replies (18)
Message 2 of 19

TerryDotson
Mentor
Mentor
I'm currently solving this by clicking on each line and updating its elevation field, which takes hours for each file. Is there a smarter way that Map 3D can recognize these lines as contours and make injecting elevation data easier?

If you were to consider third party add-ons, DotSoft's MapWorks for AutoCAD Map contains a tool that assigns elevations to polyline contours by simply striking a line across the polylines. Turn a large flat topo drawing into a workable 3D contour drawing in a matter of minutes!

 

 

Request the 45-day full working evaluation to see for yourself.  If you have Civil3D, this tool is also available inside our C3DTools package.

0 Likes
Message 3 of 19

CColozza
Contributor
Contributor

Your answer seems to suggest that there isn't a built-in easy solution to this problem. I'm not looking for third-party add-ins at this time, I'd just like to explore what can be done with Map 3D. Although if I keep getting stuck I'll definitely give MapWorks a look!

0 Likes
Message 4 of 19

O_Eckmann
Mentor
Mentor

Hi @CColozza ,

 

no OOTB command can do that. You need to create a little dev.

I think it's possible with macro and diesel command, but with this little code of Lisp it's possible to make quicker than manual.

Specify the begin of elevation and increment, then clic each contour line to update its elevation to base elevation and increment it by increment value.

(defun C:CL_Elev ( / dBaseElev dIncElev)
  (if (and (setq dBaseElev (getreal "\nBase elevation of contour line : "))
	   (setq dIncElev (getreal "\nIncrement of elevation : "))
      )
    (progn
      (while (setq oCL (car (entsel "\nContour Line : ")))
	(command "_CHANGE" oCL "" "_P" "_E" dBaseElev "")
	(setq dBaseElev (+ dBaseElev dIncElev))
      )
    )
  )
)

I use a french version of AutoCAD, I hope international commands are OK .

 

Olivier

Olivier Eckmann

EESignature

Message 5 of 19

ChicagoLooper
Mentor
Mentor

Hi @CColozza 

Yes. That process takes too long. 

 

<<....Is there a smarter way that Map 3D can recognize these lines as contours and make injecting elevation data easier?..>>

 

It depends on your line work and whether there's data 'attached' to those contours. Are you willing to share your file for evaluation? 

 

BTW, those contours and labels look like they were extracted from Civil 3D. In addition to Map 3D, do you run Civil 3D?

 

Chicagolooper

EESignature

0 Likes
Message 6 of 19

CColozza
Contributor
Contributor

Hello @O_Eckmann 

 

I will try and see if I can create a short LSP program based on your code. This isn't quite what I was hoping for but it should definitely shorten the amount of time it takes.

0 Likes
Message 7 of 19

CColozza
Contributor
Contributor

Hello @ChicagoLooper 

 

Unfortunately I only have access to Map 3D 2023 and that's it. I would not be willing to share the actual file I'm working on, or even a snippet of it, as it would violate the working terms I've agreed to. I'm approaching this as an example of a larger issue rather than a specific problem; what to do if all your contours have no elevation data and you are unable to get any more/new data from the original source.

0 Likes
Message 8 of 19

ChicagoLooper
Mentor
Mentor

Hi @CColozza 

Contours which default to O feet above mean sea level are routinely raised to their proper elevation provided there is more than a label indicating their proper height. It can be tricky to ascertain whether native data is stored in, or attached to, an object without screenshots or the dwg itself. 


Do this:

  1. Select a single contour line.
  2. Scroll to the bottom of the Properties Palette using the slider…Is there a section named ‘OD: Name Name’. Better yet, take a screen shot of the bottom 50% of the Properties Palette. 

<<Under these conditions, any experienced user will gladly take a screenshot of the Properties Palette. It is not a violation of privilege nor confidentiality. The Properties Palette does not reveal graphic content, derogatory conditions, ownership or pinpoint site location. The screenshot provides no value other than an honest evaluation of the contour’s parameters.>>

 

 

Chicagolooper

EESignature

0 Likes
Message 9 of 19

CColozza
Contributor
Contributor

After selecting one of the contour lines, this is what the entire Properties Palette looks like:

 

CColozza_0-1678284495666.png

 

If I open up the "Object Class" or "Display" tabs on the right, they are completely blank other than stating at the top that this is a polyline. I still believe that there is no data within the DWG file that contains elevation data, even data fields that were labeled incorrectly or not automatically interpreted by AutoCAD.

0 Likes
Message 10 of 19

ChicagoLooper
Mentor
Mentor

Hi @CColozza 

You're correct. There's no SOURCE within the drawing that's STORING elevation data. You'll need to rely on the labels to give your contours their correct z-value. That's a lot of manual labor on your part.

 

If you want to avoid that labor, you'll need to download new elevation data. The downloads are free and is performed frequently and once downloaded, they're easily inserted into existing drawings using various methods. <<The method to add them to an existing drawing depends on the type of data you've chosen to download.>> Examples of downloadables include, contour lines and DEMs both from the USGS. Point clouds are also available. Reducing them to a smaller area and lowering the point density can be beneficial (if you know how) because their original size makes them extremely difficult to work with, i.e. herky-jerky zooming and panning and even crashing.

 

If it were me, I'd download new elevation data. Manually giving contours their proper z-value is not my style.

 

Just curious, WHY do you need to move the contours to their correct elevation? Can you simply leave them as they are? 

Chicagolooper

EESignature

0 Likes
Message 11 of 19

CColozza
Contributor
Contributor

The contour data I'm working with has a far greater resolution than what I can typically get for free (2ft versus 3m). These detailed contours came from engineering firms who spent lots of time delineating the area for wetlands and habitats, as well as a LIDAR survey for topographic data; unfortunately I can't contact the original creators of the data for more info. However, I may ultimately resort to using a new set of free/public data as you've said. I need the contours to be as detailed as possible for large-scale construction projects and to calculate how much cut/fill may be required to get a flat surface for roads, smoother hills/water drainage, concrete pads, etc. This can be done using a third-party AutoCAD application, but I need the 3D elevation data either way.

0 Likes
Message 12 of 19

CADaSchtroumpf
Advisor
Advisor

If despite everything, you want to do it manually, a little code that can help.
Enter the lowest polyline, enter its elevation.
Then this value will be incremented by an integer value of 2, you just have to select the next polyline to introduce its new elevation.
Tedious work...

(defun put_elev (ent e / dxf_ent)
	(setq dxf_ent (entget ent))
	(entmod (subst (cons 38 e) (assoc 38 dxf_ent) dxf_ent))
)
(defun c:attrib_elev ( / ss elev)
	(princ "\nSelect the first polyline")
	(while (not (setq ss (ssget "_+.:E:S" '((0 . "LWPOLYLINE"))))))
	(initget 5)
	(setq elev (getint "\nGive the first elevation: "))
	(put_elev (ssname ss 0) elev)
	(princ "\nSelect next polyline")
	(while (setq ss (ssget "_+.:E:S" '((0 . "LWPOLYLINE"))))
		(setq elev (+ elev 2))
		(put_elev (ssname ss 0) elev)
		(princ "\nSelect next polyline")
	)
	(prin1)
)
0 Likes
Message 13 of 19

CADaSchtroumpf
Advisor
Advisor
Accepted solution

A little less tedious...

(defun put_elev (ent e / dxf_ent)
  (setq dxf_ent (entget ent))
  (entmod (subst (cons 38 e) (assoc 38 dxf_ent) dxf_ent))
)
(defun c:attrib_elev ( / first pt1 elev snd pt2 tmp ob2 ss n e1 lst_pt l_d class l_z pt_class)
  (while (not (setq first (entsel "\nSelect the first lowest polyline"))))
  (setq pt1 (vlax-curve-getClosestPointTo (car first) (cadr first) T))
  (initget 5)
  (setq elev (getint "\nGive the first elevation: "))
  (while (not (setq snd (entsel "\nSelect the second hightest polyline"))))
  (setq pt2 (vlax-curve-getClosestPointTo (car snd) (cadr snd) T))
  (entmake (list '(0 . "LINE") (cons 10 pt1) (cons 11 pt2)))
  (setq
    tmp (entlast)
    ob2 (vlax-ename->vla-object tmp)
    ss (ssget "_F" (list pt1 pt2) '((0 . "LWPOLYLINE")))
  )
  (cond
    (ss
      (repeat (setq n (sslength ss))
        (setq
          e1 (ssname ss (setq n (1- n)))
          lst_pt (cons (vlax-invoke (vlax-ename->vla-object e1) 'intersectwith ob2 acextendnone) lst_pt)
        )
      )
      (entdel tmp)
      (setq
        lst_pt (cons pt1 (append lst_pt (list pt2)))
        l_d (mapcar '(lambda (x) (distance pt1 x)) lst_pt)
        class (vl-sort l_d '<)
      )
      (while class
        (setq
          pt_class (cons (nth (vl-position (car class) l_d) lst_pt) pt_class)
          l_z (cons elev l_z)
          elev (+ elev 2)
          class (cdr class)
        )
      )
      (mapcar
        '(lambda (x y)
          (put_elev (car (nentselp x)) y)
        )
        pt_class
        l_z
      )
    )
  )
  (prin1)
)
Message 14 of 19

ChicagoLooper
Mentor
Mentor

@CColozza 

What's the nearest 'major' city, state to your site? 

 

Chicagolooper

EESignature

0 Likes
Message 15 of 19

CColozza
Contributor
Contributor

I dropped this into a .LSP and it made things much faster for me! I had to do a little tweaking for my specific use case but this was much easier than using brute force.

0 Likes
Message 16 of 19

PowerCAD98
Contributor
Contributor

I am having same issue.  Received shp files for new contour data from county.  When I bring in the shp files the polylines are at zero elevation even though there is a field for elevation.  Is there a way to import to c3d so the polylines take the elevation?  I attached one of the contour tiles for reference.  We are in NAD83 California State Planes, Zone II, US Foot coordinates.

0 Likes
Message 17 of 19

Pointdump
Consultant
Consultant

Hi Yvonne,
Read >>>Here<<< and watch >>>Here<<<. The video is 34 minutes well spent.
Dave

Dave Stoll
Las Vegas, Nevada

EESignature

64GB DDR4 2400MHz ECC SoDIMM / 1TB SSD
NVIDIA Quadro P5000 16GB
Windows 10 Pro 64 / Civil 3D 2025
0 Likes
Message 18 of 19

Pointdump
Consultant
Consultant

Here's another way. Easier, but wonky sometimes:

 

SurfFromGISData_1.png

 

Dave Stoll
Las Vegas, Nevada

EESignature

64GB DDR4 2400MHz ECC SoDIMM / 1TB SSD
NVIDIA Quadro P5000 16GB
Windows 10 Pro 64 / Civil 3D 2025
0 Likes
Message 19 of 19

CColozza
Contributor
Contributor

Dave,

 

Unfortunately, I posed this question coming from AutoCAD Map 3D, not Civil 3D. I understand that Civil 3D has these types of features already built in but it seems Map 3D does not. I (and my team) have ultimately decided to simply go back to the data source and ask that contour lines be provided with correct elevation data. If the original data provider is unreachable as I've mentioned in previous posts here, then I'll simply move on to finding other contour data. At the scale we're working with, and possibly @PowerCAD98 too, it makes more business sense that my time be spent elsewhere, and obtaining a Civil 3D license for just this feature doesn't make much sense either.

 

Best,

 

CColozza