leonucadomi Posted August 13 Posted August 13 (edited) hello all: I found this good routine here, (defun c:cd () (setvar "cmdecho" 0) (graphscr) (setq p1 (getpoint "\nPick start point ") p2 (getpoint p1 "\nPick next point ") d1 (distance p1 p2) prdist (strcat "\nDistance: " (rtos d1 2 0)) ) (princ prdist) (setq p3 (getpoint p2 "\nPick next point or RETURN if done ")) (while p3 (setq d0 (distance p2 p3) d1 (+ (distance p2 p3) d1) p2 p3 prdist (strcat "\nDistance: " (rtos d0 2 0) ", Cumulative distance: " (rtos d1 2 0)) ) (princ prdist) (setq p3 (getpoint p2 "\nPick Next Point ")) ) (setq cumd (strcat "Cumulative distance --> " (rtos d1 2 0))) (prompt cumd) (princ) ) I hope someone can help thanks Edited August 13 by leonucadomi Quote
Tsuky Posted August 13 Posted August 13 With this modification? (defun c:cd ( / p1 p2 d1 prdist p3 d0 cumd) (setvar "cmdecho" 0) (graphscr) (setq p1 (getpoint "\nPick start point ") p2 (getpoint p1 "\nPick next point ") d1 (abs (- (car p2) (car p1))) prdist (strcat "\nDistance: " (rtos d1 2 0)) ) (princ prdist) (setq p3 (getpoint p2 "\nPick next point or RETURN if done ")) (while p3 (setq d0 (abs (- (car p3) (car p2))) d1 (+ (abs (- (car p3) (car p2))) d1) p2 p3 prdist (strcat "\nDistance: " (rtos d0 2 0) ", Cumulative distance: " (rtos d1 2 0)) ) (princ prdist) (setq p3 (getpoint p2 "\nPick Next Point ")) ) (setq cumd (strcat "Cumulative distance --> " (rtos d1 2 0))) (prompt cumd) (princ) ) 1 Quote
BIGAL Posted August 14 Posted August 14 Why not (setq p3 (getpoint p2 "\nPick next point or RETURN if done ")) (while p3 (while (setq p3 (getpoint p2 "\nPick next point or RETURN if done ")) Quote
ronjonp Posted August 14 Posted August 14 (edited) This is what I use: (defun c:mdist (/ n p1 p2 d v) (setq d 0 n 0) (while (and (or p1 (setq p1 (getpoint "\nSpecify start point: "))) (setq p2 (getpoint p1 "\nSpecify next point: ")) ) (setq d (+ d (distance p1 p2)) v (append v (list (setq n (1+ n)) p1 p2)) p1 p2 ) (grvecs v) (princ (strcat "\nRunning total is " (rtos d))) ) ) Edited August 15 by ronjonp 1 Quote
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.