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