Hi,
Maybe it's a little late, but here is my take on this thread. I've put together something a little bit more flexible and I think that this approach is also easier to further develop (like adding some other stuff to these layers), if the same approach on structuring the data and to apply it to the objects is maintained. Hope it's useful:
;;;=============================================================
(defun mylayman (ltypelist laydatalist / activedoc ltypes layer)
(setq activedoc
(vla-get-activedocument
(vlax-get-acad-object)
)
)
(setq ltypes (vla-get-linetypes activedoc))
(defun ltypeisloaded (ltypename)
(not
(vl-catch-all-error-p
(vl-catch-all-apply
'vla-item
(list ltypes ltypename)
)
)
)
)
(defun loadltype (ltypename)
(not
(vl-catch-all-error-p
(vl-catch-all-apply
'vla-load
(list
ltypes
ltypename
(if (= (getvar 'measurement) 0)
"acad.lin"
"acadiso.lin"
)
)
)
)
)
)
(mapcar
'(lambda (x)
(if (not (ltypeisloaded x))
(if (not (loadltype x))
(prompt
(strcat
"\nThe linetype "
(strcase x)
" could not be loaded."
)
)
)
)
)
ltypelist
)
(mapcar
'(lambda (x)
(if
(not
(vl-catch-all-error-p
(setq layer
(vl-catch-all-apply
'vla-add
(list
(vla-get-layers activedoc)
(car x)
)
)
)
)
)
(vla-put-color layer (cdr x))
(prompt
(strcat
"\nThe layer "
(strcase (car x))
" could not be found."
)
)
)
)
laydatalist
)
(princ)
)
;;;=============================================================
;;;Usage:
;;;=============================================================
(mylayman
'("Center" "Hidden")
'(("BRACING" . 32)("CL" . 8)("GRID" . 9)("TEXT" . 4)("STEEL" . 3)("PPA" . 2)("HATCH" . 8)("WALL" . 8))
)
;;;=============================================================