amb2301 Posted March 4, 2020 Posted March 4, 2020 Hi Friends, i have bulk drawings which has been duplicated diagonally with a offset distance of 380.5mm, is it possible to remove duplicated objects in diagonal as shown in below pic, i tried overkill command but its not helping out, please someone help me on this task. sample.dwg Quote
ronjonp Posted March 5, 2020 Posted March 5, 2020 (edited) Give this a try. Not the fastest but better than nothing. (defun c:foo (/ _getbbm a b c p p1 p2 r s) ;; RJP » 2020-03-05 ;; Deletes duplicate objects based on center of bounding box and two reference points ;; Disclaimer: Written for fun, logic is most likely flawed in one way or another ;), USE AT YOUR OWN RISK (defun _getbbm (e / ll ur r) (and (not (vl-catch-all-error-p (vl-catch-all-apply 'vla-getboundingbox (list (vlax-ename->vla-object e) 'll 'ur)) ) ) (mapcar 'set '(ll ur) (mapcar 'vlax-safearray->list (list ll ur))) (setq r (list (mapcar '/ (mapcar '+ ll ur) '(2. 2.)) e)) ) r ) (cond ((and (setq p1 (getpoint "\nPick first object reference point: ")) (setq p2 (getpoint p1 "\nPick second object reference point: ")) (setq s (ssget "_:L")) ) (setq p1 (mapcar '+ (mapcar 'abs (mapcar '- p1 p2)) '(0 0))) (foreach e (vl-remove-if 'listp (mapcar 'cadr (ssnamex s))) (and (setq a (_getbbm e)) (setq r (cons a r))) ) (setq b (setq r (vl-sort r '(lambda (r j) (< (cadar r) (cadar j)))))) (foreach e r (setq p (mapcar '+ (car e) p1)) (cond ((setq c (vl-some '(lambda (x) (if (equal (car x) p 1e-2) x ) ) b ) ) (setq b (vl-remove c b)) ;; (entmod (append (entget (cadr c)) '((62 . 1)))) (entdel (cadr c)) ) ) ) ) ) (princ) ) Edited March 5, 2020 by ronjonp Quote
amb2301 Posted March 5, 2020 Author Posted March 5, 2020 (edited) 21 hours ago, ronjonp said: Give this a try. Not the fastest but better than nothing. (defun c:foo (/ _getbbm a b c p p1 p2 r s) ;; RJP » 2020-03-05 ;; Deletes duplicate objects based on center of bounding box and two reference points ;; Disclaimer: Written for fun, logic is most likely flawed in one way or another ;), USE AT YOUR OWN RISK (defun _getbbm (e / ll ur r) (and (not (vl-catch-all-error-p (vl-catch-all-apply 'vla-getboundingbox (list (vlax-ename->vla-object e) 'll 'ur)) ) ) (mapcar 'set '(ll ur) (mapcar 'vlax-safearray->list (list ll ur))) (setq r (list (mapcar '/ (mapcar '+ ll ur) '(2. 2.)) e)) ) r ) (cond ((and (setq p1 (getpoint "\nPick first object reference point: ")) (setq p2 (getpoint p1 "\nPick second object reference point: ")) (setq s (ssget "_:L")) ) (setq p1 (mapcar '+ (mapcar 'abs (mapcar '- p1 p2)) '(0 0))) (foreach e (vl-remove-if 'listp (mapcar 'cadr (ssnamex s))) (and (setq a (_getbbm e)) (setq r (cons a r))) ) (setq b (setq r (vl-sort r '(lambda (r j) (< (cadar r) (cadar j)))))) (foreach e r (setq p (mapcar '+ (car e) p1)) (cond ((setq c (vl-some '(lambda (x) (if (equal (car x) p 1e-4) x ) ) b ) ) (setq b (vl-remove c b)) ;; (entmod (append (entget (cadr c)) '((62 . 1)))) (entdel (cadr c)) ) ) ) ) ) (princ) ) Hi Ronjonp, Thank you so much for Understanding my query & prompt response on this task, I checked the lisp in my drawing, its awesome, worked like a charm, it removed all the duplicates in drawings, one small problem i found is, in some locations texts are not getting removed, i have attached the whole drawing itself, could you please check & provide your valuable solution. Edited March 6, 2020 by amb2301 Quote
ronjonp Posted March 5, 2020 Posted March 5, 2020 (edited) That text is not an exact copy of the rest of the items. Do another reference point for them or up the fuzz value here (1e-1): 2 hours ago, ronjonp said: (if (equal (car x) p 1e-4) x ) duplicated.dwg Edited March 5, 2020 by ronjonp Quote
amb2301 Posted March 5, 2020 Author Posted March 5, 2020 Hi Ronjonp, i tried to remove the text by using another reference point, but its removing one text at that moment, not able to remove all, is there any other way to overcome this problem Please help me. Quote
ronjonp Posted March 5, 2020 Posted March 5, 2020 Sorry. I can't do more for this. Looking at your last drawing the mess is too variable. Quote
amb2301 Posted March 6, 2020 Author Posted March 6, 2020 Hi friends, is there any lisp to remove this duplicated text alone? Please help me on this task Quote
ronjonp Posted March 6, 2020 Posted March 6, 2020 12 hours ago, amb2301 said: Hi friends, is there any lisp to remove this duplicated text alone? Please help me on this task The code I have is a good start ... but when there is inconsistent data how is one to know all the different scenarios to solve for? Quote
amb2301 Posted March 9, 2020 Author Posted March 9, 2020 Hi Ronjonp, Thank you so much, i have updated the fuzz value to (1e-1): its working now, its removing duplicates all over the drawing. Quote
ronjonp Posted March 9, 2020 Posted March 9, 2020 4 hours ago, amb2301 said: Hi Ronjonp, Thank you so much, i have updated the fuzz value to (1e-1): its working now, its removing duplicates all over the drawing. Glad it's working for you. Quote
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.