本帖最后由 vectra 于 2015-5-12 14:22 编辑
 - (vl-load-com)
- (defun c:db (/ obj blk)
- (defun confirm (msg default / rt)
- (initget "Y N ")
- (if (null (setq rt (getkword (strcat msg " <" default ">:"))))
- (setq rt default)
- )
- (if (= "Y" rt)
- t
- nil
- )
- )
- (defun walk (blk setlayer setcolor setlw /)
- (vlax-for x blk
- (if (= "AcDbBlockReference" (vla-get-objectname x))
- (walk (vla-item (vla-get-blocks
- (vla-get-activedocument (vlax-get-acad-object))
- )
- (vla-get-name x)
- )
- setlayer
- setcolor
- setlw
- )
- )
- (if setlayer
- (vla-put-layer x "0")
- )
- (if setcolor
- (vla-put-color x acbylayer)
- )
- (if setlw
- (progn
- (vla-put-lineweight x -1)
- (if (= "AcDbPolyline" (vla-get-objectname x))
- (vla-put-constantwidth x 0.0)
- )
- )
- )
- )
- )
- (setq obj (ace-entsel "\n选择块:" nil "INSERT")
- blk (vla-item (vla-get-blocks
- (vla-get-activedocument (vlax-get-acad-object))
- )
- (vla-get-name (vlax-ename->vla-object (car obj)))
- )
- )
- (walk blk
- (confirm "重置图元图层为\"0\" [是(Y)/否(N)]" "Y")
- (confirm "重置图元颜色为随层 [是(Y)/否(N)]" "Y")
- (confirm "重置图元线宽默认或零 [是(Y)/否(N)]" "Y")
- )
- (command ".regen")
- (princ)
- )
- (defun ace-entsel (msg kword filter / ent)
- (while (null ent)
- (if kword
- ;; 处理自定义INITGET参数
- (initget kword)
- ;; return empty string ("") if enter key or right button down
- (initget " ")
- )
- (setq ent (entsel msg))
- (cond
- ((null ent)
- (princ "未选择对象。")
- )
- ((= (type ent) 'list)
- (if (and filter
- (not (wcmatch (ace-getval 0 (car ent)) filter))
- )
- (progn
- (princ "选择对象已被过滤。")
- (setq ent nil)
- )
- )
- )
- )
- )
- ent
- )
- (defun ace-getval (key ename)
- (cdr (assoc key (entget ename)))
- )
|