If you have a polyline that appears to be closed but isn't, is there a way or lisp file that can detect which vertices have the gap?
![]() |
|
![]() |
|
![]() |
|
![]() |
If you have a polyline that appears to be closed but isn't, is there a way or lisp file that can detect which vertices have the gap?
Hi
simple select the pline go to properties window check in the box for vertices and run it around the line
Using Properties palette and running though vertices will work -- just be cautions and pay attention to the vertex number, as it will leap across the gap and go back to vertex number one.
An alternative, is to use the Pedit command, Edit vertex, and Next to step through all the vertices. This will stop at the last vertex and not jump the gap and start over.
Something else to keep in mind is that the pline may have the first and last vertices snapped together but still not be "closed". For example, take a rectangle. You need 4 vertices, but users tend not to use the CLOSE option to finish a polygon. They will add a 5th vertex with the location the same as the first vertex. This is still an open pline.The pline's Closed property needs to by TRUE. Your lisp should check that property.
C:> ED WORKING.... ▒
This lisp will draw a circle on the starting point of the open polyline.
HTML Code:(defun c:openpl ( / *DOCUMENT* *MODELSPACE* CIR_OBJ N PO POBJ PO_LIST SS SSL X) (setq *ModelSpace* (vla-get-ModelSpace (setq *Document* (vla-get-ActiveDocument (vlax-get-acad-object))))) (command-s "_undo" "_g") (defun red:cir (p r) (setq cir_Obj (vla-AddCircle *ModelSpace* (vlax-3d-point p) r)) (vlax-put-property cir_Obj'color 1) cir_Obj ) (setq ss (ssget '((0 . "LWPOLYLINE")(70 . 0)))) (setq ssl (sslength ss)) (setq n 0) (repeat ssl (setq pobj(ssname ss n)) (setq po(cdr (assoc 10 (entget pobj)))) (setq po_list(append po_list (list po))) (setq n (1+ n)) ) (mapcar '(lambda (x) (red:cir x (getvar"textsize")) ) po_list ) (command-s "_undo" "_e") )
I see that you are checking for dxf gc 7= 0. You could just set it to 1 to close it.
C:> ED WORKING.... ▒
If you just close it, sometimes it can go messy if some of the polylines have an overlap in the corner.
Here just to mark the open polygons.
Yes. I wouldn’t do it without some error checking, like seeing if the first and last vertices are coincident. I might even delete the last vertex.
C:> ED WORKING.... ▒
there is a kind of trick for such case you can explode the open polygons if it's not shared their boundaries and then polyline edit then multiple and select all the exploded polygons then Join and put a tolerance according to the drawing units and scale, that rejoin the polygons as a closed polygons.