Author Topic: Check 4 open Lwpolyline  (Read 2053 times)

0 Members and 1 Guest are viewing this topic.

V-Man

  • Bull Frog
  • Posts: 343
  • I exist therefore I am! Finally Retired!
Check 4 open Lwpolyline
« on: June 22, 2006, 03:32:42 PM »

I have this routine for checking for open lwpolylines and it does not seem to work. Where is this going wrong?

Code: [Select]
(defun c:ck4open()
(setq a (ssget "x" '((0 . "lwpolyline")
 (8 . "LNK_SPC_UA") (70 . 128)))) ;Please change the (70 . 0) to (70 . 128) for Autocad Map
 (if (= a nil)
     (progn
       (princ "All Polylines are closed!!!")
       (princ)
     )
     (progn
       (setq b (sslength a))
       (command ".chprop" a "" "c" "magenta" "")
       (setq c (strcat (itoa b) " Polyline(s) are not closed, Check Polylines with Magenta color!!!"))
       (princ c) (princ)
     )
 )
)
AutoCAD 9 - 2023, AutoCADMap 2008 - 2010, Revit 2012 - 2022, Autocad Civil 3D 2023

Tramber

  • Guest
Re: Check 4 open Lwpolyline
« Reply #1 on: June 22, 2006, 03:59:21 PM »
Code: [Select]
(setq vpoly(vlax-ename->vla-object(car(entsel))))

(setq rep(vla-get-Closed vpoly))

(= :vlax-true rep)

should help U

hmspe

  • Bull Frog
  • Posts: 362
Re: Check 4 open Lwpolyline
« Reply #2 on: June 22, 2006, 04:03:18 PM »
From a quick look, with no testing:

In plain Autocad I'd change the (70 . 128) to (70 . 0).  The dxf reference for regular Autocad lists 0 as the default value, 1 as the flag bit for a closed lwpolyline, and 128 as the flag bit for Plinegen.  Actually I'd probably grab all the lwpolylines into the selection set then delete the ones that have the 1 bit set in dxf code 70.  dxf code 70 is bit mapped, so bit 128 could be set whether the pline is open or closed.

The other possible issue is dxf code 8, which sets the layer.  As coded the ssget will only include plines on layer 'LNK_SPC_UA'.  Is that what you intend?

Martin
"Science is the belief in the ignorance of experts." - Richard Feynman

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
Re: Check 4 open Lwpolyline
« Reply #3 on: June 22, 2006, 04:54:36 PM »
Chang your ssget to this:
Code: [Select]
(setq a (ssget "x" '((0 . "lwpolyline")
                              (8 . "LNK_SPC_UA")
                              (-4 . "<NOT")
                              (-4 . "&")
                              (70 . 1)
                              (-4 . "NOT>")
                             )
               )
   )

V-Man

  • Bull Frog
  • Posts: 343
  • I exist therefore I am! Finally Retired!
Re: Check 4 open Lwpolyline
« Reply #4 on: June 23, 2006, 06:35:23 AM »

Thanks guys, that did it. Much appreciated.
AutoCAD 9 - 2023, AutoCADMap 2008 - 2010, Revit 2012 - 2022, Autocad Civil 3D 2023