Author Topic: how to know if its duplicate?  (Read 2454 times)

0 Members and 1 Guest are viewing this topic.

rainier

  • Guest
how to know if its duplicate?
« on: July 16, 2007, 12:42:22 AM »
how to know if the line or arc has a duplicate?? in lisp routine??

Adesu

  • Guest
Re: how to know if its duplicate?
« Reply #1 on: July 16, 2007, 01:41:25 AM »
use ssget for first collect data, then describe that data every entity, find start point and compare to other start point.

how to know if the line or arc has a duplicate?? in lisp routine??

rainier

  • Guest
Re: how to know if its duplicate?
« Reply #2 on: July 16, 2007, 01:47:06 AM »
thanks Ade, maybe its up to me to find it out... :-)

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: how to know if its duplicate?
« Reply #3 on: July 16, 2007, 07:28:50 AM »
how to know if the line or arc has a duplicate?? in lisp routine??

YOU must define what is a duplicate.
Which of the DXF codes must be the same before you consider the object a duplicate.
Please tell us specifically which ones.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

gile

  • Gator
  • Posts: 2507
  • Marseille, France
Re: how to know if its duplicate?
« Reply #4 on: July 16, 2007, 07:58:19 AM »
Hi,

Here's a way, it returns the number of times the selected object has been exactely duplicated.
If you don't want to match some properties (layer, color and so on...), had their DXF code to the list in the (vl-remove-if ...) expression.

Code: [Select]
(defun c:duplicated? (/ ent ss)
  (and
    (setq ent (car (entsel)))
    (setq ss (ssget "_X"
    (vl-remove-if
      '(lambda (x) (member (car x) '(-1 5)))
      (entget ent)
    )
     )
    )
    (alert (strcat "\nObject duplicated "
   (itoa (1- (sslength ss)))
   " times."
   )
    )
  )
  (princ)
)
Speaking English as a French Frog

V-Man

  • Bull Frog
  • Posts: 343
  • I exist therefore I am! Finally Retired!
Re: how to know if its duplicate?
« Reply #5 on: July 18, 2007, 06:45:37 AM »

Can this work by instead of selecting a single object but but selecting multiple objects?
AutoCAD 9 - 2023, AutoCADMap 2008 - 2010, Revit 2012 - 2022, Autocad Civil 3D 2023

ronjonp

  • Needs a day job
  • Posts: 7529
Re: how to know if its duplicate?
« Reply #6 on: July 18, 2007, 09:40:53 AM »

Can this work by instead of selecting a single object but but selecting multiple objects?

Try this:

Code: [Select]
(defun c:duplicated? (/ ss1 ent ss)
  (setq ss1 (ssget))
  (if ss1
    (progn
      (setq ss1 (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss1))))
      (mapcar
'(lambda (e)
   (setq ss (ssget "_X"
   (vl-remove-if
     '(lambda (x) (member (car x) '(-1 5)))
     (entget e)
   )
    )
   )
   (alert (strcat "\nObject duplicated "
  (itoa (1- (sslength ss)))
  " times."
  )
   )
)
ss1
      )
    )
  )
  (princ)
)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC