Author Topic: How can i find elevation on line  (Read 2226 times)

0 Members and 1 Guest are viewing this topic.

scorpion76

  • Guest
How can i find elevation on line
« on: July 31, 2018, 11:05:47 AM »
Dear friends, hi from Turkey
I m a civil engineer, and i want to learn about autolisp. When i surf i find this forum. I hope i can learn more.

For example we have a line, start z of line 10,00 end z of line 14,00 .
How can we calculate with lisp, 5 mt later z ?
How must be autolisp code?
Thanks a lot.

I hope i can understand. :cry2:

tombu

  • Bull Frog
  • Posts: 289
  • ByLayer=>Not0
Re: How can i find elevation on line
« Reply #1 on: July 31, 2018, 11:15:32 AM »
One quick way would be to break the line at the endpoints of the vertical lines.  Selecting a line and hovering over the endpoints displays the elevation in the coordinates display.
Tom Beauford P.S.M.
Leon County FL Public Works - Windows 7 64 bit AutoCAD Civil 3D

scorpion76

  • Guest
Re: How can i find elevation on line
« Reply #2 on: July 31, 2018, 11:22:02 AM »
Thanks for your answer but i can calculate with formula,
for example;

if i know x coordinate of z1 ,

z1=10+[(14-10)/25 * Xz1]
z1=10+[(14-10)/25*5]=10,80

but i want to calculate with lisp, lisp must read lenght of between point "a" and "z1"

rkmcswain

  • Swamp Rat
  • Posts: 978
Re: How can i find elevation on line
« Reply #3 on: July 31, 2018, 11:38:04 AM »
If you know the elevation at both ends, and you know the total length, then you can calculate the slope.
Then just multiply the slope X the distance from the unknown point to one of the two known end points
Then add or subtract that value to/from a known point.

For example:
Pt1 = 5,5,5
Pt2 = 5,15,8
Pt3 = 5,7.81245,?

The Hz distance between Pt1 and Pt2 = 10
The elevation diff between Pt1 and Pt2 = 3
The slope between Pt1 and Pt2 = 30%
The Hz distance between Pt1 and Pt3 = 2.81245
2.81245 * 30% = 0.843735
So the Z value of Pt3 = 5.843735


VovKa

  • Water Moccasin
  • Posts: 1629
  • Ukraine

scorpion76

  • Guest

efernal

  • Bull Frog
  • Posts: 206
Re: How can i find elevation on line
« Reply #6 on: August 02, 2018, 12:46:50 PM »
Code - Auto/Visual Lisp: [Select]
  1. (PROGN                                  
  2.   (SETQ xz1 5.0)
  3.   (SETQ result (+ 10 (* (/ (- 14.0 10.0) 25.0) xz1)))
  4. )
  5.  
  6. Command: (PROGN (SETQ xz1 5.0) (SETQ result (+ 10 (* (/ (- 14.0 10.0) 25.0) xz1))))
  7. 10.8
  8.  
  9. (DEFUN c:scorpion76 (/ result xz1)
  10.   (WHILE (SETQ xz1 (GETREAL "\n-> Enter xz1 or ENTER for finish : "))
  11.     (SETQ result (+ 10 (* (/ (- 14.0 10.0) 25.0) xz1)))
  12.     (PRINC (STRCAT "\n-> " (RTOS xz1 2 8) " in, out " (RTOS result 2 8)))
  13.   )
  14.   (PRINC)
  15. )
  16.  
  17. Command: SCORPION76
  18.  
  19. -> Enter xz1 or ENTER for finish : 5
  20. ; reset after error
  21.  
  22. Command: SCORPION76
  23.  
  24. -> Enter xz1 or ENTER for finish : 5
  25.  
  26. -> 5 in, out 10.8
  27. -> Enter xz1 or ENTER for finish : 10
  28.  
  29. -> 10 in, out 11.6
  30. -> Enter xz1 or ENTER for finish : 12
  31.  
  32. -> 12 in, out 11.92
  33. -> Enter xz1 or ENTER for finish : 23
  34.  
  35. -> 23 in, out 13.68
  36. -> Enter xz1 or ENTER for finish : 12
  37.  
  38. -> 12 in, out 11.92
  39. -> Enter xz1 or ENTER for finish : 1
  40.  
  41. -> 1 in, out 10.16
  42. -> Enter xz1 or ENTER for finish : 0
  43.  
  44. -> 0 in, out 10
  45. -> Enter xz1 or ENTER for finish : 33
  46.  
  47. -> 33 in, out 15.28
  48. -> Enter xz1 or ENTER for finish :
  49.  
e.fernal

tombu

  • Bull Frog
  • Posts: 289
  • ByLayer=>Not0
