Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Extract Coordinates of Polylign

3 REPLIES 3
Reply
Message 1 of 4
stelios16
277 Views, 3 Replies

Extract Coordinates of Polylign

Hello

I'm trying to extract he coordinates of the points that make a polylign but as a result I have an empty list.
Can somebody help please ? 🙂

 

(defun c:contour_voile ()


    (setq contour_polyligne (car (entsel "Select a polylign please :")))    
    (setq defpolyligne (entget contour_polyligne))    
        
        (if (/= (cdr (assoc 8 defpolyligne)) "Polyligne_Concrete")
            (prompt "\nYou havent selected a polylign")
        );endif
        (princ defpolyligne)
                
    (foreach rec defpolyligne
            (princ (cdr (= (car rec)10)))
    );foreach

3 REPLIES 3
Message 2 of 4
Ajilal.Vijayan
in reply to: stelios16

Here's the modified code

 

(defun c:contour_voile ()


    (setq contour_polyligne (car (entsel "Select a polylign please :")))    
    (setq defpolyligne (entget contour_polyligne))    
        
        (if (/= (cdr (assoc 8 defpolyligne)) "Polyligne_Concrete")
            (prompt "\nYou havent selected a polylign")
        );endif
        ;(princ defpolyligne)
                
    (foreach rec defpolyligne
			(if ( = (car rec) 10)
			(princ (cdr rec))
			)
    );foreach
	
	);defun

 

Message 3 of 4
Kent1Cooper
in reply to: stelios16


@stelios16 wrote:

....

I'm trying to extract he coordinates of the points that make a polylign but as a result I have an empty list. ...


Welcome to the Forums!

 

Ajilal.Vijayan's suggestion should work if you want only to see the point coordinate lists on-screen.  If you want them actually in a list as AutoLISP uses that term, there are ways to do that, such as:

 

(mapcar 'cdr (vl-remove-if '(lambda (x) (/= (car x) 10)) defpolyligne))

 

which looks at each record in the entity data, and if its first number is not 10, omits it, then removes the 10's from the beginnings of what remains.

Kent Cooper, AIA
Message 4 of 4
stelios16
in reply to: stelios16

Thank you very much!!!!!

It works 🙂 🙂 🙂

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost