Welcome to these Forums!
I can't explain that behavior, though there is a certain predictability about it, most of the time. When you draw one that ends with an arc segment without closing it, the final vertex's bulge factor entry in entity data seems to be the complement of the last segment [the factor that gives the rest of the circle of which that arc segment is a part], so when you close it in the Properties box, the closing arc segment has that bulge factor. And when you do it with PEDIT, it closes with an arc segment that's a tangent continuation, as it would be if you had used the CLose option in drawing it. But not always -- it seems to be affected by editing. For instance, if you draw one closed with a line segment but with the last segment before that being an arc, and then un-close it in Properties, its final-vertex bulge factor remains 0.0 as it was for the original closing line segment, so if you close it again [in Properties, not via PEDIT], it will close with a line segment again. Or if you drag a grip on that last arc segment, it seems the bulge factor for the last vertex doesn't end up with the same relationship to that of the last segment. Or if you build a Polyline by PEDIT-Joining some Lines and Arcs, then even if the last resulting segment is an arc, closing in Properties will be with a line segment.
But here's a simple [minimally tested] routine to do it with a line segment regardless of initial conditions or subsequent editing:
(vl-load-com); if needed
(defun C:PLCL ; = PolyLine Close, always with Line segment
(/ plsel pl)
(if
(and
(setq plsel (entsel "\nSelect open Polyline to close with line segment: "))
(setq pl (car plsel))
(= (cdr (assoc 0 (entget pl))) "LWPOLYLINE")
(not (vlax-curve-isClosed pl))
); and
(command ; then
"_.line" (vlax-curve-getStartPoint pl) (vlax-curve-getEndPoint pl) ""
"_.pedit" pl "_join" (entlast) "" ""
); command
(prompt "\nNot an open lightweight Polyline."); else
); if
(princ)
); defun
With a little more code, it could be made to allow "heavy" 2D Polylines, but would need to forbid 3D ones under this approach, because even though PEDIT offers the Join option for them, for some reason it seems you can't join a Line to one.
Kent Cooper, AIA