TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: V-Man on June 22, 2006, 03:32:42 PM

Title: Check 4 open Lwpolyline
Post by: V-Man 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)
     )
 )
)
Title: Re: Check 4 open Lwpolyline
Post by: Tramber 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
Title: Re: Check 4 open Lwpolyline
Post by: hmspe 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
Title: Re: Check 4 open Lwpolyline
Post by: Jeff_M 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>")
                             )
               )
   )
Title: Re: Check 4 open Lwpolyline
Post by: V-Man on June 23, 2006, 06:35:23 AM

Thanks guys, that did it. Much appreciated.