Rain0923 Posted November 27, 2014 Share Posted November 27, 2014 I know how to use "overlap" in Autocad & I already readed a theme (Help - Select duplicate entities) but it still can't solve my problem. Is any lisp that can select overlapping block & entities(line&pline&circle) and put all overlapping entities in other layer at the same time? example-try to select red entities and put them in other layer at the same time. example.dwg Quote Link to comment Share on other sites More sharing options...
hanhphuc Posted November 28, 2014 Share Posted November 28, 2014 I know how to use "overlap" in Autocad & I already readed a theme (Help - Select duplicate entities) but it still can't solve my problem. Is any lisp that can select overlapping block & entities(line&pline&circle) and put all overlapping entities in other layer at the same time? example-try to select red entities and put them in other layer at the same time. i think your drawing objects not overlap in same position actually (there 2 different blocks) maybe you can try command: qselect ? then filter by layers, color etc.. Quote Link to comment Share on other sites More sharing options...
Rain0923 Posted November 28, 2014 Author Share Posted November 28, 2014 Dear hanhphuc-- Thanks for your reply, actually I have a design and need use many different blocks inside but how can I find overlapping different blocks? (I just put 2 different blocks in my example actually I need to put over 10 different blocks in my design and it real very different find overlapping different blocks:oops:) i think your drawing objects not overlap in same position actually (there 2 different blocks)maybe you can try command: qselect ? then filter by layers, color etc.. example1.dwg Quote Link to comment Share on other sites More sharing options...
hanhphuc Posted November 28, 2014 Share Posted November 28, 2014 (edited) Dear hanhphuc-- Thanks for your reply, actually I have a design and need use many different blocks inside but how can I find overlapping different blocks?(I just put 2 different blocks in my example actually I need to put over 10 different blocks in my design and it real very different find overlapping different blocks:oops:) did you try command: overkill ? though you can try qselect filter by Name, this is isolate method which by fitering block name, you still have to manually test due to i'm not sure which type block you want to keep or erase command: test ;invoke program then pick any reference block entity, it will hide the matched name blocks. the leftover maybe the overlaps. *mark with red circle (optional). (defun c:test1 (/ e e1 i typ ss [color="gray"]vs[/color]) [color="gray"] (setq vs '(nil (/ (getvar 'viewsize) (cadr (getvar 'screensize)))))[/color] ; *optional (if (and (setq e (entsel "\nSelect reference block.. ")) (setq e (car e) typ (cdr (assoc 2 (entget e))) ss (ssget ":L" (list '(0 . "INSERT")));(cons 2 name) ) ;_ end of setq ) ;_ end of and (repeat (setq i (sslength ss)) (setq e1 (ssname ss (setq i (1- i)))) (if (equal typ (cdr (assoc 2 (entget e1))) ) (redraw e1 2) [color="red"](redraw e1 3)[/color] ;comment this if entmake circle [color="gray"];;; (entmake (list '(0 . "CIRCLE") ;*optional ;;; '(8 . "highlight") ;;; '(62 . 1) ;;; (cons 40 (* (vs) 5.)) ;;; (cons 10 (cdr (assoc 10 (entget e1)))) ;;; ) ;_ end of list ;;; ) ;_ end of entmake[/color] ) ;_ end of if ) ;_ end of repeat ) ;_ end of if (princ) ) ;_ end of defun step by step , repeat to test the leftover... command: regen ;to restore hidden blocks HTH Edited November 28, 2014 by hanhphuc *in grey: entmake circle is optional / red* optional Quote Link to comment Share on other sites More sharing options...
Rain0923 Posted November 28, 2014 Author Share Posted November 28, 2014 Dear hanhphuc, Thanks, overkill can't use for block. Pls have a review the example2. There are many blocks in my DWG. I want all blocks but there are two blocks overlapping(just like pink area) how can I find this overlapping in this drawing quickly? Please advise me, thanks thanks thanks:cry: did you try command: overkill ? though you can try qselect filter by Name, this is isolate method which by fitering block name, you still have to manually test due to i'm not sure which type block you want to keep or erase command: test ;invoke program then pick any reference block entity, it will hide the matched name blocks. the leftover maybe the overlaps. mark with red circle. (defun c:test (/ e e1 i vs typ ss) (setq vs '(nil (/ (getvar 'viewsize) (cadr (getvar 'screensize))))) (if (and (setq e (entsel "\nSelect reference block.. ")) (setq e (car e) typ (cdr (assoc 2 (entget e))) ss (ssget "X" (list '(0 . "INSERT")));(cons 2 name) ) ;_ end of setq ) ;_ end of and (repeat (setq i (sslength ss)) (setq e1 (ssname ss (setq i (1- i)))) (if (eq typ (cdr (assoc 2 (entget e1)))) (redraw e1 2) (entmake (list '(0 . "CIRCLE") '(8 . "highlight") '(62 . 1) (cons 40 (* (vs) 5.)) (cons 10 (cdr (assoc 10 (entget e1)))) ) ;_ end of list ) ;_ end of entmake ) ;_ end of if ) ;_ end of repeat ) ;_ end of if (princ) ) ;_ end of defun step by step , repeat to test the leftover... command: regen ;to restore hidden blocks HTH example2.dwg Quote Link to comment Share on other sites More sharing options...
Tharwat Posted November 28, 2014 Share Posted November 28, 2014 I hope that hanhphuc won't mind if I posted my attempt . Be careful that this may delete the other block and not the required one and that's why I gave the user the chance to select blocks to see the changes clearly . (defun c:Test (/ s) ;; Tharwat 28.11.2014 ;; (if (setq s (ssget "_:L" '((0 . "INSERT")))) ((lambda (x / a b ss i _sn sn) (while (setq _sn (ssname s (setq x (1+ x)))) (vla-getboundingbox (vlax-ename->vla-object _sn) 'a 'b) (if (setq ss (ssget "_C" (vlax-safearray->list a) (vlax-safearray->list b) '((0 . "INSERT")) ) ) (repeat (setq i (sslength ss)) (if (not (eq (setq sn (ssname ss (setq i (1- i)))) _sn)) (entdel _sn) ) ) ) ) ) -1 ) ) (princ) )(vl-load-com) Quote Link to comment Share on other sites More sharing options...
hanhphuc Posted November 28, 2014 Share Posted November 28, 2014 Dear hanhphuc,Thanks, overkill can't use for block. Pls have a review the example2. There are many blocks in my DWG. I want all blocks but there are two blocks overlapping(just like pink area) how can I find this overlapping in this drawing quickly? Please advise me, thanks thanks thanks:cry: Just a normal filter for insertion points then hide if not overlap, ie: the rest visible blocks are considered "overlap" ,you decide yourself to erase manually. command: ubi ;unique block insertion ;hide if insertion points are unique (defun c:ubi ( / e ss lst l) (setq ss (ssget ":L" (list '(0 . "INSERT")))) (setq lst (acet-ss-to-list ss) ) (while lst (setq l (cons (setq e (car lst)) l) lst (cdr lst) lst (vl-remove-if ''((x)(equal (cdr(assoc 10 (entget e ))) (cdr(assoc 10 (entget x) )) 1e-3)) lst)) ) (foreach x l (redraw x 2)) (princ)) use this as genaral filter, then use Tharwat's finer tune or the previous post#4 Quote Link to comment Share on other sites More sharing options...
Rain0923 Posted December 1, 2014 Author Share Posted December 1, 2014 Dear Tharwat, Thanks a lot!! I hope that hanhphuc won't mind if I posted my attempt . Be careful that this may delete the other block and not the required one and that's why I gave the user the chance to select blocks to see the changes clearly . (defun c:Test (/ s) ;; Tharwat 28.11.2014 ;; (if (setq s (ssget "_:L" '((0 . "INSERT")))) ((lambda (x / a b ss i _sn sn) (while (setq _sn (ssname s (setq x (1+ x)))) (vla-getboundingbox (vlax-ename->vla-object _sn) 'a 'b) (if (setq ss (ssget "_C" (vlax-safearray->list a) (vlax-safearray->list b) '((0 . "INSERT")) ) ) (repeat (setq i (sslength ss)) (if (not (eq (setq sn (ssname ss (setq i (1- i)))) _sn)) (entdel _sn) ) ) ) ) ) -1 ) ) (princ) )(vl-load-com) Quote Link to comment Share on other sites More sharing options...
Rain0923 Posted December 1, 2014 Author Share Posted December 1, 2014 Dear hanhphuc, Thank you for your help!! Just a normal filter for insertion points then hide if not overlap,ie: the rest visible blocks are considered "overlap" ,you decide yourself to erase manually. command: ubi ;unique block insertion ;hide if insertion points are unique (defun c:ubi ( / e ss lst l) (setq ss (ssget ":L" (list '(0 . "INSERT")))) (setq lst (acet-ss-to-list ss) ) (while lst (setq l (cons (setq e (car lst)) l) lst (cdr lst) lst (vl-remove-if ''((x)(equal (cdr(assoc 10 (entget e ))) (cdr(assoc 10 (entget x) )) 1e-3)) lst)) ) (foreach x l (redraw x 2)) (princ)) use this as genaral filter, then use Tharwat's finer tune or the previous post#4 Quote Link to comment Share on other sites More sharing options...
Tharwat Posted December 1, 2014 Share Posted December 1, 2014 Dear Tharwat,Thanks a lot!! You're welcome . Quote Link to comment Share on other sites More sharing options...
hanhphuc Posted December 1, 2014 Share Posted December 1, 2014 Dear hanhphuc,Thank you for your help!! You are welcome! Rain0923 I hope that hanhphuc won't mind if I posted my attempt . Thank you Tharwat, i don't mind but i welcome you as long as OP issue solve!! i could also learn better solution from you guys too Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.