Extracting elements(information/coordinates) layer by layer

Extracting elements(information/coordinates) layer by layer

Anonymous
Not applicable
1,359 Views
2 Replies
Message 1 of 3

Extracting elements(information/coordinates) layer by layer

Anonymous
Not applicable

Hello,

 

I am fairly new to AutoCad, so please excuse my little experience.

 

I have a map with different lines, circles etc. Elements which belong together are on the same layer. I am trying to find a way to extract all information (think the build in Dataextract function) [coordinates of beginning/end, length, radius etc] to a csv file or excel file, but layer by layer.

 

I tried different codes with the ssget function, but everything failed so far.

 

 

I am using AutoCAD 2016 with Express-Tools on Windows 10.

 

Any help is appreciated.

 

Johanna

 

 

0 Likes
Accepted solutions (1)
1,360 Views
2 Replies
Replies (2)
Message 2 of 3

john.uhden
Mentor
Mentor
Accepted solution

I guess I would start by using tblnext to iterate through all the layers and do an ssget on each layer name.

For example:

 

(setq rewind 1)
(while (setq layer (tblnext "layer" rewind))
  (setq rewind nil
           layer (cdr (assoc 2 layer))
  )
  (or
    (setq ss (ssget "X" (list (cons 8 layer))))
    (setq ss (ssadd))
  )
  (setq i (sslength ss))
  (while (> i 0)
    (setq e (ssname ss (setq i (1- i)))
             ent (entget e) ;; entity data
             obj (vlax-ename->vla-object e) ;; to get vla-object data
    )
    (extract e) ;; extract function not provided; that's up to you
    ;; or (extract obj) ;; that's up to you too.
  )
)

John F. Uhden

0 Likes
Message 3 of 3

Anonymous
Not applicable

Thank you. It worked like a charm.

 

 

0 Likes