Author Topic: Print Layers (or export to Word / Excel)  (Read 4316 times)

0 Members and 1 Guest are viewing this topic.

M-dub

  • Guest
Print Layers (or export to Word / Excel)
« on: May 04, 2004, 12:56:16 PM »
As the subject states, I'm looking for something that will either print out the layers in a drawing (Acad2000) or export them to an Excel spreadsheet or Word document.  Anyone have any ideas?  (Besides -layer and copying all that stuff to Word and all that garbage...I've got Freakin' TONS of layers in this one drawing in particular.)

Thanks a million!

Mike

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
Print Layers (or export to Word / Excel)
« Reply #1 on: May 04, 2004, 01:22:48 PM »
why don't we write one real quick? I'll get it started.
TheSwamp.org  (serving the CAD community since 2003)

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
Print Layers (or export to Word / Excel)
« Reply #2 on: May 04, 2004, 01:25:22 PM »
that was quick Mark!!

creates a .csv file on the root of C named the same as the dwg.
example: Drawing1.csv

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)

M-dub

  • Guest
Print Layers (or export to Word / Excel)
« Reply #3 on: May 04, 2004, 01:34:02 PM »
I am not worthy of your talents, Mark!

When are you gonna put that paypal thing up again?  ;)

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
Print Layers (or export to Word / Excel)
« Reply #4 on: May 04, 2004, 01:45:53 PM »
glad you like it :D
TheSwamp.org  (serving the CAD community since 2003)

Dent Cermak

  • Guest
Print Layers (or export to Word / Excel)
« Reply #5 on: May 04, 2004, 03:58:52 PM »
Go to your Sheet Manager tab, down to "Sheet Tools", then down to "Create Layer Report". Gives you a nice file that you can edit in WORD, and probably Excel.

M-dub

  • Guest
Print Layers (or export to Word / Excel)
« Reply #6 on: May 04, 2004, 08:54:12 PM »


I'll have to try that one tomorrow Dent.  Hopefully it works!
Thanks a lot!
Mike

Dent Cermak

  • Guest
Print Layers (or export to Word / Excel)
« Reply #7 on: May 05, 2004, 01:41:22 PM »
Well, did it work ?

M-dub

  • Guest
Print Layers (or export to Word / Excel)
« Reply #8 on: May 05, 2004, 02:09:37 PM »
Call me an idiot, but I can't find 'Sheet Manager' so, No, I guess it didn't work.  :(

I just have Acad 2000...pretty plain jane.

Dent Cermak

  • Guest
Print Layers (or export to Word / Excel)
« Reply #9 on: May 05, 2004, 03:00:44 PM »
Dang!! Send me the drawing and I will send you a text file. A blank drawing with all of your layers loaded will do the trick.

M-dub

  • Guest
Print Layers (or export to Word / Excel)
« Reply #10 on: May 05, 2004, 03:16:59 PM »
Acutally Dent, I completely appreciate the offer, but the routine Mark provided me with worked like a charm.
Thanks a lot!

One Shot

  • Guest
Print Layers (or export to Word / Excel)
« Reply #11 on: April 19, 2005, 08:15:40 PM »
Quote from: Mark Thomas
that was quick Mark!!

creates a .csv file on the root of C named the same as the dwg.
example: Drawing1.csv

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)
  )

Mark,

This cool, but where do the file go after your run the lisp?

One Shot

  • Guest
Print Layers (or export to Word / Excel)
« Reply #12 on: April 19, 2005, 08:34:55 PM »
I found it.  Is there a way that the file can be sent to a folder that you want?

thank you,

Brad

nivuahc

  • Guest
Print Layers (or export to Word / Excel)
« Reply #13 on: April 19, 2005, 09:08:47 PM »
Change this line
Code: [Select]
fo (open (strcat "c:/"(getvar 'dwgname)".csv") "w"); suitable for Excel

to the directory of your choosing (using forward slashes, of course). Like this:

Code: [Select]
fo (open (strcat "c:/this/is/my/favorite/folder/"(getvar 'dwgname)".csv") "w"); suitable for Excel

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Print Layers (or export to Word / Excel)
« Reply #14 on: April 20, 2005, 09:16:42 AM »
Quote from: Dent Cermak
Go to your Sheet Manager tab, down to "Sheet Tools", then down to "Create Layer Report". Gives you a nice file that you can edit in WORD, and probably Excel.

I have 2005, i opened Sheet Set Manager, but I cant find what you are referring to.
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)