sigi-19 Posted April 1, 2014 Share Posted April 1, 2014 I'm looking for a lisp routine that will difference in elevation between two points. It would need to work as such: 1: select a point 1, 2: select point 2. than routin will Calculate the difference between (z)point 1 to (z) point 2 and Write the result Where the user Request Quote Link to comment Share on other sites More sharing options...
BIGAL Posted April 2, 2014 Share Posted April 2, 2014 KISS principle (setq Pt1 (getpoint)) (setq pt2 (getpoint)) (setq X1 (nth 0 pt1)) (setq y1 (nth 1 pt1)) (setq Z1 (nth 2 pt1 )) (setq X2 (nth 0 pt1)) (setq y2 (nth 1 pt1)) (setq Z2 (nth 2 pt1 )) (princ (- z2 z1)) Quote Link to comment Share on other sites More sharing options...
sigi-19 Posted April 2, 2014 Author Share Posted April 2, 2014 Thanks Thread Thank you I made some changes The third step is to write the answer on the drawing What is the correct command for this? (defun c:Z-h () (setq Pt1 (getpoint)) (setq pt2 (getpoint)) (setq X1 (nth 0 Pt1)) (setq y1 (nth 1 Pt1)) (setq Z1 (nth 2 Pt1)) (setq X2 (nth 0 pt2)) (setq y2 (nth 1 pt2)) (setq Z2 (nth 2 pt2)) (princ (- z1 z2)) (princ) ;finish cleanly ) ;end of defun sigi-19 Quote Link to comment Share on other sites More sharing options...
MSasu Posted April 2, 2014 Share Posted April 2, 2014 Just add this line (presuming your current text style doesn't have imposed height): ... (princ (- z1 z2)) [color=blue](command "_TEXT" pause "" "" (rtos (- z1 z2)))[/color] (princ) ... Please edit your previous post and add the required code tags. Quote Link to comment Share on other sites More sharing options...
sigi-19 Posted April 2, 2014 Author Share Posted April 2, 2014 hi i insert the code (defun c:Z-h1 () (setq Pt1 (getpoint)) (setq pt2 (getpoint)) (setq X1 (nth 0 Pt1)) (setq y1 (nth 1 Pt1)) (setq Z1 (nth 2 Pt1)) (setq X2 (nth 0 pt2)) (setq y2 (nth 1 pt2)) (setq Z2 (nth 2 pt2)) (princ (- z1 z2)) (command "_TEXT" pause "20" "0" (rtos (- z1 z2))) ;finish cleanly ;end of defun But I got an error message where I went wrongerror: ; error: malformed list on input thanks for your help Quote Link to comment Share on other sites More sharing options...
sigi-19 Posted April 2, 2014 Author Share Posted April 2, 2014 Sorry I found what the problem was I was missing the mark ) in the end thanks for your help have a Quote Link to comment Share on other sites More sharing options...
MSasu Posted April 2, 2014 Share Posted April 2, 2014 Sigi-19, good to hear that works as expected! Again, please edit your previous posts and add the required code tags. Quote Link to comment Share on other sites More sharing options...
grifflee Posted February 21, 2019 Share Posted February 21, 2019 Sigi-19 could I be cheeky and ask for a copy of this Lisp routine please? It's just what I'm looking for. Quote Link to comment Share on other sites More sharing options...
Robert89 Posted February 21, 2019 Share Posted February 21, 2019 (edited) The lisp below is what I made to crudely check overlapping vertical alignments (plotted as 3d-polylines). (defun c:Diz (/ pt1 pt2 gss txt_rot ) (setq pt1 (getpoint "\nSelect first point: ")) (setq pt2 (getpoint "\nSelect second point: ")) (setq gss (ssadd)) (setq txt_rot (if (> (distance (list (car pt1)(cadr pt1))(list (car pt2)(cadr pt2))) 0.1) (+ (angle pt1 pt2)(* PI 1.5)) 0)) (entmake (list '(0 . "line") (cons 10 pt1) (cons 11 pt2) ) ) (ssadd (entlast) gss) ; add entity to selection set (entmake (list '(0 . "text") (cons 1 (strcat "dZ= "(rtos (abs(*(- (caddr pt1)(caddr pt2))1000)) 2 0)"mm")) (cons 10 (polar ent1_pt offset_angle (/ Dist_xy 2))) (cons 11 (polar ent1_pt offset_angle (/ Dist_xy 2))) (cons 10 (list (/(+ (car pt1)(car pt2))2)(/(+ (cadr pt1)(cadr pt2))2)))(cons 11 (list (/(+ (car pt1)(car pt2))2)(/(+ (cadr pt1)(cadr pt2))2))) (cons 50 txt_rot) '(40 . 1.0) '(72 . 0) '(73 . 2) ) ) (ssadd (entlast) gss) ; add entity to selection set (command "_.group" "c" "*" "" gss "") ; create group from selection set (princ) ) Edited February 21, 2019 by Robert89 Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted February 21, 2019 Share Posted February 21, 2019 8 hours ago, grifflee said: Sigi-19 could I be cheeky and ask for a copy of this Lisp routine please? It's just what I'm looking for. Why not use the standard DIST command for this purpose? 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.