虽然不太好看,但确实有效。。至少对我来说
- ;|************************************************************************
- **************************************************************************
- *********************A Simple Block Replace Function**********************
- ******************************By: ZRABOIN*********************************
- **************************************************************************
- ************************************************************************|;
- (defun c:bsw ( / rblk nblk)
- (if (and (setq rblk (car (entsel "\nSelect a block with the block name you want to replace: ")))
- (setq nblk (car (entsel "\nSelect the block you would like to replace it with: ")))
- (= (cdr (assoc 0 (setq rblk (entget rblk)))) "INSERT")
- (= (cdr (assoc 0 (setq nblk (entget nblk)))) "INSERT"))
- (progn
- (setq rblk (reverse (vl-string->list (cdr (assoc 2 rblk)))))
- (while (and (> (car rblk) 48)
- (< (car rblk) 57))
- (setq rblk (cdr rblk)))
- (mapcar '(lambda (z) (vla-put-name (vlax-ename->vla-object (cadr z)) (cdr (assoc 2 nblk))))
- (ssnamex (ssget "X" (list (cons 2 (strcat (vl-list->string (reverse rblk)) "*")))))))
- (princ "\nBlock not selected! Exiting program."))
- (princ)
- )
|