一些替代方案:
- (defun C:test ; Written by: Grrr, credits to: Lee Mac, Tharwat
- ( / PropsLst SS sBe sBo srcLst i dBe dBo dstLst )
- (setq PropsLst (list 'EffectiveName 'Layer 'Linetype 'Rotation 'TrueColor)) ; <- list of required properties
- (and (setq SS (ssget "_I" (list (cons 0 "INSERT")))) (sssetfirst nil nil))
- (setvar 'errno 0)
- (while (/= 52 (getvar 'errno))
- (setq sBe (car (entsel "\nSelect source block:" )))
- (cond
- ( (and sBe (eq (vla-get-ObjectName (setq sBo (vlax-ename->vla-object sBe))) "AcDbBlockReference"))
- (setq srcLst
- (mapcar
- (function
- (lambda (x)
- (if (not (eq x 'TrueColor))
- (vlax-get sBo x)
- (mapcar
- (function
- (lambda (p)
- (vlax-get (vlax-get sBo 'TrueColor) p)
- )
- )
- (list 'ColorIndex 'Red 'Green 'Blue)
- )
- ); if
- )
- )
- PropsLst
- )
- )
- (setvar 'errno 52)
- )
- ( T nil )
- )
- )
- (if
- (and
- sBe
- (or SS
- (and
- (princ "\nSelect blocks to be filtered: ")
- (setq SS
- (ssget
- (vl-remove nil
- (list
- (cons 0 "INSERT")
- (if (member 'EffectiveName PropsLst) (cons 2 (strcat "`*U*," (vla-get-EffectiveName sBo))))
- )
- )
- )
- )
- )
- )
- )
- (repeat (setq i (sslength SS))
- (setq dBo (vlax-ename->vla-object (setq dBe (ssname SS (setq i (1- i))))))
- (setq dstLst
- (mapcar
- (function
- (lambda (x)
- (if (not (eq x 'TrueColor))
- (vlax-get dBo x)
- (mapcar
- (function
- (lambda (p)
- (vlax-get (vlax-get dBo 'TrueColor) p)
- )
- )
- (list 'ColorIndex 'Red 'Green 'Blue)
- )
- ); if
- )
- )
- PropsLst
- )
- )
- (and (not (equal srcLst dstLst)) (ssdel dBe SS))
- )
- )
- (sssetfirst nil SS)
- (princ)
- );| defun |; (or vlax-get-acad-object (vl-load-com)) (princ)
但不支持多个源块引用。 |