I found this LISP routine on this fourm a while back. I have contours from ArcGIS shape file without z values. This LISP routine has worked well until today. I decided to align and scale the contours after realizing that the area was 1/5 the size i need it to be. After resizing the topographic area to 5 miles wide (from a very stuffy 1 mile measurment) the LISP routine is assigning z values in a way that is difficult to control. Asking for the selection fence pline (which defines from lowest to highest which contours I want to work with), enter the lowest elevation-->0, enter contour interval -->20 … then checking the contours I find the lowest to be z value 0 followed by 20 then 80 then 120. Not sure how to fix this.
(defun c:SetELev()
(setq Ent1 (car (entsel "\nSelect Fence Pline "))
LowestEl (getreal "\nEnter Lowest Elevation ")
ContInter (getreal "\nEnter Contour Interval ")
LastVert (fix (vlax-curve-getEndParam Ent1))
VertList (list (vlax-curve-getPointAtParam Ent1 0))
count 1
oEnt1 (vlax-ename->vla-object Ent1)
)
(repeat LastVert
(setq VertList (append VertList (list (vlax-curve-GetPointAtParam Ent1 Count)))
Count (+ Count 1)
)
)
(setq ss1 (ssget "F" VertList)
Count 0
CrossPtList nil
ss1 (ssdel Ent1 ss1)
);setq
(repeat (sslength ss1)
(if CrossPtList
(setq CrossPtList (append CrossPtList (list (last (last (last (ssnamex ss1 count) )))) ) )
(setq CrossPtList (list (last (last (last (ssnamex ss1 count))))))
);if
(setq Count (+ count 1))
);repeat
(setq DistList nil
Count 0
CurrElev LowestEl
);setq
(repeat (length CrossPtList)
(if DistList
(setq DistList (append DistList (list (vlax-curve-GetDistAtPoint Ent1 (vlax-curve-getClosestPointTo Ent1 (nth count CrossPtList))))))
(setq DistList (list (vlax-curve-GetDistAtPoint Ent1 (vlax-curve-getClosestPointTo Ent1 (nth count CrossPtList)))))
);if
(setq count (+ 1 count))
);repeat
(setq DistListSortI (vl-sort-i DistList '<)
count 0
);setq
(repeat (length DistListSortI)
(setq currEnt (ssname ss1 (nth count DistListSortI))
currElev (+ LowestEl (* ContInter count))
CurrEntList (entget currEnt)
;change the elevation
CurrEntList (subst (cons 38 currElev) (assoc 38 CurrEntList) CurrEntList)
;change the color so we can keep track
colorIndex 6
CurrEntList (subst (cons 62 colorIndex) (assoc 62 CurrEntList) CurrEntList)
);setq
(entmod CurrEntList)
(setq count (+ count 1))
)
)