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

Exporting list of objects

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
Anonymous
814 Views, 3 Replies

Exporting list of objects

Hi,

Does anyone know how to export to a txt file a list containg all the objects on the current layer and their properties?

To be precise, I would like to export the following items from a selection of plines:

- ObjectID;

- Start Point;

- End Point;

- Vertex Points;

- Width.

Thanks in advance.

3 REPLIES 3
Message 2 of 4
Lee_Mac
in reply to: Anonymous

Quickly written, untested:

 

 

;; ExportPline  -  Lee Mac  -  www.lee-mac.com

(defun c:ExportPline ( / f i o s )
    (if
        (and
            (setq s (ssget '((0 . "LWPOLYLINE"))))
            (setq f (getfiled "Create Output File" "" "txt" 1))
            (setq f (open f "w"))
        )
        (progn
            (repeat (setq i (sslength s))
                (setq o (vlax-ename->vla-object (ssname s (setq i (1- i)))))
                (write-line
                    (apply 'strcat
                        (vl-list*
                            (itoa (vla-get-objectid o)) "\t"
                            (rtos (vla-get-constantwidth o)) "\t"
                            (   (lambda ( a ) (a (vlax-get o 'coordinates)))
                                (lambda ( b )
                                    (if b
                                        (cons
                                            (strcat (rtos (car b)) "," (rtos (cadr b)) "\t")
                                            (a (cddr b))
                                        )
                                    )
                                )
                            )
                        )
                    )
                    f
                )
            )
            (close f)
        )
    )
    (princ)
)
(vl-load-com) (princ)
Message 3 of 4
Anonymous
in reply to: Lee_Mac

Just fantastic!

Thanks a lot!

Message 4 of 4
Lee_Mac
in reply to: Anonymous

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

Post to forums  

Autodesk Design & Make Report

”Boost