Jump to content

find unclosed polylines


rodrigo_sjc_sp

Recommended Posts

Try this and it would highlight the open polylines .

(defun c:test (/ ss x sn lst l)
 (vl-load-com)
 (if (setq
       ss (ssget "_x"
                 (list '(0 . "*POLYLINE") (cons 410 (getvar 'ctab)))
          )
     )
   (repeat (setq x (sslength ss))
     (setq sn (ssname ss (setq x (1- x))))
     (if (not (vlax-curve-isclosed sn))
       (setq lst (cons sn lst))
     )
   )
 )
 (setq l (ssadd))
 (sssetfirst nil (foreach x lst (ssadd x l)))
 (princ)
)

Link to comment
Share on other sites

(defun c:hipl nil
(sssetfirst nil
 (ssget "_X" '((0 . "*POLYLINE,SPLINE")
     (-4 . "<NOT")(-4 . "<OR")
     (70 . 1) (70 . 9)(70 . 129)
     (-4 . "OR>")(-4 . "NOT>")
     )
   )
 )(princ)
)

Link to comment
Share on other sites

If we take the code Tharvat, and assume that it is sometimes not correctly closed polylines (same start and end), here:

(defun c:test (/ ss x sn lst l)
 (vl-load-com)
 (if (setq
ss (ssget "_x"
	  (list '(0 . "*POLYLINE") (cons 410 (getvar 'ctab)))
   )
     )
   (repeat (setq x (sslength ss))
     (setq sn (ssname ss (setq x (1- x))))
     (if (or
    (vlax-curve-isclosed sn)
    (equal (vlax-curve-getStartPoint sn)
	   (vlax-curve-getEndPoint sn)
    )
  )
(ssdel sn ss)
     )
   )
 )
 (sssetfirst nil ss)
 (princ)
)

Link to comment
Share on other sites

hmmmn makes me wonder what the OP is planning to do with the selected plines

perhaps this:

 

(defun c:hipl ( / p b e)
(vl-load-com)  
(if (setq p   (ssget "_X" '((0 . "*POLYLINE,SPLINE")
     (-4 . "<NOT")(-4 . "<OR")
     (70 . 1) (70 . 9)(70 . 129)
     (-4 . "OR>")(-4 . "NOT>")
     )
   )
 )
(repeat (setq b (sslength p))
 	(setq e (ssname p (setq b (1- b))))
 		(if (equal (vlax-curve-getStartPoint e)
	           (vlax-curve-getEndPoint e))
	  	(vla-put-closed (vlax-ename->vla-object e) :vlax-true)
	)
 )
 )
 (princ)
)

 

Closes plines with the same start and end point.

Link to comment
Share on other sites


(Defun C:ChkPl(/ old_var plcntr pllen ssnme ent)
 (setq old_var(Getvar "CMDECHO"))
 (setvar "CMDECHO" 0)
 (if (setq plset(ssget "x" '((0 . "POLYLINE"))))
   (progn
     (setq plcntr 0)
     (setq pllen(sslength plset))
     (repeat pllen
(setq ssnme(ssname plset plcntr))
(setq Ent  (entget ssnme))
(if (/= (cdr (assoc 70 ent)) 9)
  (Vl-Cmdf "CHPROP" ssnme "" "C" "1" "")
)
(setq plcntr(1+ plcntr))
     )
   )
 (princ "\nNo POLYLINES Found in Drawing!:")
)
 (setvar "CMDECHO" old_var)
 (princ)
)


 

 

Happy Computing :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...