thereisnotime Posted September 26, 2016 Posted September 26, 2016 A brief overview of what's going on here: user will select their points run the command once the LISP encounters a point description with "CNF" or "DEC", it places a block with text Now the next step is to grab the next 2 sequential points and get their X&Y coordinates so I can measure the distance between the two, but I'm kind of stuck on how to do that. Any help would be appreciated. (defun c:desc2 (/ ss x northng pnt eastng descr dist hndl eastng1 eastng2 northng1 northng2) (vl-load-com) (if (ssget ":S:E" '((0 . "AECC_COGO_POINT"))) (progn (vlax-for x (setq ss (vla-get-activeselectionset (vla-get-activedocument (vlax-get-acad-object)))) (setq pnt (vlax-get x 'number) eastng (vlax-get x 'easting) northng (vlax-get x 'northing) descr (vlax-get x 'rawdescription) hndl (vlax-get x 'handle) );END setq (if (= 0 (vl-string-search "DEC" descr)) (progn (command "text" "c" (list eastng northng) 0.5 0 descr) (command "_insert" "nf_shrub_decid" (list eastng northng) "" "" "") (setq pnt1 (+ 1 pnt) pnt2 (+ 2 pnt) ) );END if TRUE (progn (if (= 0 (vl-string-search "CNF" descr)) (progn (command "text" "c" (list eastng northng) 0.5 0 descr) (command "_insert" "nf_shrub_conifer" (list eastng northng) "" "" "") );END if TRUE );END if );END if FALSE );END if );END vlax-for );END progn );END if (princ) ) Quote
marko_ribar Posted September 26, 2016 Posted September 26, 2016 I don't have Civil, but based on your code, you can try something like this : (defun c:desc2 ( / ss x northng pnt eastng descr dist hndl eastng1 eastng2 northng1 northng2 pnt1 pnt2 easting1 nothing1 easting2 northing2 ) (vl-load-com) (if (ssget ":S:E" '((0 . "AECC_COGO_POINT"))) (progn (vlax-for x (setq ss (vla-get-activeselectionset (vla-get-activedocument (vlax-get-acad-object)))) (setq pnt (vlax-get x 'number) eastng (vlax-get x 'easting) northng (vlax-get x 'northing) descr (vlax-get x 'rawdescription) hndl (vlax-get x 'handle) );END setq (if (= 0 (vl-string-search "DEC" descr)) (progn (command "text" "c" (list eastng northng) 0.5 0 descr) (command "_insert" "nf_shrub_decid" (list eastng northng) "" "" "") (setq pnt1 (+ 1 pnt) pnt2 (+ 2 pnt) ) (vlax-for p ss (if (= pnt1 (vlax-get p 'number)) (progn (setq easting1 (vlax-get p 'easting)) (setq northing1 (vlax-get p 'northing)) ) ) (if (= pnt2 (vlax-get p 'number)) (progn (setq easting2 (vlax-get p 'easting)) (setq northing2 (vlax-get p 'northing)) ) ) ) );END if TRUE (progn (if (= 0 (vl-string-search "CNF" descr)) (progn (command "text" "c" (list eastng northng) 0.5 0 descr) (command "_insert" "nf_shrub_conifer" (list eastng northng) "" "" "") );END if TRUE );END if );END if FALSE );END if );END vlax-for );END progn );END if (prompt "\nDistance is : ") (princ (rtos (distance (list easting1 northing1) (list easting2 northing2)) 2 20)) (princ) ) HTH, M.R. Quote
BIGAL Posted September 27, 2016 Posted September 27, 2016 marko is the rtos ... 2 20 a typo ? 123.45678901234567....... 2 2 sounds right. thereisnotime you may be interested in this also http://www.cadtutor.net/forum/showthread.php?98234-Dyanically-setting-tree-trunk-and-diameter. 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.