EDIT 4/6/2010: SelectSimilar has been present in vertical products such as AutoCAD Architecture, however, due to the popularity of this post, I'd like to note that in AutoCAD 2010, this command was included in a package of extra tools offered to subscription users, and in 2011, it is present in vanilla AutoCAD as a native command.
In MAP3D 2006 there is a tool, accessed by most via the right-click menu, called SelectSimilar.
Once you’ve selected an object(s), you use this command to add all other similar entities throughout the drawing to your selection set. (I believe this tool is also available in Architectural Desktop [ADT])
I’ve heard quite a buzz on the newsgroups from MAP users who’ve upgraded to 2007 and are disappointed to see that this command is no longer available in it’s current form. That made me upset, so I’d been keeping my eyes open to see if anyone had come up with a routine which will accomplish the same thing… even going so far as asking people if they knew what sorts of things a command like that would look at and could they write something up.
Well… I finally found that special someone who could help me! Adam Wuellner, whose acquaintance I made via the Autodesk Newsgroups. He has kindly allowed me permission to post his code here: (edit: Adam updated his code, and I am posting the new in here 7/28/06)
;;; Select Similar
;;; (based on a command found in a few versions of AutoCAD)
;;; written by Adam Wuellner
;;; all rights released
;--------> MAIN ROUTINE
(defun c:selsim (/ ss1 i ent filter_list type-layer filter sstemp)
(if (not (setq ss1 (cadr (ssgetfirst))))
(setq ss1 (ssget)))
(setq i 0
(repeat (sslength ss1)
(setq ent (entget (ssname ss1 i))
i (1+ i))
(setq type-layer (list (assoc 0 ent) (assoc 8 ent)))
(if (not (member type-layer filter_list))
(setq filter_list (cons type-layer filter_list))))
(foreach filter filter_list
(princ (strcat "selecting all " (cdar filter) " entities on layer " (cdadr filter) "...\n"))
(setq sstemp (ssget "X" filter))
(setq ss1 (ss:union ss1 sstemp)
(sssetfirst nil ss1)
(defun ss:union (ss1 ss2 / ename ss-smaller ss-larger c)
(cond ((and ss1 ss2)
(setq c 0)
(if (< (sslength ss1) (sslength ss2))
(setq ss-smaller ss1
(setq ss-larger ss1
(while (< c (sslength ss-smaller))
(setq ename (ssname ss-smaller c)
c (1+ c))
(if (not (ssmemb ename ss-larger))
(ssadd ename ss-larger)))
I have used this with success in MAP2005 as well as 2006.
If you’re not sure how to use this code, here are the steps to take:
Copy the above code, paste into notepad, save as SelectSimilar.lsp into an appropriate location on your hard drive.
When in AutoCAD (whatever flavor) type APPLOAD at the command line, navigate to the .lsp file you’ve just created (while accessing APPLOAD look for the little briefcase icon, where you can set to have the routine load on startup).
Once the routine is loaded: select an object, then type ‘selsim’ to run.
Look for my next post on how to add this command to your right-click menu in AutoCAD 2005 and below.