Jump to content

Recommended Posts

Posted

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.

image.png.1f2d2620be600d33e0bc59c552357874.png

sample.dwg

Posted (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)
)

 

2020-03-05_7-47-14.gif

Edited by ronjonp
Posted (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)
)

 

2020-03-05_7-47-14.gif

 

 

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 by amb2301
Posted (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 )

 

image.png

duplicated.dwg

Edited by ronjonp
Posted

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.

Posted

Sorry. I can't do more for this. Looking at your last drawing the mess is too variable.

Posted

Hi friends, is there any lisp to remove this duplicated text alone?

Please help me on this task

Posted
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?

Posted

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.

Posted
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. 🍻

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...