polyline close

Anonymous

polyline close

Anonymous
Not applicable

i want to close a selected polyline without clicking or picking a point

 

 

 

(defun C:SWPOLY (/ dat c elst wid ename pend pt)
(vl-load-com)
(setvar "cmdecho" 0)
(setq plw (getvar "plinewid"))
(if
(and (setq dat (entsel "\nSelect source polyline: "))
(wcmatch (cdadr (setq elst (entget (setq ename (car dat)))))
"*POLYLINE*"))
(progn
(setq wid (cdr (assoc 40 elst)))
(prompt (strcat "\nWidth is " (rtos wid)))
(setq pend (osnap (cadr dat) "_end"))
(setq pt
(cond
((equal (vlax-curve-getstartpoint ename) pend 0.0001)
(vlax-curve-getstartpoint ename))
((equal (vlax-curve-getendpoint ename) pend 0.0001)
(vlax-curve-getendpoint ename))
(t nil)))
(if pt
(setq p pt)
(setq p (getpoint "\nSpecify start point: ")))
(command "_.pline" p "_w" wid wid)
(while (eq 1 (logand 1 (getvar "cmdactive")))
(command pause))
(if
(and pt (wcmatch (cdadr (entget (entlast))) "*POLYLINE*"))
(command "_.pedit" ename "_j" (entlast) "" "")))
(prompt "\nNot a polyline"))
(if plw
(setvar "plinewid" plw))
(setvar "cmdecho" 1)
(princ))
(princ)

0 Likes
Reply
3,059 Views
26 Replies
Replies (26)

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

here is the lisp im talking about but can you modify it.

i want to remove the "specify a point to add a LWPOLYLINE command and make automatic searching the end of polyline and close it according to this lisp"

....


Solutions have already been offered that will do that.  This routine does make one "truly" closed by AutoCAD's definition.  So is that what you want, or not?  On the mysteriously missing thread, it clearly was not, though I still can't imagine why, but if you want it to do what this routine does but without the extra point, it is.  You can't have it both ways.

Kent Cooper, AIA
0 Likes

rkmcswain
Mentor
Mentor
Kent1Cooper wrote:

On the assumption that this was meant to be something like "It's not clear to me why...", the other thread linked to in Post 5 was clearer about why, but for some reason it's not accessible any more.

Maybe @Discussion_Admin can figure out where that thread went.

R.K. McSwain     | CADpanacea | on twitter
0 Likes

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

here is the lisp im talking about ....

 

....

((not ( = (cdr (assoc 70 e)) 0))
  (alert "Select LWPolyline is closed <!>")
)
....


By the way, that part will cause trouble if linetype generation is enabled for the selected Polyline.  If it's open with linetype generation enabled, the 70-code value will be 128, not 0, so the routine will "claim" it's closed incorrectly.  There are a few of ways to check for whether it's closed that will not be affected by whether or not linetype generation is enabled, that you could use in place of the first code line quoted above:

 

((vlax-curve-isClosed s)

 

((= (logand 1 (cdr (assoc 70 e))) 1)

 

((member (cdr (assoc 70 e)) '(1 129))

Kent Cooper, AIA

Discussion_Admin
Alumni
Alumni

@rkmcswain wrote:
@Kent1Cooper wrote:

On the assumption that this was meant to be something like "It's not clear to me why...", the other thread linked to in Post 5 was clearer about why, but for some reason it's not accessible any more.

Maybe @Discussion_Admin can figure out where that thread went.


@Kent1Cooper

@rkmcswain

 

That post was move as a duplicate. Would you like me to merge it with this topic??

 

Thanks
Discussion_Admin

0 Likes

Kent1Cooper
Consultant
Consultant

@Discussion_Admin wrote:

That post was move as a duplicate. Would you like me to merge it with this topic??

Thanks
Discussion_Admin


It might help people understand, whether merged in or restored as as separate thread.  It had an image from the OP showing a quadrilateral open and "closed", with a closed one showing what they wanted, having vertex 1 and vertex 5 at the same place, contrasted to a "truly" closed one with only 4 vertices.  And it had a routine I came up with to accomplish that.  And if it had any further responses from the OP that I didn't see before it disappeared, they might also shed some light.

Kent Cooper, AIA
0 Likes

Anonymous
Not applicable

thank you guys for the time i already solve my own problem...its easy than i imagine. Smiley Happy  it is like a chess game...keep practicing 

0 Likes

john.uhden
Mentor
Mentor

That makes sense.  You have been treating us like pawns.

John F. Uhden

0 Likes