# Thread: distance and elevation routine

1. ## distance and elevation routine

Registered forum members do not see this ad.

Hi guys,
Long time ago ,I have written this lisp routine,
This routine inputs a reference points coordinates, elevation and distance values from screen. It calculates several new points elevation and distance values and writes their elevation and distance values on screen.

Can anyone help me compiling this routine in to vba code

(defun C()
;We define the reference point
(command "osnap" "int")
(setq prop (getpoint "Define the reference point:"))
(setq propx (car prop))
(setq n 100)
;We define the reference point elevation
(setq ropkot1 (entget (setq ropkot (car (entsel "\n Define the reference point elevation:")))))
(setq ropkot2 (cdr (assoc 1 ropkot1)))
(setq ropkoti (atof ropkot2))
;We define the reference point distance
(setq ropmes1 (entget (setq ropmes (car (entsel "\n Define the reference point distance:")))))
(setq ropmes2 (cdr (assoc 1 ropmes1)))
(setq ropmesi (atof ropmes2))

;We pick up the new point
(repeat n
(command "osnap" "end")
(setq p1 (getpoint "Define new point:"))

(setq p1x (car p1))

(command "osnap" "none")
(command "color" "white")
(command "line" (list p1x p1y) (list (+ p1x 1.575) (+ p1y 2.1)) "")
(command "line" (list (+ p1x 1.575) (+ p1y 2.1)) (list (- p1x 1.575) (+ p1y 2.1)) "")
(command "line" (list (- p1x 1.575) (+ p1y 2.1)) (list p1x p1y) "")
(setq m1 (- p1x propx))
(if (< m1 0) (setq mesafe (+ ropmesi (/ (abs m1) 10))) (setq mesafe (- ropmesi (/ (abs m1) 10))))

(setq kot (+ ropkoti (/ (- p1y propy ) 10)))
(command "text" (list (- p1x 3.0) (+ p1y 2.5)) 1.8 0 (rtos kot 2 2))
(command "text" (list (+ p1x 0.75) (- p1y 7)) 1.8 90 (rtos (abs mesafe) 2 2))

)

Code:
`Your Code Here`

3. Registered forum members do not see this ad.

Why convert it if it works ? You can run a lisp from VBA code if thats the problem. Just find some VBA code examples you should be able to work it out.

Code:
```Dim basepnt, pt1, pt2, pt3 As Variant
basepnt = ThisDrawing.Utility.GetPoint(, " Pick PIT center ")
ptxtx1 = CStr(FormatNumber(basepnt(0), 3))
ptxty1 = CStr(FormatNumber(basepnt(1), 3))
pt1 = ThisDrawing.Utility.GetPoint(, " Pick 1st point ")```