;| Select Similar (based on a command found in a few versions of AutoCAD-based products) written by Adam Wuellner all rights released Edited by Marc Scherer for www.cad.de Changes: The selsim command now identifies the "Simliar" Objects not only by the Entity-Type and Layername. The Identification is based on the resulting entget-list from the Sub-Function "FILTER-DXFCODES". This Function first removes all DXF-Codes which Datatypes are not String or Real (f.e. Layernames, Textstyles, Hatchnames, Textheights...) Then it removes all DXF-Codes that are defined in the second Argument of the member function within. Feel free to change this List for your own purposes. You can find this List if you search this code for the Text: "Here is the List of DXF-Codes that have to be removed" |; (defun C:SELSIM (/ SS1 I ENT FILTER_LIST TYPE-LAYER FILTER SSTEMP) (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 SS-LARGER SS2 ) (setq SS-LARGER SS1 SS-SMALLER SS2 ) ) (while (< C (sslength SS-SMALLER)) (setq ENAME (ssname SS-SMALLER C) C (1+ C) ) (if (not (ssmemb ENAME SS-LARGER)) (ssadd ENAME SS-LARGER) ) ) SS-LARGER ) (SS1 SS1) (SS2 SS2) (t NIL) ) ) (defun FILTER-DXFCODES (LST-ENTGETDATA /) ;; At first remove all DXF-Codes which Datatypes are not String or Real (if (setq LST-ENTGETDATA (vl-remove-if-not '(lambda (X) (setq OBJTYPE (type (cdr X))) (or (= OBJTYPE 'STR) (= OBJTYPE 'REAL)) ) LST-ENTGETDATA ) ) ;; Then remove all DXF-Code that are defined in the second Argument of ;; the member function. Feel free to change this List for your own purposes. (setq LST-ENTGETDATA (vl-remove-if '(lambda (X) (member (car X) ;; Here is the List of DXF-Codes that have to be removed '(1 2 3 5 40 41 42 43 44 45 46 49 50 51 52 53 54 100 102 300 410 460 461 462 470 ) ) ) LST-ENTGETDATA ) ) ) LST-ENTGETDATA ) (if (not (setq SS1 (cadr (ssgetfirst)))) (setq SS1 (ssget)) ) (setq I 0 FILTER_LIST '() ) (repeat (sslength SS1) (setq ENT (FILTER-DXFCODES (entget (ssname SS1 I))) I (1+ I) ) (setq TYPE-LAYER ENT) (if (not (member TYPE-LAYER FILTER_LIST)) (setq FILTER_LIST (cons TYPE-LAYER FILTER_LIST)) ) ) (foreach FILTER FILTER_LIST (princ (strcat "\nFilter: " (vl-prin1-to-string FILTER_LIST) ) ) (setq SSTEMP (ssget "X" FILTER)) (setq SS1 (SS:UNION SS1 SSTEMP) SSTEMP NIL ) ) (sssetfirst NIL SS1) (princ (strcat "\n>" (itoa (sslength SS1)) "< similar Objects selected!" ) ) (princ) ) (princ)