# Thread: LOOKING FOR A LISP ROUTINE

1. Login to Give a bone

## LOOKING FOR A LISP ROUTINE

I am currently working with LDD. I'm not sure if one exists, or how to go about creating one, but I'm looking for a lisp routine that will interpolate an elevation. It would need to work as such: You would be promted to select a point, input an elevation for that point, select a second point, then input an elevation for that point. The lisp would calculate the slope based upon the 2 elevations and the distance obtained from the 2 selection points. Then you would be promted to select a point in between those 2 original points, and the lisp would calculate the elevation for you based upon the obtained slope. This routine would be a tremendous help in obtaining proposed spot grades for a proposed grading plan.

Thank You,
Chris Bird

2. Login to Give a bone

## Re: LOOKING FOR A LISP ROUTINE

Do you want to do this without creating LDT points?

3. Login to Give a bone

## Re: LOOKING FOR A LISP ROUTINE

Yes if at all possible. If not, then I will find a work around.

4. Login to Give a bone

## Re: LOOKING FOR A LISP ROUTINE

Do you want to pick 2 actual POINT entities?
Could you pick a single 3d LINE entity instead?

Is your 3rd point always going to be on the line defined by the first two points, or will the 3rd point form a triangle?
Are curves a factor, or will this always be three points on a line?

5. Login to Give a bone

## Re: LOOKING FOR A LISP ROUTINE

-I do not want to pick 2 point entities.
-I could pick a single 3d line instead if it gave me the option to input the elevation for each end of the line.
-The 3rd point will always be on the line and not form a triangle.
-It would be nice if it could work with curves as well, such as a 3d polyline with a curve. But I know that adding curves tends to complicate things. So to keep it simple and easy a straight line would work.

6. Login to Give a bone

## Re: LOOKING FOR A LISP ROUTINE

Originally Posted by INTELLIBIRD2
-I do not want to pick 2 point entities.
-I could pick a single 3d line instead if it gave me the option to input the elevation for each end of the line.
-The 3rd point will always be on the line and not form a triangle.
-It would be nice if it could work with curves as well, such as a 3d polyline with a curve. But I know that adding curves tends to complicate things. So to keep it simple and easy a straight line would work.
3D Polylines do not have curves.

7. Login to Give a bone

## Re: LOOKING FOR A LISP ROUTINE

Assuming the elevation changes are linear and run perpendicular to a line between the first
and second picked points this will return an elevation for the third picked point.

Code:
```(defun c:test (/ p1 p2 p3 p4 el1 el2 el3 d12 vecs tepPt deltaE deltaE3)
(and  (setq p1 (getpoint "\nPick First point: "))
(setq el1 (getdist "\nEnter elevation."))
(setq p2 (getpoint p1 "\nPick Second point: "))
(setq el2 (getdist "\nEnter elevation."))
(setq deltaE (- el2 el1)
d12 (distance p1 p2))
(while (setq p3 (getpoint "\nPick point for elevation: "))
(redraw)
(grvecs (list 1 p1 p3 p3 p2))
(setq tmpPt (polar p3 (+ (/ pi 2) (angle p1 p2)) 10.0))
(setq p4 (inters p1 p2 p3 tmpPt nil))
(setq deltaE3 (*(/ (distance p1 p4) (distance p1 p2))deltaE))
(if (> (distance p2 p4) d12)
(setq el3 (- el1 deltaE3))
(setq el3 (+ el1 deltaE3))
)
(print (strcat "Elevation at point is " (rtos el3)))
)
)
(princ)
)```
PS Use at your own risk. Testing is recommended.

8. Login to Give a bone

## Re: LOOKING FOR A LISP ROUTINE

Thank you, Thank you, Thank you.
Works Great!

9. Login to Give a bone

## Re: LOOKING FOR A LISP ROUTINE

I have to agree, this is a great little routine.

I never thought of doing this, but it will definitely save me time. I like working smarter, not harder.

10. Login to Give a bone

## Re: LOOKING FOR A LISP ROUTINE

Cab, when I first saw the question I thought this would be a simple answer of using the 3d lines commands with the transition command or something like that but I thought I'd try out the list anyways......actually it is pretty useful. I'd still probably use 3d lines for most of my proposed grading design since they are needed for building surfaces anyway but this could come in handy when "playing around" with a design and trying to come up with better ideas.