Jump to content

Recommended Posts

Posted (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 by barristann
Posted

@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)))

 

  • Like 2
Posted

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

  • Like 2
Posted

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

 

  • Like 1
Posted

Thank you pkenewell, BIGAL, and Steven P. All of these methods work. These lessons are invaluable to me!   

  • Like 1

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...