;; | ---------------------------------------------------------------------------- ;; | Check for Duplicate Objects ;; | ---------------------------------------------------------------------------- ;; | Function : Checks to see if duplicate objects exist in the drawing. ;; | Author : Rakesh Rao ;; | Argument : ;; | 'ss' - selection set to be checked. ;; | 'ChkXdata' - If T, verify Xdata equivalence also. ;; | 'ChkLyr' - If T, verify Layer also. ;; | 'ChkObjData' - If T, verify Object Data Equality also. ;; | 'IgnoreZ' - If T, ignore Z elevation values while checking ;; | coordinates. ;; | 'Diff' - Fuzzy tolerance value ;; | Action : Checks if there are duplicate objects in the selection set. ;; | Additionally, the duplication can be detected on the basis of ;; | Xdata and/or layer match. ;; | Updated : April 16, 1998 ;; | Comments : Uses append, not efficient, needs changing over to cons ;; | e-mail : rakesh.rao@4d-technologies.com ;; | Web : www.4d-technologies.com ;; | ---------------------------------------------------------------------------- (defun MI_ChkDup ( ss ChkXdata ChkLyr ChkObjData IgnoreZ Diff / EllipseLst ImageLst InsertLst LeaderLst LineLst MlineLst MtextLst RegionLst PointLst PolylineLst ShapeLst SolidLst SplineLst TextLst TraceLst 3DFaceLst 3DSolidLst ArcLst AttdefLst CircleLst DimensionLst DupSS xd Lst cnt en ename entl ETok1 ETok2 ETok la ssl vlist tmp tmp1 ) (setq DupSS (ssadd)) (if ss (progn (setq Lst '() EllipseLst '() ImageLst '() InsertLst '() LeaderLst '() LineLst '() MlineLst '() MtextLst '() RegionLst '() PointLst '() PolylineLst '() ShapeLst '() SolidLst '() SplineLst '() TextLst '() TraceLst '() 3DFaceLst '() 3DSolidLst '() ArcLst '() AttdefLst '() CircleLst '() DimensionLst '() ssl (sslength ss) tmp (strcat " of " (itoa ssl)) cnt 0 ) (princ "\n") (repeat ssl (setq ename (ssname ss cnt) entl (entget ename) en (LI_item 0 entl) xd (cdr (assoc -3 (entget ename (list "*")))) la (LI_item 8 entl) cnt (1+ cnt) ) (cond ((= en "ELLIPSE") (setq pt10 (LI_item 10 entl) pt11 (LI_item 11 entl) ) (if IgnoreZ (setq pt10 (MI_Point2d pt10) pt11 (MI_Point2d pt11) ) ) (setq ETok (list pt10 pt11 (LI_item 40 entl) (LI_item 41 entl) (LI_item 42 entl) ) ) (if ChkLyr (setq ETok (append ETok (list la)))) (if (and xd ChkXdata) (setq ETok (append ETok (list xd)))) (if (and EllipseLst (LI_memb ETok EllipseLst Diff)) (ssadd ename DupSS) (setq EllipseLst (append EllipseLst (list ETok))) ) ) ((= en "INSERT") (setq pt10 (LI_item 10 entl)) (if IgnoreZ (setq pt10 (MI_Point2d pt10)) ) (setq ETok (list pt10 (LI_item 41 entl) (LI_item 42 entl) (LI_item 43 entl) (MI_r2d (LI_item 50 entl)) ) ) (setq tmp1 (LI_item 2 entl)) (if (and (> (strlen tmp1) 1) (= (substr tmp1 1 1) "*") (= (substr tmp1 2 1) "U") ) (prin1) (setq ETok (cons tmp1 ETok)) ) (if (setq Lst (BL_GetAtts ename)) (setq ETok (append ETok (list Lst))) ) (if ChkLyr (setq ETok (append ETok (list la)))) (if (and xd ChkXdata) (setq ETok (append ETok (list xd)))) (if (and InsertLst (LI_memb ETok InsertLst Diff)) (ssadd ename DupSS) (setq InsertLst (append InsertLst (list ETok))) ) ) ((= en "LEADER") (setq ETok (list (LI_CodeStrip entl (list -1 0 3 5 8 100 210 211 212 340)))) (if ChkLyr (setq ETok (append ETok (list la)))) (if (and xd ChkXdata) (setq ETok (append ETok (list xd)))) (if (and LeaderLst (LI_memb ETok LeaderLst Diff)) (ssadd ename DupSS) (setq LeaderLst (append LeaderLst (list ETok))) ) ) ((= en "LINE") (setq pt10 (LI_item 10 entl) pt11 (LI_item 11 entl) ) (if IgnoreZ (setq pt10 (MI_Point2d pt10) pt11 (MI_Point2d pt11) ) ) (setq ETok1 (list pt10 pt11) ETok2 (list pt11 pt10) ) (if ChkLyr (setq ETok1 (append ETok1 (list la)))) (if (and xd ChkXdata) (setq ETok1 (append ETok1 (list xd)))) (if ChkLyr (setq ETok2 (append ETok2 (list la)))) (if (and xd ChkXdata) (setq ETok2 (append ETok2 (list xd)))) (if (and LineLst (or (LI_memb ETok1 LineLst Diff) (LI_memb ETok2 LineLst Diff))) (ssadd ename DupSS) (setq LineLst (append LineLst (list ETok1)) LineLst (append LineLst (list ETok2)) ) ) ) ((= en "MLINE") (setq ETok (list (LI_CodeStrip entl (list -1 0 2 5 8 100 340)))) (if ChkLyr (setq ETok (append ETok (list la)))) (if (and xd ChkXdata) (setq ETok (append ETok (list xd)))) (if (and LeaderLst (LI_memb ETok LeaderLst Diff)) (ssadd ename DupSS) (setq LeaderLst (append LeaderLst (list ETok))) ) ) ((= en "MTEXT") (setq pt10 (LI_item 10 entl)) (if IgnoreZ (setq pt10 (MI_Point2d pt10)) ) (setq ETok (list (LI_item 1 entl) pt10 (LI_item 11 entl) (LI_item 40 entl) (LI_item 41 entl) (LI_item 67 entl) (LI_item 71 entl) (LI_item 72 entl) ) ) (if ChkLyr (setq ETok (append ETok (list la)))) (if (and xd ChkXdata) (setq ETok (append ETok (list xd)))) (if (and MTextLst (LI_memb ETok MTextLst Diff)) (ssadd ename DupSS) (setq MTextLst (append MTextLst (list ETok))) ) ) ((= en "REGION") (setq ETok (list ename)) (if ChkLyr (setq ETok (append ETok (list la)))) (if (and xd ChkXdata) (setq ETok (append ETok (list xd)))) (if (and RegionLst (LI_memb ETok RegionLst Diff)) (ssadd ename DupSS) (setq RegionLst (append RegionLst (list ETok))) ) ) ((= en "POINT") (setq pt10 (LI_item 10 entl)) (if IgnoreZ (setq pt10 (MI_Point2d pt10)) ) (setq ETok (list pt10)) (if ChkLyr (setq ETok (append ETok (list la)))) (if (and xd ChkXdata) (setq ETok (append ETok (list xd)))) (if (and PointLst (LI_memb ETok PointLst Diff)) (ssadd ename DupSS) (setq PointLst (append PointLst (list ETok))) ) ) ((member en (list "POLYLINE" "LWPOLYLINE")) (setq vlist (PL_plist ename)) (if IgnoreZ (setq vlist (GE_plist3d2d vlist "Zero")) ) (setq ETok1 (list vlist) ETok2 (list (reverse vlist)) ) (if ChkLyr (setq ETok1 (append ETok1 (list la)))) (if (and xd ChkXdata) (setq ETok1 (append ETok1 (list xd)))) (if ChkLyr (setq ETok2 (append ETok2 (list la)))) (if (and xd ChkXdata) (setq ETok2 (append ETok2 (list xd)))) (if (and PolylineLst (or (LI_memb ETok1 PolylineLst Diff) (LI_memb ETok2 PolylineLst Diff))) (ssadd ename DupSS) (setq PolylineLst (append PolylineLst (list ETok1 ETok2))) ) ) ((= en "SHAPE") (setq pt10 (LI_item 10 entl)) (if IgnoreZ (setq pt10 (MI_Point2d pt10)) ) (setq ETok (list pt10 (LI_item 2 entl) (LI_item 40 entl) (LI_item 41 entl) (MI_r2d (LI_item 50 entl)) (MI_r2d (LI_item 51 entl)) ) ) (if ChkLyr (setq ETok (append ETok (list la)))) (if (and xd ChkXdata) (setq ETok (append ETok (list xd)))) (if (and ShapeLst (LI_memb ETok ShapeLst Diff)) (ssadd ename DupSS) (setq ShapeLst (append ShapeLst (list ETok))) ) ) ((= en "SOLID") (setq pt10 (LI_item 10 entl) pt11 (LI_item 11 entl) pt12 (LI_item 12 entl) pt13 (LI_item 13 entl) ) (if IgnoreZ (setq pt10 (MI_Point2d pt10) pt11 (MI_Point2d pt11) pt12 (MI_Point2d pt12) pt13 (MI_Point2d pt13) ) ) (setq ETok (list pt10 pt11 pt12 pt13)) (if ChkLyr (setq ETok (append ETok (list la)))) (if (and xd ChkXdata) (setq ETok (append ETok (list xd)))) (if (and SolidLst (LI_memb ETok SolidLst Diff)) (ssadd ename DupSS) (setq SolidLst (append SolidLst (list ETok))) ) ) ((= en "SPLINE") (setq ETok (list ename)) (if ChkLyr (setq ETok (append ETok (list la)))) (if (and xd ChkXdata) (setq ETok (append ETok (list xd)))) (if (and SplineLst (LI_memb ETok SplineLst Diff)) (ssadd ename DupSS) (setq SplineLst (append SplineLst (list ETok))) ) ) ((= en "TEXT") (setq pt10 (LI_item 10 entl) pt11 (LI_item 11 entl) ) (if IgnoreZ (setq pt10 (MI_Point2d pt10) pt11 (MI_Point2d pt11) ) ) (setq ETok (list pt10 pt11 (LI_item 40 entl) (LI_item 41 entl) (MI_r2d (LI_item 50 entl)) (LI_item 1 entl) (LI_item 71 entl) (LI_item 72 entl) ) ) (if ChkLyr (setq ETok (append ETok (list la)))) (if (and xd ChkXdata) (setq ETok (append ETok (list xd)))) (if (and TextLst (LI_memb ETok TextLst Diff)) (ssadd ename DupSS) (setq TextLst (append TextLst (list ETok))) ) ) ((= en "TRACE") (setq pt10 (LI_item 10 entl) pt11 (LI_item 11 entl) pt12 (LI_item 12 entl) pt13 (LI_item 13 entl) ) (if IgnoreZ (setq pt10 (MI_Point2d pt10) pt11 (MI_Point2d pt11) pt12 (MI_Point2d pt12) pt13 (MI_Point2d pt13) ) ) (setq ETok (list pt10 pt11 pt12 pt13)) (if ChkLyr (setq ETok (append ETok (list la)))) (if (and xd ChkXdata) (setq ETok (append ETok (list xd)))) (if (and TraceLst (LI_memb ETok TraceLst Diff)) (ssadd ename DupSS) (setq TraceLst (append TraceLst (list ETok))) ) ) ((= en "3DFACE") (setq pt10 (LI_item 10 entl) pt11 (LI_item 11 entl) pt12 (LI_item 12 entl) pt13 (LI_item 13 entl) ) (if IgnoreZ (setq pt10 (MI_Point2d pt10) pt11 (MI_Point2d pt11) pt12 (MI_Point2d pt12) pt13 (MI_Point2d pt13) ) ) (setq ETok (list pt10 pt11 pt12 pt13)) (if ChkLyr (setq ETok (append ETok (list la)))) (if (and xd ChkXdata) (setq ETok (append ETok (list xd)))) (if (and 3DFaceLst (LI_memb ETok 3DFaceLst Diff)) (ssadd ename DupSS) (setq 3DFaceLst (append 3DFaceLst (list ETok))) ) ) ((= en "3DSOLID") (setq ETok (list ename)) (if ChkLyr (setq ETok (append ETok (list la)))) (if (and xd ChkXdata) (setq ETok (append ETok (list xd)))) (if (and 3DSolidLst (LI_memb ETok 3DSolidLst Diff)) (ssadd ename DupSS) (setq 3DSolidLst (append 3DSolidLst (list ETok))) ) ) ((= en "ARC") (setq pt10 (LI_item 10 entl)) (if IgnoreZ (setq pt10 (MI_Point2d pt10)) ) (setq ETok (list pt10 (LI_item 40 entl) (MI_r2d (LI_item 50 entl)) (MI_r2d (LI_item 51 entl)) ) ) (if ChkLyr (setq ETok (append ETok (list la)))) (if (and xd ChkXdata) (setq ETok (append ETok (list xd)))) (if (and ArcLst (LI_memb ETok ArcLst Diff)) (ssadd ename DupSS) (setq ArcLst (append ArcLst (list ETok))) ) ) ((= en "ATTDEF") (setq pt10 (LI_item 10 entl) pt11 (LI_item 11 entl) ) (if IgnoreZ (setq pt10 (MI_Point2d pt10) pt11 (MI_Point2d pt11) ) ) (setq ETok (list pt10 pt11 (LI_item 1 entl) (LI_item 2 entl) (LI_item 3 entl) (LI_item 40 entl) (LI_item 41 entl) (MI_r2d (LI_item 50 entl)) (MI_r2d (LI_item 51 entl)) (LI_item 70 entl) (LI_item 71 entl) (LI_item 72 entl) (LI_item 73 entl) (LI_item 74 entl) ) ) (if ChkLyr (setq ETok (append ETok (list la)))) (if (and xd ChkXdata) (setq ETok (append ETok (list xd)))) (if (and AttdefLst (LI_memb ETok AttdefLst Diff)) (ssadd ename DupSS) (setq AttdefLst (append AttdefLst (list ETok))) ) ) ((= en "CIRCLE") (setq pt10 (LI_item 10 entl)) (if IgnoreZ (setq pt10 (MI_Point2d pt10)) ) (setq ETok (list pt10 (LI_item 40 entl))) (if ChkLyr (setq ETok (append ETok (list la)))) (if (and xd ChkXdata) (setq ETok (append ETok (list xd)))) (if (and CircleLst (LI_memb ETok CircleLst Diff)) (ssadd ename DupSS) (setq CircleLst (append CircleLst (list ETok))) ) ) ((= en "DIMENSION") (setq pt10 (LI_item 10 entl) pt11 (LI_item 11 entl) pt12 (LI_item 12 entl) pt13 (LI_item 13 entl) ) (if IgnoreZ (setq pt10 (MI_Point2d pt10) pt11 (MI_Point2d pt11) pt12 (MI_Point2d pt12) pt13 (MI_Point2d pt13) ) ) (setq ETok (list (LI_item 1 entl) (LI_item 2 entl) (LI_item 3 entl) pt10 pt11 pt12 pt13 (LI_item 14 entl) (LI_item 15 entl) (LI_item 16 entl) (LI_item 70 entl) (LI_item 40 entl) (MI_r2d (LI_item 50 entl)) (MI_r2d (LI_item 51 entl)) (MI_r2d (LI_item 52 entl)) (MI_r2d (LI_item 53 entl)) ) ) (if ChkLyr (setq ETok (append ETok (list la)))) (if (and xd ChkXdata) (setq ETok (append ETok (list xd)))) (if (and DimensionLst (LI_memb ETok DimensionLst Diff)) (ssadd ename DupSS) (setq DimensionLst (append DimensionLst (list ETok))) ) ) ) (princ (strcat "\rChecking for duplicate objects..." (itoa cnt) tmp)) ) )) (if (> (sslength DupSS) 0) DupSS nil) )