cheatacad11 Posted May 5, 2015 Share Posted May 5, 2015 Hello Guys. I want a simple LSP and I need all your help. Below is my question: I want a LSP to help me calculate the angle by capturing the distance of a st. line while im inputting the two mpd level of the two end points. Example: 1.)It asks me to pick a line (with length d) 2.)It asks me to input the higher mpd (h1) 3.)It asks me to input the lower mpd (h2) 4.)It calculates the inclined angle by this formula (tan -1(h1-h2)/d) 5.)It asks me to locate the calculated angle. Thanks alot:) Quote Link to comment Share on other sites More sharing options...
cheatacad11 Posted May 6, 2015 Author Share Posted May 6, 2015 bump^Please help Quote Link to comment Share on other sites More sharing options...
ymg3 Posted May 6, 2015 Share Posted May 6, 2015 What's an mpd ?? Quote Link to comment Share on other sites More sharing options...
eldon Posted May 6, 2015 Share Posted May 6, 2015 Just a pure guess:- "In Hong Kong mPD is a surveying term meaning "metres above Principle Datum" and refers to height of 1.230m below average sea level" Quote Link to comment Share on other sites More sharing options...
ymg3 Posted May 6, 2015 Share Posted May 6, 2015 First Thanks! Eldon Cheatacad, This kind of thing must have been done a thousand times and you could find it on this forum or others. But here goes, with a few useful function: defun c:test () (setq txh (getvar 'TEXTSIZE)) (setq p1 (getpoint p1 "\nPick Point: ") z1 (getreal "\Enter Elevation: ") ) (while p1 (setq p2 (getpoint p1 "\nPick Next Point: ") z2 (getreal "\Enter Elevation: ") p1 (list (car p1) (cadr p1) z1) p2 (list (car p2) (cadr p2) z2) an (angle p1 p2) mid (midpoint p1 p2) ;; Remove following statement if lines are existing ; en (entmakex (list (cons 0 "LINE") (cons 10 p1) (cons 11 p2) '(210 0.0 0.0 1.0)) ) ) (vl-cmdf "_TEXT" "_J" "_BC" mid txth (rtd an) (angtodms an 0)) (setq p1 p2 z1 z2) ) (princ) ) ;; Radian to Decimal Degree ; (defun rtd (a) (* 180.0 (/ a pi))) ;; ; ;; midpoint ; ;; ; ;; Returns The Midpoint Between Point a and Point b ; ;; ; (defun midpoint (a b) (mapcar '(lambda (a b) (* (+ a b) 0.5)) a b) ) ; angtodms by ymg ; ; Given an angle in radian and number of decimal after the seconds ; ; Returns a string formatted in Degree Minutes and Seconds, ; ; with proper symblol for degree and leading 0 on the minutes and seconds ; ; 0°00'00.0" 271°05'06.3" etc. ; (defun angtodms (a prec /) (setq a (angtos a 1 (+ prec 4))) (while (< (vl-string-position (ascii "d") a) 3) (setq a (strcat " " a)) ) (if (< (vl-string-position (ascii "'") a) 6) (setq a (strcat (substr a 1 4) "0" (substr a 5))) ) (if (< (vl-string-position (ascii "\"") a) (+ 9 (if (= 0 prec) 0 (1+ prec)))) (setq a (strcat (substr a 1 7) "0" (substr a )) ) (vl-string-subst "°" "d" a) ) Quote Link to comment Share on other sites More sharing options...
Lazer Posted May 6, 2015 Share Posted May 6, 2015 Welcome to the forum cheatacad11, please do not start a thread with HELP! and no need to BUMP (it does not help other finding answers to posts) and no need to bump a post. I removed the HELP! from your title. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted May 6, 2015 Share Posted May 6, 2015 But here goes, with a few useful function: ; angtodms by ymg ; ; Given an angle in radian and number of decimal after the seconds ; ; Returns a string formatted in Degree Minutes and Seconds, ; ; with proper symblol for degree and leading 0 on the minutes and seconds ; ; 0°00'00.0" 271°05'06.3" etc. ; (defun angtodms (a prec /) (setq a (angtos a 1 (+ prec 4))) (while (< (vl-string-position (ascii "d") a) 3) (setq a (strcat " " a)) ) (if (< (vl-string-position (ascii "'") a) 6) (setq a (strcat (substr a 1 4) "0" (substr a 5))) ) (if (< (vl-string-position (ascii "\"") a) (+ 9 (if (= 0 prec) 0 (1+ prec)))) (setq a (strcat (substr a 1 7) "0" (substr a )) ) (vl-string-subst "°" "d" a) ) Just for fun... Perhaps another way to write your 'angtodms' function: (defun ang->dms ( ang prc ) ( (lambda ( f / s p ) (setq s (angtos ang 1 (+ prc 4)) p (vl-string-position 100 s) ) (strcat (substr s 1 p) "°" (f (substr s (+ 2 p)) '(39 46))) ) (lambda ( a b / p ) (cond ( (null b) a) ( (setq p (vl-string-position (car b) a)) (strcat (substr (strcat "00" (substr a 1 (1+ p))) (1+ p)) (f (substr a (+ p 2)) (cdr b))) ) ( (f a (cdr b))) ) ) ) ) If two leading zeros for the degree value was acceptable, the above could become: (defun ang->dms ( ang prc ) ( (lambda ( f ) (vl-string-translate "d" "°" (f (angtos ang 1 (+ prc 4)) '(100 39 46)))) (lambda ( a b / p ) (cond ( (null b) a) ( (setq p (vl-string-position (car b) a)) (strcat (substr (strcat "00" (substr a 1 (1+ p))) (1+ p)) (f (substr a (+ p 2)) (cdr b))) ) ( (f a (cdr b))) ) ) ) ) Quote Link to comment Share on other sites More sharing options...
ymg3 Posted May 6, 2015 Share Posted May 6, 2015 Lee, As they say, "There is many ways to skin a Cat". Yours is a bit more concise. Two leading zeros is rarely used in surveying. I have yet to develop the lambda habit, they certainly are useful. ymg Quote Link to comment Share on other sites More sharing options...
eldon Posted May 7, 2015 Share Posted May 7, 2015 .......Two leading zeros is rarely used in surveying.... Only by those who remember writing angles manually. One always put in leading and trailing zeroes to fully populate the format DDD-MM-SS. Quote Link to comment Share on other sites More sharing options...
ymg3 Posted May 7, 2015 Share Posted May 7, 2015 eldon, Don't know about that one, maybe I am getting old. But to me 0° 04' 23" is more readable than 000° 04' 23" ymg Quote Link to comment Share on other sites More sharing options...
eldon Posted May 7, 2015 Share Posted May 7, 2015 But to me 0° 04' 23" is more readable than 000° 04' 23" When reading hand written data back in the office, 0-04-23, could be read as 004-23-00. It is all about trying to minimise potential errors. Quote Link to comment Share on other sites More sharing options...
cheatacad11 Posted May 7, 2015 Author Share Posted May 7, 2015 thank you guys:) I worked it out last night:) I just modify one .lsp from another website you may have a view from the attached file:) by the way, i love u guys:) u guys r really nice:) sl.lsp Quote Link to comment Share on other sites More sharing options...
ymg3 Posted May 7, 2015 Share Posted May 7, 2015 eldon, You are right that I did a lot of handwriting angle from reading in a theodolite. For our part we would read it as 0-4-23 Whatever floats one's boat. ymg Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.