CADLISPMASTER
Stop wasting time on repetitive AutoCAD tasks. CAD LISP Master provides free, efficient AutoLISP codes and clear tutorials designed to automate your workflow and speed up your drafting.

Draw Polylines Faster from a Fixed Base Point

Download a free AutoCAD LISP to draw continuous polylines from a fixed origin easily.

[AutoCAD LISP] Draw Polylines Faster from a Fixed Base Point (BP.lsp)

Draw Polylines Faster from a Fixed Base Point
Have you ever found yourself frustrated while drawing multiple schematic lines, clearance boundaries, or leader-like polylines radiating from a single reference point?

Without this LISP, you have to repeatedly run the PLINE command, manually click the exact same center or base point every single time, or constantly use object snaps (OSNAP) which can get tedious and slow down your workflow. Even worse, if you need to change line colors to represent different phases, layers, or systems, you have to stop drawing, select the lines, and manually change their properties afterward. It’s a repetitive, click-heavy process that drains your productivity.

Why You Should Use the 'BP' LISP

  • One-Click Base Point Memory: It remembers your last used base point, even after the command ends. No more repeated clicking on the same origin.
  • On-the-Fly Color Switching: You can change the polyline color (1-9 or ByLayer) directly inside the command before clicking the next point.
  • Cleaner Workspace: It automates the CHPROP command instantly, saving you from navigating the Properties palette constantly.

How It Works (Step-by-Step Guide)

Here is a simple breakdown of how to use the BP command once you load it into AutoCAD:

  1. Launch the Command: Type BP in the command line and hit Enter.
  2. Set the Base Point: * If it's your first time, click any point on the screen to set your base point. If you've used it before, simply press Enter (or type P) to automatically reuse your previous base point.
  3. Specify the Next Point: Click anywhere on the screen. The LISP will instantly draw a polyline from your base point to this new point.
  4. Change Colors Instantly (Optional): Instead of clicking a point, type a number from 1 to 9 or B (for ByLayer) to change the color of the next lines you draw.
  5. Continuous Drawing: The command loops automatically. You can keep clicking next points radiating from the same base point.
  6. Exit the Command: Simply press Enter or Spacebar without selecting a point to cleanly exit the loop.

Wrapping Up

This Base Polyline (BP) utility is a massive timesaver for drafting diagrams, radial layouts, or quick schematics where everything originates from a single hub. By eliminating repetitive clicks and streamlining color changes, it keeps your eyes on the design and off the command ribbon.

Give it a try in your next drafting session, and let me know how much time it saved you in the comments below!

The LISP Code

Copy the code below, save it as a .lsp file (e.g., BP_BasePolyline.lsp), and load it into AutoCAD using the APPLOAD command.

Lisp

(if (not *aa-prev-pt*) (setq *aa-prev-pt* nil))

(defun c:BP ( / pt1 input loop current-col-str col-idx *error* )
  (defun *error* (msg)
    (setvar "CMDECHO" 1)
    (princ)
  )

  (setvar "CMDECHO" 0)
  (setq col-idx "ByLayer")
  (if *aa-prev-pt*
    (progn
      (initget "Previous P")
      (setq pt1 (getpoint (strcat "\nSpecify base point [Previous(P)] <Enter to use previous>: ")))
      (cond
        ((or (= pt1 "Previous") (= pt1 "P") (= pt1 nil))
         (setq pt1 *aa-prev-pt*)
         (princ "\n-> Previous base point applied.")
        )
        ((listp pt1)
         (setq *aa-prev-pt* pt1)
        )
      )
    )
    (progn
      (setq pt1 (getpoint "\nSpecify base point: "))
      (if pt1 (setq *aa-prev-pt* pt1))
    )
  )
  (if pt1
    (progn
      (setq loop T)
      (while loop
        (setq current-col-str (if (= (type col-idx) 'STR) col-idx (itoa col-idx)))
        (initget "1 2 3 4 5 6 7 8 9 B ByLayer")
        (setq input (getpoint pt1 (strcat "\nSpecify next point or Color [1-9 / B(ByLayer)] <" current-col-str ">: ")))
        (cond
          ((null input)
           (setq loop nil)
          )
          ((or (= input "B") (= input "ByLayer"))
           (setq col-idx "ByLayer")
           (princ "\n-> Color changed to ByLayer.")
          )
          ((member input '("1" "2" "3" "4" "5" "6" "7" "8" "9"))
           (setq col-idx (atoi input))
           (princ (strcat "\n-> Color changed to " input "."))
          )
          ((listp input)
           (command "_.pline" pt1 input "")
           (command "_.chprop" (entlast) "" "_Color" col-idx "")
          )
        )
      )
    )
  )
  (setvar "CMDECHO" 1)
  (princ "\nBP command completed.")
  (princ)
)

Post a Comment