Re: How can i find elevation on line
« Reply #7 on: August 02, 2018, 02:13:58 PM »
This lisp gives you many options including entering the new Total length you want the line to have or entering the Elevation you want the line to end at.  Only options that would change the grade would be Percent or Ratio.  Select the end of the line you want to change.
Code: [Select]
;| Change the Length of a Line|;
; BY: Tom Beauford
; BeaufordT@LeonCountyFL.gov
; Leon County Public Works Engineering
;=======================================================
(defun C:chl (/ ActDoc A pick B etype pt1 pt pt2 pt3 pt4 distold dist1 ang1 z1)
  (setq ActDoc (vla-get-ActiveDocument (vlax-get-Acad-Object)))
  (vla-StartUndoMark ActDoc)
  (setq A (entsel "\nSelect Entity: ")
     pick (osnap (cadr A) "endp")
        B (entget (car A))
    etype (cdr(assoc 0 B))
  ); setq
  (princ "\netype = ")
  (princ etype)
  (cond
    ((eq etype "LINE")
      (progn
        (setq pt1 (cdr (assoc 10 B)) pt2 (cdr (assoc 11 B)))
        (if (>(distance pt1 pick)(distance pick pt2))
         (setq pt pt1 pt1 pt2 pt2 pt)
        )
        (setq pt3 (list (car pt1)(cadr pt1)) pt4 (list (car pt2)(cadr pt2))
                  distold (distance pt3 pt4)
                  ang1 (angle pt2 pt1)
        )
        (princ "\nOld Distance=")
        (princ distold)
        (initget "Lengthen Shorten Total Elevation Percent Ratio")
        (if(= ¦¦global¦¦ nil)(setq ¦¦global¦¦ "Total"))
        (if(setq ¦¦notnil¦¦ (getkword (strcat " [Lengthen/Shorten/Total/Elevation/Percent/Ratio] <" ¦¦global¦¦ ">: ")))(setq ¦¦global¦¦ ¦¦notnil¦¦))
        (setvar "cmdecho" 0)

    (cond
      ((= ¦¦global¦¦ "Lengthen")
        (setq dist1 (+ distold (getreal "\nEnter Distance: "))
                  z1 (+(caddr pt2)(*(/ dist1 distold)(-(caddr pt1)(caddr pt2))))
        )
      ); Lengthen
      ((= ¦¦global¦¦ "Shorten")
        (setq dist1 (- distold (getreal "\nEnter Distance: "))
                  z1 (+(caddr pt2)(*(/ dist1 distold)(-(caddr pt1)(caddr pt2))))
        )
      ); Shorten
      ((= ¦¦global¦¦ "Total")
        (setq dist1 (getreal "\nEnter New Length: ")
                  z1 (+(caddr pt2)(*(/ dist1 distold)(-(caddr pt1)(caddr pt2))))
        )
      ); Total
      ((= ¦¦global¦¦ "Elevation")
        (setq z1 (getreal "\nEnter Elevation to Trim/Extend: ")
                  dist1 (*(/ distold (-(caddr pt1)(caddr pt2)))(- z1 (caddr pt2)))
          )
      ); Elevation
      ((= ¦¦global¦¦ "Percent")
        (setq z1 (+(caddr pt2)(* distold(getreal "\nEnter Slope in %: ")0.01))
                  dist1 distold
        )
      ); Percent
      ((= ¦¦global¦¦ "Ratio")
        (setq z1 (+(caddr pt2)(/ distold(getreal "\nEnter Run/Rise: ")))
                  dist1 distold
        )
      ); Ratio
    ); cond

        (setq pt1 (polar pt2 ang1 dist1)
                  pt1 (list (car pt1)(cadr pt1) z1)
        )
        (if pt (setq pt pt1 pt1 pt2 pt2 pt))
        (setq B (subst(cons 10 pt1)(assoc 10 B) B)
              B (subst(cons 11 pt2)(assoc 11 B) B)
        )
        (entmod B)
        (princ "\nOld Distance=")
        (princ distold)
        (princ ", New Distance=")
        (princ dist1)
      ); progn
    ); line
    ((or(eq etype "ARC")(eq etype "POLYLINE")(eq etype "LWPOLYLINE"))
      (progn
        (command "lengthen" pick)
      ); progn
    ); ARC, POLYLINE or LWPOLYLINE
  ); cond
  (vla-EndUndoMark ActDoc)
  (princ)
)
Tom Beauford P.S.M.
Leon County FL Public Works - Windows 7 64 bit AutoCAD Civil 3D

scorpion76

  • Guest
Re: How can i find elevation on line
« Reply #8 on: August 13, 2018, 11:26:41 AM »
Thanks for answer dear friends, i will to try for understand that codes.