(setq _layers (gettableitems "layer") _styles (gettableitems "style"));;获取图层表、字体样式表图层表:("0" "1_中心线" "2_轮廓线" "3" "3_隐藏线" "3中心线" "4_标注和文字" "4虚线层" "5_双点划线" "5剖面线层" "6_图框线" "7_标记线" "7标注层" "8双点划线" "Defpoints" "标注" "标注线" "尺寸线" "粗实线" "粗线" "批量打印层" "剖面线" "文字" "细实线" "细线" "虚线" "指引线" "中心线-点画线")字体样式表:("" "-30" "{18b73a54-fa43-428c-adcb-c1c7bbdf2c84}" "30" "hzt.shx" "hzt.txt" "Standard" "txt-3.5" "WMF-System0" "WMF-System1" "WMF-宋体0" "标 宽0.7 高3" "宋 宽0.7 高3" "宋体")
;; table 值为 "LAYER"、"LTYPE"、"VIEW"、"STYLE"、"UCS"、"APPID"、"DIMSTYLE" 和 "VPORT"。该参数不区分大小写。(defun gettableitems(table / a b) (while (setq a (tblnext table (null a))) (if (not (or (wcmatch (cdr (assoc 2 a)) "`**,*|*") (and (= "layer" (strcase table t)) (= 4 (logand 4 (cdr (assoc 70 a))))))) (setq b (cons (cdr (assoc 2 a)) b)) ) ) (acad_strlsort b) )
(defun GetLayerList (/ llist l) (setq llist nil) (if (tblnext "LAYER" T) (progn (setq llist (cons (cdr (assoc 2 (tblnext "LAYER" T))) llist)) (while (setq l (tblNext "LAYER")) (setq llist (cons (cdr (assoc 2 l)) llist)) ) ) ) (vl-sort llist '<))