There's got to be a better way
I posted a tiny bit of code in
this thread earlier today that I threw together yesterday when my brain took a detour from work for a bit. Anyway, I threw it together because I wanted to refresh my mind a bit when it comes to building lists and processing them (I haven't written any code in forever and I have a framework of an idea for a routine, this being part of it).
Anyway, what I actually wanted to do was build a list of layers that I could parse through and this is what I came up with:
;*********************************************************************************
; Function to build a list of available layers - © Copyright 2005 by Chuck Chauvin
;*********************************************************************************
(defun BuildLayerList (/ LayerItem)
(setq LayerList nil)
(setq LayerItem (tblnext "LAYER" T))
(while (/= LayerItem nil)
(setq LayerList
(append LayerList
(list
(list
(cdr (assoc 2 LayerItem)) ;; Name
(cdr (assoc 62 LayerItem)) ;; Color
(cdr (assoc 6 LayerItem)) ;; Linetype
) ;_end list
) ;_end list
) ;_end append
) ;_end setq LayerList
(setq LayerItem (tblnext "LAYER"))
) ;_end while
(princ)
) ;_end defun BuildLayerList
This started out as me thinking
"build a list of layers that are in the drawing along with their linetypes". That was simple enough to do but, along the way I thought
"well, maybe I'll want to throw the color in there as well" so I added that bit as an afterthought. Anyway, the above code will build a list that looks like this:
(("0" 7 "Continuous") ("LAYER_1" 7 "Continuous") ("LAYER_2" 5 "Dashed") ("LAYER_3" 150 "Hidden"))
that I can then use later on, in this skeleton of a routine I've got floating around in my skull.
Anyway, my
gut tells me this isn't the most efficient way (with LISP) to do this and I was wondering if anyone had any thoughts or suggestions (using LISP) to make this better.