Author Topic: layer names to file  (Read 2257 times)

0 Members and 1 Guest are viewing this topic.

Oak3s

  • Guest
layer names to file
« on: March 17, 2005, 04:23:41 PM »
does anyone have a routine that can retrieve layers in a drawing and save the names to a file with the file name? the over all routine (hopefully) will be able to give a list of drawings that have layers that are not standard layer names.....its a big thing for me. might be simple. :oops:

whdjr

  • Guest
layer names to file
« Reply #1 on: March 17, 2005, 04:37:16 PM »
Dotsoft has a pretty good program for a file Layerhtm

ronjonp

  • Needs a day job
  • Posts: 7531
layer names to file
« Reply #2 on: March 17, 2005, 05:11:17 PM »
Code: [Select]
(defun c:layerxls (/  dirname, file,
  count,  f, row,
  LayerName,  layercolornum, LayerLineType,
  layerstatnum,  LayerStatus, LayerColor
 )
  (setq
    dirname (getfiled "Select a location to save the layer list..."
     "layers.csv"
     "csv"
     1
   )
  )
  (setq file (open dirname "w"))
  (write-line
    (strcat "Layer List for "
   (getvar "dwgprefix")
   (getvar
     "dwgname"
   )
    )
    file
  )
  (write-line "" file)
  (write-line "NAME, COLOR, LINETYPE, STATUS" file)
  (setq count 0)
  (setq f 1)
  (while (setq row (tblnext "LAYER" f))
    (setq f nil)
    (setq LayerName (cdr (assoc 2 row)))
    (setq layercolornum (cdr (assoc 62 row)))
    (setq LayerLineType (cdr (assoc 6 row)))
    (setq layerstatnum (cdr (assoc 70 row)))
    (if (= layerstatnum 1)
      (setq LayerStatus "FROZEN")
      (setq LayerStatus "THAWED")
    )
    (if (< layercolornum 8)
      (cond
((= layercolornum 1) (setq LayerColor "RED"))
((= layercolornum 2) (setq LayerColor "YELLOW"))
((= layercolornum 3) (setq LayerColor "GREEN"))
((= layercolornum 4) (setq LayerColor "CYAN"))
((= layercolornum 5) (setq LayerColor "BLUE"))
((= layercolornum 6) (setq LayerColor "MAGENTA"))
((= layercolornum 7) (setq LayerColor "WHITE"))
      )
      (setq LayerColor (rtos layercolornum 2 0))
    )
    (setq txt (strcat LayerName   "," LayerColor
     ","   LayerLineType
     ","   LayerStatus
    )
    )
    (write-line txt file)
    (setq count (+ count 1))
  )
  (close file)
  (princ count)
  (princ (strcat " layers have been written to "
dirname
"."
)
  )
  (princ
    "\nDouble-click on this file to open in Microsoft Excel."
  )
  (princ)
)
(princ
  "\nType LAYERXLS to generate a listing of the current drawing's layer
set."
)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC