(defun c:test ( / acblk acdoc acsel name obj processed ) ;; Lee Mac 17.06.11 (setq acdoc (vla-get-activedocument (vlax-get-acad-object)) acblk (vla-get-blocks acdoc) ) (if (ssget '((0 . "INSERT")(2 . "Test"))) (progn (vlax-for block (setq acsel (vla-get-activeselectionset acdoc)) (if (not (member (setq name (vla-get-name block)) processed)) ( (lambda ( / lst ) (vlax-for obj (vla-item acblk name) (if (eq "AcDbWipeout" (vla-get-objectname obj)) (setq lst (cons obj lst)) ) ) (if lst (vla-movetobottom (LM:SortentsTable (vla-item acblk name)) (vlax-make-variant (vlax-safearray-fill (vlax-make-safearray vlax-vbobject (cons 0 (1- (length lst)))) lst ) ) ) ) (setq processed (cons name processed)) ) ) ) ) (vla-delete acsel) (vla-regen acdoc acallviewports) ) ) (princ) ) (defun LM:SortentsTable ( space / dict result ) (cond ( (not (vl-catch-all-error-p (setq result (vl-catch-all-apply 'vla-item (list (setq dict (vla-GetExtensionDictionary space)) "ACAD_SORTENTS") ) ) ) ) result ) ( (vla-AddObject dict "ACAD_SORTENTS" "AcDbSortentsTable") ) ) ) (vl-load-com) (princ)