Cannot get coordinates pointes of a polyline

Cannot get coordinates pointes of a polyline

Kh.mbkh
Advocate Advocate
637 Views
4 Replies
Message 1 of 5

Cannot get coordinates pointes of a polyline

Kh.mbkh
Advocate
Advocate

Im using this functions to get coordinates pointes of a ployline:

(defun PointsOfPline(Pline)      
  (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget Pline)))
)

but it doesnt work with this p-line, because after calling (entget) the list starting with "10" is: (10 0 0 0) ??

123.PNG

(My pline here called B5Am)

Accepted solutions (2)
638 Views
4 Replies
Replies (4)
Message 2 of 5

rkmcswain
Mentor
Mentor
Accepted solution

Without trying it or looking too carefully at the code, my guess would be this is written for LWPOLYLINE entities, and the one in your screenshot is a POLYLINE entity. See Also

 

 

R.K. McSwain     | CADpanacea | on twitter
0 Likes
Message 3 of 5

Kh.mbkh
Advocate
Advocate
thank you that was a good remark
0 Likes
Message 4 of 5

Kh.mbkh
Advocate
Advocate

It works with this now :

(defun PointsOfPline(Poline)      
  (if (/= (cdr (assoc 0 (entget Poline))) "LWPOLYLINE")
  	(command "_convert" "_p" "_s" Poline "" )
    )
  (mapcar 'cdr
	  (vl-remove-if-not '(lambda (x) (= (car x) 10))
	    (entget  Poline)
	    )
	  )
  )

 

0 Likes
Message 5 of 5

Kent1Cooper
Consultant
Consultant
Accepted solution

If you want to get the vertices without converting a "heavy" Polyline to "lightweight," you can do this:

(defun PointsOfPline (pline / n vertices)
  (repeat (setq n (+ (fix (vlax-curve-getEndParam pline)) (if (vlax-curve-isClosed pline) 0 1)))
    (setq vertices (cons (vlax-curve-getPointAtParam pline (setq n (1- n))) vertices))
  ); repeat
  vertices
); defun

 

Kent Cooper, AIA