Author Topic: Duplicate Lwpolylines  (Read 6040 times)

0 Members and 1 Guest are viewing this topic.

LE

  • Guest
Re: Duplicate Lwpolylines
« Reply #15 on: July 17, 2007, 04:52:14 PM »

Quote
I see, I do not have my old lisp functions here (where I'm doing some cleaning) I think I might have something and for the xdata, that can be easy to filter out too.. If I do/can I'll post here later.

That would be great. Can you or anyone out there have any ideas on how to accomplish what I am trying to do?

Quote
ps> for your signature, you use map, have you tried to use the clean-up tools (some say are pretty good, and could work for this case)

Yea I tried to use them with no luck.

As I said, if I find the function I did for something similar, I'll post the function here... lately I do not write in lisp anymore, only post old code.

LE

  • Guest
Re: Duplicate Lwpolylines
« Reply #16 on: July 18, 2007, 06:14:11 PM »
Don;

Looks like you have being help by Gile using his nice simple function no?... good then!

V-Man

  • Bull Frog
  • Posts: 343
  • I exist therefore I am! Finally Retired!
Re: Duplicate Lwpolylines
« Reply #17 on: July 19, 2007, 07:49:59 AM »

Yea, I saw that there was another thread basically doing what I want. I did request if the routine by Gile could be made for multiple selection and ronjonp was so nice to respond with..... Thanks ronjonp
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)
)


But... It gives you an alert dialog for every instance. I would like for it to hatch each duplicate not alert.
Almost there but I need a little assistance.

Thanks
AutoCAD 9 - 2023, AutoCADMap 2008 - 2010, Revit 2012 - 2022, Autocad Civil 3D 2023

ronjonp

  • Needs a day job
  • Posts: 7526
Re: Duplicate Lwpolylines
« Reply #18 on: July 19, 2007, 12:57:04 PM »

Yea, I saw that there was another thread basically doing what I want. I did request if the routine by Gile could be made for multiple selection and ronjonp was so nice to respond with..... Thanks ronjonp
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)
)


But... It gives you an alert dialog for every instance. I would like for it to hatch each duplicate not alert.
Almost there but I need a little assistance.

Thanks

dvarino,

See if this doees what you need:

Code: [Select]
(defun c:fdcp (/ ss3 ss2 ss1 ent ss hatch)
[color=blue]  (setq ss1 (ssget
      '((0 . "lwpolyline")
;;(8 . "ROOMS")
(-4 . "<or")
(70 . 1)
(70 . 129)
(-4 . "or>")
       )
    )
  )[/color]
  (if ss1
    (progn
      (setq ss1 (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss1))))
      (mapcar
'(lambda (e)
   (if (not (member e ss2))
     (progn
       (setq
ss (ssget "_X"
   (vl-remove-if
     '(lambda (x) (member (car x) '(-1 5)))
     (entget e)
   )
    )
       )
       (if (/= (1- (sslength ss)) 0)
(progn
   (setq
     ss2 (mapcar 'cadr (ssnamex ss))
     ss3 (vl-remove (nth 0 ss2) ss2)
   )
   (princ (strcat "\n"
  (itoa (1- (sslength ss)))
  " duplicates..."
  )
   )
   (mapcar '(lambda (e)
      (setq hatch (vlax-invoke
    (vla-get-modelspace
      (vla-get-activedocument
(vlax-get-acad-object)
      )
    )
    'addhatch
    acHatchObject
    "SOLID"
    :vlax-true
  )
      )
      (vlax-invoke
hatch
'appendouterloop
(list (vlax-ename->vla-object e))
      )
      (vla-evaluate hatch)
    )
   ss3
   )
)
       )
     )
   )
)
ss1
      )
    )
  )
  (princ)
)

Ron
« Last Edit: July 19, 2007, 01:50:23 PM by ronjonp »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

V-Man

  • Bull Frog
  • Posts: 343
  • I exist therefore I am! Finally Retired!
Re: Duplicate Lwpolylines
« Reply #19 on: July 19, 2007, 01:23:42 PM »
I get the following when I select the lwpolylines...

Quote
Command:
DUPLICATED?
Select objects: Specify opposite corner: 2 found

Select objects:

1 duplicates...; error: Parameter not optional
AutoCAD 9 - 2023, AutoCADMap 2008 - 2010, Revit 2012 - 2022, Autocad Civil 3D 2023

ronjonp

  • Needs a day job
  • Posts: 7526
Re: Duplicate Lwpolylines
« Reply #20 on: July 19, 2007, 01:27:45 PM »
Possibly you selected a polyline that was not closed?

*edit I updated the code above to select only closed polylines regardless of PLINEGEN setting.

See if that helps.
« Last Edit: July 19, 2007, 01:40:26 PM by ronjonp »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

V-Man

  • Bull Frog
  • Posts: 343
  • I exist therefore I am! Finally Retired!
Re: Duplicate Lwpolylines
« Reply #21 on: July 19, 2007, 04:22:27 PM »

Still a no go. I get the same error. I did notice that fi there are no duplicates at all then the routine does not fail (error out) but if there ARE duplicates then I get......

Quote
I get the following when I select the lwpolylines...


Quote
Command:
DUPLICATED?
Select objects: Specify opposite corner: 2 found

Select objects:

1 duplicates...; error: Parameter not optional

This is after I used your revised code.
AutoCAD 9 - 2023, AutoCADMap 2008 - 2010, Revit 2012 - 2022, Autocad Civil 3D 2023

ronjonp

  • Needs a day job
  • Posts: 7526
Re: Duplicate Lwpolylines
« Reply #22 on: July 19, 2007, 05:00:57 PM »
How about a different identifier than hatch....give this a whirl:

Code: [Select]
(defun c:fdcp (/ ss3 ss2 ss1 ent ss hatch obj)
  (setq ss1 (ssget
      '((0 . "lwpolyline")
;;(8 . "ROOMS")
(-4 . "<or")
(70 . 1)
(70 . 129)
(-4 . "or>")
       )
    )
  )
  (if ss1
    (progn
      (setq ss1 (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss1))))
      (mapcar
'(lambda (e)
   (if (not (member e ss2))
     (progn
       (setq
ss (ssget "_X"
   (vl-remove-if
     '(lambda (x) (member (car x) '(-1 5)))
     (entget e)
   )
    )
       )
       (if (/= (1- (sslength ss)) 0)
(progn
   (setq
     ss2 (mapcar 'cadr (ssnamex ss))
     ss3 (vl-remove (nth 0 ss2) ss2)
   )
   (princ (strcat "\n"
  (itoa (1- (sslength ss)))
  " duplicates..."
  )
   )
   (mapcar '(lambda (e)
      (setq obj (vlax-ename->vla-object e))
[color=green]       (vla-put-constantwidth obj 2)
      (vla-put-color obj 3)[/color]
    )
   ss3
   )
)
       )
     )
   )
)
ss1
      )
    )
  )
  (princ)
)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

V-Man

  • Bull Frog
  • Posts: 343
  • I exist therefore I am! Finally Retired!
Re: Duplicate Lwpolylines
« Reply #23 on: July 19, 2007, 05:44:14 PM »

Worked like a dream. Many thanks to you ronjonp.

AutoCAD 9 - 2023, AutoCADMap 2008 - 2010, Revit 2012 - 2022, Autocad Civil 3D 2023

ronjonp

  • Needs a day job
  • Posts: 7526
Re: Duplicate Lwpolylines
« Reply #24 on: July 19, 2007, 05:46:19 PM »
Glad it worked for you :)......

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC