Sorry, I had overlooked a few things:
- (defun c:sel_blocks ( / blk def lst sel ) (while (setq def (tblnext "block" (not def))) (setq blk (cdr (assoc 2 def))) (cond ( (= 4 (logand 4 (cdr (assoc 70 def)))) (setq lst (cons (cons 2 (LM:escapewildcards blk)) lst)) ) ( (/= 1 (cdr (assoc 1070 (reverse (cadr (assoc -3 (entget (cdr (assoc 330 (entget (tblobjname "block" blk) ) ) ) '("AcadAnnotative") ) ) ) ) ) ) ) (setq lst (cons (cons 2 (LM:escapewildcards blk)) lst)) ) ) ) (if lst (if (setq sel (ssget (append '((0 . "INSERT") (-4 . ""))))) (princ (strcat "\nNumber of blocks: " (itoa (sslength sel)))) (princ "\nNothing selected.") ) (princ "\nNo valid blocks found in drawing.") ) (sssetfirst nil sel) (princ));; Escape Wildcards - Lee Mac;; Escapes wildcard special characters in a supplied string(defun LM:escapewildcards ( str ) (vl-list->string (apply 'append (mapcar '(lambda ( c ) (if (member c '(35 64 46 42 63 126 91 93 45 44)) (list 96 c) (list c) ) ) (vl-string->list str) ) ) ))
Escape Wildcards function from here.
Note that the above code will still not be compatible with annotative dynamic blocks, as these will require yet more checks.
Correct - the developer documentation in AutoCAD is not complete. |