Author Topic: how can i extract layer names from alot of drawings  (Read 3195 times)

0 Members and 1 Guest are viewing this topic.

ELOQUINTET

  • Guest
how can i extract layer names from alot of drawings
« on: December 01, 2004, 04:52:43 PM »
i remember seeing around here recently something someone wrote that would extract layer names to a text file but can't seem to track it down. basically what i would like to do is find all of the layer names we have commonly used and create a layer standards file so we can update our drawings a little easier with the layer translator. i just started using this and was also wondering if anybody has anysuggestion of the fastest way to update our drawings. thanks

M-dub

  • Guest
how can i extract layer names from alot of drawings
« Reply #1 on: December 01, 2004, 08:55:19 PM »
I'll post it when I get to work tomorrow...

ELOQUINTET

  • Guest
how can i extract layer names from alot of drawings
« Reply #2 on: December 02, 2004, 09:32:09 AM »
mdub i thought that was you who posted that but couldn't find it, where it at man?

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
how can i extract layer names from alot of drawings
« Reply #3 on: December 02, 2004, 09:45:49 AM »
I think this is what Mike was referring to.

Code: [Select]

(defun c:layers2csv (/ get->layobj open->file lay lylst fo)
  (vl-load-com)

  (defun get->layrobj ()
    (vla-get-Layers
      (vla-get-ActiveDocument
        (vlax-get-acad-object)
        )
      )
    )
 
    (vlax-for lay (get->layrobj)
      (setq lylst
             (cons
               (list
                 (vlax-get-property lay 'Name)
                 (itoa (vlax-get-property lay 'Color))
                 (vlax-get-property lay 'Linetype)
                 )
               lylst
               )
            )
      )

  (if lylst
    (progn
       ; remove layer '0' and reverse the list
      (setq lylst (reverse (vl-remove (last lylst) lylst))
            ; sort the list
            lylst (vl-sort lylst '(lambda (x y) (< (car x)(car y))))
            fo (open (strcat "c:/"(getvar 'dwgname)".csv") "w"); suitable for Excel
            )
      (foreach l lylst
        (write-line (strcat (car l) "," (cadr l) "," (last l)) fo)
        )
      (close fo)
      )
    )

  (princ)
  )
TheSwamp.org  (serving the CAD community since 2003)

ELOQUINTET

  • Guest
how can i extract layer names from alot of drawings
« Reply #4 on: December 02, 2004, 09:58:54 AM »
ok mark i loaded it up and ran it but don't really know where it saved the file to. i don't know a thing about csv. like i said originally it would be great too if it would not create duplicate layer names. i also wish i could figure out that ezscript program so i could run this on a whole directory. i'm trying to come up with a list of all the layers various users have used over the years and come up with a way to translate the common ones.

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
how can i extract layer names from alot of drawings
« Reply #5 on: December 02, 2004, 10:24:47 AM »
Quote from: ELOQUINTET
ok mark i loaded it up and ran it but don't really know where it saved the file to.

Hint: (strcat "c:/"(getvar 'dwgname)".csv")
TheSwamp.org  (serving the CAD community since 2003)

M-dub

  • Guest
how can i extract layer names from alot of drawings
« Reply #6 on: December 02, 2004, 10:31:56 AM »
Thanks Mark...
Sorry, I've been really busy this week.  It may say that I'm online, but I've usually got it minimized.
Dan, did you figure it out?

ELOQUINTET

  • Guest
how can i extract layer names from alot of drawings
« Reply #7 on: December 02, 2004, 10:40:56 AM »
ah i see gotcha mark thanks man