(setq _blocks (getblockdata));;获取所有块名及属性名(setq blocks (mapcar 'car _blocks));;获取所有块名( "A1图框-横" "A1图框-竖" "A2图框-横" "A2图框-竖" "A3图框-横" "A3图框-竖" "A4图框-横" "A4图框-竖" "RecordCardSub" "粗糙度" "工序编号" "杭州川空图框明细栏" "杭州川空图框明细栏1" "检序铆序" "控制点" "零件明细(单)" "零件明细(多)" "四川空分集团图框明细栏" "四川空分集团图框明细栏1")
(defun getblockdata(/ a b c) (while (setq a (tblnext "block" (null a))) (if (and (null (wcmatch (cdr (assoc 02 a)) "`**,*|*")) (= 2 (logand 2 (cdr (assoc 70 a)))) (setq c ((lambda(c / d e) (while (setq c (entnext c)) (if (= "ATTDEF" (cdr (assoc 0 (setq d (entget c))))) (setq e (cons (strcase (cdr (assoc 2 d))) e))) ) (vl-sort e '<) ) (tblobjname "block" (cdr (assoc 2 a))) ) ) ) (setq b (cons (cons (cdr (assoc 2 a)) c) b)) ) ) (vl-sort b '(lambda (a b) (< (car a) (car b)))))
;;说明:获取块名表;;返回:块名表(defun GetBlockList (/ blist b) (setq blist nil) (if (tblnext "BLOCK" T) (progn (setq blist (cons (cdr (assoc 2 (tblnext "BLOCK" T))) blist)) (while (setq b (tblNext "BLOCK")) (setq blist (cons (cdr (assoc 2 b)) blist)) ) ) ) (vl-sort (vl-remove-if '(lambda (s) (= "*" (substr s 1 1))) blist) '<))