Author Topic: Duplicate Lwpolylines  (Read 6154 times)

0 Members and 1 Guest are viewing this topic.

V-Man

  • Bull Frog
  • Posts: 343
  • I exist therefore I am! Finally Retired!
Duplicate Lwpolylines
« on: July 16, 2007, 03:21:25 PM »

I need some assistance with my code. I want to be able to get the area of all lwpolylines and form the Square footage of each into a list for later camparison.
Once the list is made I want to go back through all lwpolylines one at a time, get the area in SF and compare the SF to the list. If a match is found I want to hatch that particular lwpolyline.
Then it can continue with the rest of the lwpolylines until complete.
(In a nutshell I am trying to find duplicate areas within my floorplan and enote where (if any) they are.

Help please.  Thanks,

Code: [Select]
          (setq ss (ssget "x" '((0 . "lwpolyline") (8 . "ROOMS") (70 . 1))))
(if ss
  (progn
      (setq n (1- (sslength ss)))
         (while (>= n 0)
             (command "_.area" "_o" (ssname ss n))
             (setq a (+ a (getvar "area"))
                     n (1- n))
          )
  )
)
AutoCAD 9 - 2023, AutoCADMap 2008 - 2010, Revit 2012 - 2022, Autocad Civil 3D 2023

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Duplicate Lwpolylines
« Reply #1 on: July 16, 2007, 05:21:35 PM »
Try this:
Code: [Select]
(defun c:test (/ ss lst)
  (if (setq ss (ssget "x" '((0 . "lwpolyline") (8 . "ROOMS") (70 . 1))))
    (progn
      (setq lst (mapcar 'vlax-ename->vla-object (mapcar 'cadr (ssnamex ss))))
      (setq lst (mapcar '(lambda (x) (list x (vla-get-area x))) lst))
    )
  )
  lst
)
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.

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1569
  • Moscow (Russia)
Re: Duplicate Lwpolylines
« Reply #2 on: July 17, 2007, 04:10:25 AM »
Try this:
Code: [Select]
(defun c:test (/ ss lst)
  (if (setq ss (ssget "x" '((0 . "lwpolyline") (8 . "ROOMS") (70 . 1))))
    (progn
      (setq lst (mapcar 'vlax-ename->vla-object (mapcar 'cadr (ssnamex ss))))
      (setq lst (mapcar '(lambda (x) (list x (vla-get-area x))) lst))
    )
  )
  lst
)

Hi Alan!
I have a little cut your code...

Code: [Select]
(defun c:test (/ ss)
  (if (setq ss (ssget "x" '((0 . "lwpolyline") (8 . "ROOMS") (70 . 1))))
    (mapcar 'vlax-curve-getArea (mapcar 'cadr (ssnamex ss)))
  )
)

V-Man

  • Bull Frog
  • Posts: 343
  • I exist therefore I am! Finally Retired!
Re: Duplicate Lwpolylines
« Reply #3 on: July 17, 2007, 07:46:41 AM »
Thanks for replying.

Quote
(defun c:test (/ ss)
  (if (setq ss (ssget "x" '((0 . "lwpolyline") (8 . "ROOMS") (70 . 1))))
    (mapcar 'vlax-curve-getArea (mapcar 'cadr (ssnamex ss)))
  )
)

How do I search through the list to find any duplicate square footage's?
AutoCAD 9 - 2023, AutoCADMap 2008 - 2010, Revit 2012 - 2022, Autocad Civil 3D 2023

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Duplicate Lwpolylines
« Reply #4 on: July 17, 2007, 08:17:55 AM »
Something like this:
Code: [Select]
(defun c:test (/ ss lst result match)
  (if (setq ss (ssget "x" '((0 . "lwpolyline") (8 . "ROOMS") (70 . 1))))
    (progn
    (setq lst (mapcar 'vlax-curve-getArea (mapcar 'cadr (ssnamex ss))))
    (print lst)
    (foreach itm lst
      (setq match (vl-remove-if-not '(lambda(x) (equal itm x 0.0001)) lst))
      (if (> (length match) 1)
        (setq result (cons itm result))
        )
      )
    (print result)
    )
  )
  (princ)
)
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.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Duplicate Lwpolylines
« Reply #5 on: July 17, 2007, 08:20:10 AM »
I have a little cut your code...

Code: [Select]
(defun c:test (/ ss)
  (if (setq ss (ssget "x" '((0 . "lwpolyline") (8 . "ROOMS") (70 . 1))))
    (mapcar 'vlax-curve-getArea (mapcar 'cadr (ssnamex ss)))
  )
)

Hi Evgeniy!  :-)

I just thought he wanted to keep track of the owner of the area.
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.

V-Man

  • Bull Frog
  • Posts: 343
  • I exist therefore I am! Finally Retired!
Re: Duplicate Lwpolylines
« Reply #6 on: July 17, 2007, 08:37:12 AM »
Thanks much Alan.
Now I am in the home stretch. Now I want to go through and get the area of all lwpolylines on the ROOM layer and compare each to the list and where it finds a match then hatch the lwpolyline with the duplicate.
AutoCAD 9 - 2023, AutoCADMap 2008 - 2010, Revit 2012 - 2022, Autocad Civil 3D 2023

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Duplicate Lwpolylines
« Reply #7 on: July 17, 2007, 08:52:44 AM »
I think you have enough parts & pieces to do that.
Put the code together & let's see what you have.
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.

V-Man

  • Bull Frog
  • Posts: 343
  • I exist therefore I am! Finally Retired!
Re: Duplicate Lwpolylines
« Reply #8 on: July 17, 2007, 12:51:17 PM »

First of all Many thanks Alan.
I finally figured it out. Here is the final code.

Code: [Select]
(defun c:getduplicate ( )
(getdupareas)
          (setq ss (ssget "x" '((0 . "lwpolyline") (8 . "ROOM") (70 . 1))))
(if ss
  (repeat (setq n (sslength ss))
    (setq n (1- n))
             (command "_.area" "_o" (ssname ss n))
        (setq a (getvar "area"))
(if (member a result)
(command ".hatch" "HONEY" "140" "" (ssname ss n) "")
)
)
)
)

(defun getdupareas ();(/ ss lst result match)
  (if (setq ss (ssget "x" '((0 . "lwpolyline") (8 . "ROOM") (70 . 1))))
    (progn
    (setq lst (mapcar 'vlax-curve-getArea (mapcar 'cadr (ssnamex ss))))
    ;(print lst)
    (foreach itm lst
      (setq match (vl-remove-if-not '(lambda(x) (equal itm x 0.0001)) lst))
      (if (> (length match) 1)
        (setq result (cons itm result))
        )
      )
    (print result)
    )
  )
  (princ)
)
AutoCAD 9 - 2023, AutoCADMap 2008 - 2010, Revit 2012 - 2022, Autocad Civil 3D 2023

V-Man

  • Bull Frog
  • Posts: 343
  • I exist therefore I am! Finally Retired!
Re: Duplicate Lwpolylines
« Reply #9 on: July 17, 2007, 12:53:42 PM »

I think I spoke to soon. It's not quite working correctly. Help
AutoCAD 9 - 2023, AutoCADMap 2008 - 2010, Revit 2012 - 2022, Autocad Civil 3D 2023

LE

  • Guest
Re: Duplicate Lwpolylines
« Reply #10 on: July 17, 2007, 01:35:11 PM »

I need some assistance with my code. I want to be able to get the area of all lwpolylines and form the Square footage of each into a list for later camparison.
Once the list is made I want to go back through all lwpolylines one at a time, get the area in SF and compare the SF to the list. If a match is found I want to hatch that particular lwpolyline.
Then it can continue with the rest of the lwpolylines until complete.
(In a nutshell I am trying to find duplicate areas within my floorplan and enote where (if any) they are.

Are you sure, that by testing for the area, it will allow you to get the duplicates?.... what happen when one room it is equal to another and it is not a duplicate?... or in your particular case, that never going to happen?

Post a simple drawing if you can, and also, have you tried to use the autocad built-in command overkill and eliminate the duplicates? - i think the word is OVERLAP instead of duplicates....
« Last Edit: July 17, 2007, 01:41:38 PM by LE »

V-Man

  • Bull Frog
  • Posts: 343
  • I exist therefore I am! Finally Retired!
Re: Duplicate Lwpolylines
« Reply #11 on: July 17, 2007, 01:44:48 PM »


Quote
Are you sure, that by testing for the area, it will allow you to get the duplicates?.... what happen when one room it is equal to another and it is not a duplicate?... or in your particular case, that never going to happen?

Post a simple drawing if you can, and also, have you tried to use the autocad built-in command overkill and eliminate the duplicates? - i think the word is OVERLAP instead of duplicates....




You are correct. This is a flaw in the searching for true duplicates. I have ran into the routine finding duplicate areas but not duplicate lwpolylines.
This is a problem that I did not think of. Therefore, the routine I made will not work for what I am trying to get accomplished. As for overkill command, I cannot
use this because our lwpolylines have "smart" information attached via XDATA and if there are 2 lwpolylines occupying the same space I do not know which lwpolyline
has the XDATA attached to it, hence my problem. I was going to use this routine to "locate" the lwpolylines and the user would have to manually check to see which needs
to be deleted. I hope I clarified this.
AutoCAD 9 - 2023, AutoCADMap 2008 - 2010, Revit 2012 - 2022, Autocad Civil 3D 2023

LE

  • Guest
Re: Duplicate Lwpolylines
« Reply #12 on: July 17, 2007, 02:02:32 PM »
You are correct. This is a flaw in the searching for true duplicates. I have ran into the routine finding duplicate areas but not duplicate lwpolylines.
This is a problem that I did not think of. Therefore, the routine I made will not work for what I am trying to get accomplished. As for overkill command, I cannot
use this because our lwpolylines have "smart" information attached via XDATA and if there are 2 lwpolylines occupying the same space I do not know which lwpolyline
has the XDATA attached to it, hence my problem. I was going to use this routine to "locate" the lwpolylines and the user would have to manually check to see which needs
to be deleted. I hope I clarified this.

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.

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)

V-Man

  • Bull Frog
  • Posts: 343
  • I exist therefore I am! Finally Retired!
Re: Duplicate Lwpolylines
« Reply #13 on: July 17, 2007, 03:37:36 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.
AutoCAD 9 - 2023, AutoCADMap 2008 - 2010, Revit 2012 - 2022, Autocad Civil 3D 2023

V-Man

  • Bull Frog
  • Posts: 343
  • I exist therefore I am! Finally Retired!
Re: Duplicate Lwpolylines
« Reply #14 on: July 17, 2007, 03:50:10 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.
AutoCAD 9 - 2023, AutoCADMap 2008 - 2010, Revit 2012 - 2022, Autocad Civil 3D 2023