Author Topic: inexplicable jumps in z values using SetElev lisp routine.  (Read 3604 times)

0 Members and 1 Guest are viewing this topic.

Aquarianking

  • Guest
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))
    )

)


mjfarrell

  • Seagull
  • Posts: 14444
  • Every Student their own Lesson
Re: inexplicable jumps in z values using SetElev lisp routine.
« Reply #1 on: July 22, 2015, 08:42:46 AM »
IF you got those contours from a shp file they DO have z values however they are embedded in the Object Data attached to the contours polylines.


You would want to do the following

Use MAPIMPORT
 get that shape file
be sure to click on the DATA column and allow map to bring in the object data table

After import if you select a contour and look at the properties of it you will see and OD:  entry at the very bottom it will show you the elevation information

Save this file


Open new session or open your design file....
Attache the above saved file with map, query in the contours
use Alter properties function
toggle ELEVATION, using the Expression button to ttell it to use the Object Properties assigned to those contour lines....

They will now be at proper elevation to use in your terrain model
Be your Best


Michael Farrell
http://primeservicesglobal.com/

jvillarreal

  • Bull Frog
  • Posts: 332
Re: inexplicable jumps in z values using SetElev lisp routine.
« Reply #2 on: July 22, 2015, 09:16:47 AM »
Or, after importing your shape file and including your object data, you can access that data with lisp to elevate your contours.
Enjoy.

Aquarianking

  • Guest
Re: inexplicable jumps in z values using SetElev lisp routine.
« Reply #3 on: July 22, 2015, 11:11:35 AM »
Thank you for the suggestions. I have to apologize for not mentioning that I have AutoCAD not AutoCAD civil 3d. I will keep this suggestion in mind because I will be learning Civil later this month.
I will have to see if there is a way to follow this process in AutoCAD?
« Last Edit: July 22, 2015, 11:19:59 AM by Aquarianking »

ronjonp

  • Needs a day job
  • Posts: 7529
Re: inexplicable jumps in z values using SetElev lisp routine.
« Reply #4 on: July 22, 2015, 11:19:28 AM »
Welcome to The Swamp :) . Maybe if you post your sample drawing where this is not working it would help to figure this out.

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC