View Full Version : LOOKING FOR A LISP ROUTINE
INTELLIBIRD2
2007-10-22, 06:03 PM
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
rkmcswain
2007-10-22, 07:40 PM
Do you want to do this without creating LDT points?
INTELLIBIRD2
2007-10-22, 08:32 PM
Yes if at all possible. If not, then I will find a work around.
rkmcswain
2007-10-23, 03:53 AM
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?
INTELLIBIRD2
2007-10-23, 02:24 PM
-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.
-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.
CAB2k
2007-10-25, 10:44 PM
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.
(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.
INTELLIBIRD2
2007-10-29, 04:11 PM
Thank you, Thank you, Thank you.
Works Great!
margaretl
2007-10-29, 09:53 PM
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.
imblueflies
2007-11-02, 08:54 PM
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.
Thanks for your work.
CAB2k
2007-11-02, 09:50 PM
Glad you all found a use for it.:)
CADDmanVA
2007-11-03, 01:48 AM
After seeing what you can do with LISP, when are you going to start teaching Cab? I'd sign up for a series of classes if you taught them. I've always wanted to learn, but the books I've found don't seem to do it.
CAB2k
2007-11-03, 04:43 AM
Thanks for the kind words.
There are lots of folks here that can teach lisp. I find I learn best by doing. Start a lisp & you will
get plenty of help & tips on how to compose your routine.
Be sure to read the two sticky topics in this forum. Lot of good stuff there.
ron_09812001
2007-11-03, 07:25 AM
............. run perpendicular to a line between the first
and second picked points this will return an elevation for the third picked point.
.
if you picked a point that is non collinear with the first 2 points, does it assume the elevation of the point of intersection or does it have a slope also based on the first slope calculated?
cab, what if my 3rd point which is running perpendicular between the first and second picked points has a different slope from the point of intersection?this would be useful in my routine. elevations in roads are given in road center but what im after is the elevation above my water pipeline, there is a change in slope because the road center is always higher compared to areas near the curb/gutter.
-wizman07
ron_09812001
2007-11-03, 11:53 AM
here's a simple drawing with regards to my query above..thanks
CAB2k
2007-11-03, 01:19 PM
This is an image for my routine above.
CAB2k
2007-11-03, 02:55 PM
if you picked a point that is non collinear with the first 2 points, does it assume the elevation of the point of intersection or does it have a slope also based on the first slope calculated?
cab, what if my 3rd point which is running perpendicular between the first and second picked points has a different slope from the point of intersection?this would be useful in my routine. elevations in roads are given in road center but what im after is the elevation above my water pipeline, there is a change in slope because the road center is always higher compared to areas near the curb/gutter.
-wizman07
See if this will work for your needs.
;; CAB 11.3.07
;; This one allows for a side slope
;; Pick Start & End points of main run & enter elevations.
;; Enter Lateral slope percentage. Example -2 = down 2%
;; Pick lateral point & routine calculates the elevation at that point
(defun c:SideSlope (/ p1 p2 p3 p4 el1 el2 el3 el4 d12 vecs tmpPt deltaE deltaE3
slope slo LatDis)
(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 slope (getdist "\nEnter lateral slope %. Example -2 = down 2%"))
(setq deltaE (- el2 el1)
d12 (distance p1 p2)
slo (/ slope 100.)
)
(while (setq p3 (getpoint "\nPick point for elevation: "))
(redraw)
(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))
)
(setq LatDis (distance p3 p4) ; lateral Distance
el4 (+ (* LatDis slo) el3)
)
(grvecs (list 1 p1 p2 p3 p4))
(print (strcat "Elevation at intercept is " (rtos el3 2)))
(print (strcat "Elevation at point is " (rtos el4 2)))
)
)
(princ)
)
CAB2k
2007-11-03, 02:56 PM
Forgot to attach my picture.
ron_09812001
2007-11-03, 03:37 PM
i'll run few samples tomorrow, i'll let you know of my feedback,
many thanks CAB
ron_09812001
2007-11-03, 04:11 PM
i ran a quick math here cab and its perfect..thank you very much.its a great use for me.
but on the other hand, not all roads are straight, some having loops and round abouts, i may still do it manually when it comes to those portions or if u have any idea about that..
more power.
CAB2k
2007-11-03, 04:26 PM
If there is a center line object you can program to select that but you would stil need the elevations of that center line.
BoKirra
2007-11-06, 12:13 AM
I do agree all your thanks to CAB2k, as he is a great helper.
:beer: :beer: :beer: :beer: :beer:
INTELLIBIRD2
2007-11-06, 07:07 PM
I just looked at this thread since you had created the first lisp. I have tried the modified one and it works fantastic. With one exception, it seems to leave points behind after the command is finished.
Is this a simple thing that I can modify?
CAB2k
2007-11-06, 08:11 PM
Oops, left a line of code I used during testing. I fixed the lisp posted.
In your copy remove this line of code:
(command "point" "non" p4)
INTELLIBIRD2
2007-11-07, 02:49 PM
That works.
And Again, I can't thank you enough. This routine has made a big difference in my everyday work.
-Chris Bird
Bohler Engineering Inc.
Center Valley PA
CAB2k
2007-11-07, 03:06 PM
Chris,
Happy i could help.
ron_09812001
2007-11-08, 04:49 AM
we finished a 2 weeks work in just 2 days, thanks again cab.
CAB2k
2007-11-08, 03:32 PM
Hey, That's great to hear.:mrgreen:
vBulletin® v3.6.7, Copyright ©2000-2009, Jelsoft Enterprises Ltd.