barristann Posted January 8 Share Posted January 8 (edited) Hi all. The below is a "print elist" of a Polyline ((-1 . <Entity name: 21c26e35e70>) (0 . "LWPOLYLINE") (330 . <Entity name: 21c214e69f0>) (5 . "9077") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "TEXT") (62 . 1) (6 . "ByBlock") (100 . "AcDbPolyline") (90 . 2) (70 . 0) (43 . 0.1) (38 . 0.0) (39 . 0.0) (10 378.655 321.399) (40 . 0.1) (41 . 0.1) (42 . 0.0) (91 . 0) (10 367.655 340.599) (40 . 0.1) (41 . 0.1) (42 . 0.0) (91 . 0) (210 0.0 0.0 1.0)) ((-1 . <Entity name: 21c26e35e70>) (0 . "LWPOLYLINE") (330 . <Entity name: 21c214e69f0>) (5 . "9077") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "TEXT") (62 . 1) (6 . "ByBlock") (100 . "AcDbPolyline") (90 . 2) (70 . 0) (43 . 0.1) (38 . 0.0) (39 . 0.0) (10 378.655 321.399) (40 . 0.1) (41 . 0.1) (42 . 0.0) (91 . 0) (10 367.655 340.599) (40 . 0.1) (41 . 0.1) (42 . 0.0) (91 . 0) (210 0.0 0.0 1.0)) There are 2 possible assoc 10 results. I want pt = 378.655 321.399 with the bellow codes: (if (setq ss (ssget ":L")) (progn (setq x 0) (setq ename (ssname ss x)) (setq elist (entget ename)) (setq pt (cdr(assoc 10 elist))) ) ;; progn ) ;; if But, these codes keeps giving me pt = 367.655 340.599 instead How do I specify that I want the second assoc 10? Thank you Edited January 8 by barristann Quote Link to comment Share on other sites More sharing options...
pkenewell Posted January 8 Share Posted January 8 @barristann A simple function commonly called MASSOC, which returns a list of all DXF codes of a certain prefix. There ae several variations of this function out there. (defun Massoc (el dxf) (vl-remove-if 'null (mapcar (function (lambda (x)(if (= (car x) dxf) x nil))) el) ) ) ;;Example that will return the 2nd vertex of a selected polyline. (cdr (cadr (Massoc (entget (car (entsel))) 10))) 2 Quote Link to comment Share on other sites More sharing options...
BIGAL Posted January 8 Share Posted January 8 This is what I use to get a list of pline points. I think I got it from Lee-mac. (setq plent (entsel "\nPick pline ")) (if plent (setq co-ord (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget (car plent)))))) For any point use (nth x co-ord) note 1st point x=0, so for 2 points only x=1 2 Quote Link to comment Share on other sites More sharing options...
Steven P Posted January 9 Share Posted January 9 and third option, if the polyline only has 2 points on it, can try reverse, look at it 'backwards' (if (setq ss (ssget ":L")) (progn (setq x 0) (setq ename (ssname ss x)) (setq elist (entget ename)) (setq pt (cdr(assoc 10 (reverse elist)))) ) ;; progn ) ;; if 1 Quote Link to comment Share on other sites More sharing options...
barristann Posted January 9 Author Share Posted January 9 Thank you pkenewell, BIGAL, and Steven P. All of these methods work. These lessons are invaluable to me! 1 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.