;;;By Aeo
(defun c:blk_col (/ blk blkref blocks doc ent name ss n clo)
  (vl-load-com)
  (princ "\n选要随层的块: ")
  (setq	ss (ssget '((0 . "INSERT")))
	n  (sslength ss)
  )
  (while
    (and (setq BLK (ssname ss (setq n (1- n))))
	 (setq BLKREF (vlax-ename->vla-object BLK))
	 (not
	   (and	(/= (vla-get-objectname BLKREF) "AcDbBlockReference")
		(princ "\n不是块:")
	   )
	 )
	 (setq clo (acad_colordlg 7))
	 (setq name (vla-get-name BLKREF))
    )
     (progn
       (command "undo" "group")
       (setq DOC    (vla-get-activedocument (vlax-get-acad-object))
	     BLOCKS (vla-get-blocks doc)
	     blk    (vla-item BLOCKS name)
       )
       (vlax-for ENT blk
	 (vla-put-layer ent "0")
	 (vla-put-color ent clo)
       )
       (vla-regen doc acActiveViewport)
       (vlax-release-object blk)
       (vlax-release-object BLOCKS)
       (vlax-release-object DOC)
       (command "undo" "end")
     )
  )
  (princ "\nUndo后请regen.")
  (princ)
)
