;; Select similar blocks which have different names - Lee Mac

(defun c:ssb ( / blk def ent lst tmp )

(while

(progn (setvar 'errno 0) (setq blk (car (entsel "\nSelect block: ")))

(cond

( (= 7 (getvar 'errno))

(princ "\nMissed, try again.")

)

( (null blk) nil)

( (/= "INSERT" (cdr (assoc 0 (setq blk (entget blk)))))

(princ "\nSelected object is not a block.")

)

)

)

)

(if blk

(progn

(while (setq def (tblnext "block" (null def)))

(setq ent (tblobjname "block" (cdr (assoc 2 def)))

tmp nil

)

(while (setq ent (entnext ent))

(setq tmp

(append tmp

(vl-remove-if

'(lambda ( x ) (or (= 'ename (type (cdr x))) (member (car x) '(5))))

(entget ent)

)

)

)

)

(setq lst

(cons

(cons (assoc 2 def)

(vl-sort tmp

'(lambda ( a b )

(if (= (car a) (car b))

(if (listp (cdr a)) (vl-some '< (cdr a) (cdr b)) (< (cdr a) (cdr b)))

(< (car a) (car b))

)

)

)

)

lst

)

)

)

(setq blk (cdr (assoc (assoc 2 blk) lst)))

(sssetfirst nil

(ssget "_X"

(append '((0 . "INSERT") (-4 . ""))

)

)

)

)

)

(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)

)

)

)

)

(princ)

(c:ssb)

Advertisements