AutoLISP: Continue Polyline

One year ago today, I started this blog in hopes to have reference for AutoCAD tips in case I forgot them. After one year, I have made 196 posts and every week more and more people come to this blog and hopefully find a few good tips. Thanks for making my blogging experience fun and may there be many more helpful posts!!!

Here is a simple routine that lets you pick up where you left off. You simply pick the end of an existing polyline, and this routine will let you pick more points (add more vertices) to that polyline. This routine continues even the properites as well…

Here’s how:

  • SWPOLY <enter> to start
  • Select a part of a polyline that is near its endpoint.
  • You may need to specify what endpoint you want to continue from
  • Click to place more vertices

(defun C:SWPOLY (/ dat c elst wid ename pend pt)
(setvar "cmdecho" 0)
(setq plw (getvar "plinewid"))
(and (setq dat (entsel "\nSelect source polyline: "))
(wcmatch (cdadr (setq elst (entget (setq ename (car dat)))))
(setq wid (cdr (assoc 40 elst)))
(prompt (strcat "\nWidth is " (rtos wid)))
(setq pend (osnap (cadr dat) "_end"))
(setq pt
((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))
(and pt (wcmatch (cdadr (entget (entlast))) "*POLYLINE*"))
(command "_.pedit" ename "_j" (entlast) "" "")))
(prompt "\nNot a polyline"))
(if plw
(setvar "plinewid" plw))
(setvar "cmdecho" 1)

About AutoCAD Tips

This blog serves as a knowledge base for myself (and anyone else) so that I can reference tips & tricks that I have learned and also refer others to it as well. I hope that this blog helps you learn at least one tip to make your drafting/design experience better.
This entry was posted in AutoLISP, AutoLISP: Polylines, Modifying, Polylines. Bookmark the permalink.

11 Responses to AutoLISP: Continue Polyline

  1. Julio says:

    many thanks for this jewel, I cannot recall how many times I lost track of the polyline and have to start from the last point to join them later, great routine

  2. Pingback: AutoLISP: Continue Line on Layer… | AutoCAD Tips

  3. Blos, Andreas says:

    I’m from Germany and want to test your Makro but it doesn’t work in a German AutoCAD
    in Line 28 is the problem
    (command “_.pedit” ename “j” (entlast) “” “”)))
    it should be
    (command “_.pedit” ename “_j” (entlast) “” “”)))
    then it will go

    Kind regards

  4. Tommy says:

    Wow that works great! Do you have a lsp that can add a vertex to the middle of a polyline? I know you can put your mouse on a grip and wait till Add Vertex shows up and hit “a” and it will add another vertex but it would be nice if you could click multiple points without having to wait.

  5. Anthony says:

    hi! sorry this is my first post, I wanted to know if you can add the command before joint to ask for radius, otherwise I need to go back and fill it with radius. Thank you very much

  6. Wojtek says:

    Hi. In AutoCad 2017, this lisp does not work. Maybe I’m doing something badly, but it creates a new polyline not continues. Could you tell what I’m doing wrong.

  7. Aaron Elswick says:

    I tried this and yes it continues the line but it is still a separate line. It isn’t like Carlson and joins and continues. You still have to join the lines after. In Carlson the command lets you continue a line and then it closes to the original beginning point. Not the beginning of the line that you start with this command.

  8. Juss says:

    Works perfectly. You have to hit “Enter” after command to register. Thank you so much.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s