Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

polyline close

26 REPLIES 26
Reply
Message 1 of 27
Anonymous
3056 Views, 26 Replies

polyline close

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)

26 REPLIES 26
Message 21 of 27
Kent1Cooper
in reply to: Anonymous


@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
Message 22 of 27
rkmcswain
in reply to: Kent1Cooper

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
Message 23 of 27
Kent1Cooper
in reply to: Anonymous


@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
Message 24 of 27


@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

Message 25 of 27


@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
Message 26 of 27
Anonymous
in reply to: Kent1Cooper

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 

Message 27 of 27
john.uhden
in reply to: Anonymous

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

John F. Uhden

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report