This is not my script but I find it very useful. I need some tips on how to fix it.
The problem I'm having is the filtered selection is picking up blocks that aren't supposed to be a part of the selection set.
What the script does:
Selects only blocks that you specify.
First select a single block, then select a window or the entire drawing. Then the blocks will be selected.
;blockselect function
(defun bls (/ s blk bn opt )
(vl-load-com)
(while (not
(progn
(initget "N")
(setq blk (entsel "\nSelect Block/N for Block name:"))
(cond
((null blk) (prompt "\n<<Null selection>>"))
((eq blk "N")
(while (not
(and (Setq bn (getstring "\nEnter Block Name: "))
(tblsearch "Block" bn)
)
)
(princ (Strcat "\n<< " bn " Invalid block name>>"))
) T
)
((setq s (car blk))
(if (eq (cdr (Assoc 0 (entget s))) "INSERT")
(setq bn (vla-get-EffectiveName (vlax-ename->vla-object s)))
(prompt "\n<<Invalid Object>>")
)
)
)
)
)
)
(princ (Strcat "\nBlock Name Filter: " (Strcase BN)))
(initget "A W")
(setq opt (cond ((getkword
(strcat "\n Choose option [Window/All] <Window>: ")
)
)
("W")
)
)
(sssetfirst nil(setq selection
(ssget (if (eq opt "A") "_X" "_:L")
(list '(0 . "insert")
(cons 2 (strcat bn ",`*U*"))
)
)
))
;(sssetfirst nil selection)
(princ)
)
(defun c:bls()
(bls)
(princ)
)