If you have ever drafted electrical layouts, ductwork, or radial grid lines in AutoCAD, you know how repetitive drawing lines from a single center point can be. Running the PLINE command, snapping to the center, clicking the endpoint, restarting PLINE, snapping back to the center again... it takes way too many clicks and breaks your drawing flow.
To fix this, I put together a lightweight AutoLISP routine called BP.lsp (Base Point Polyline). It locks in your origin point so you can draw multiple radiating lines continuously without re-selecting the base point every single time. You can also swap line colors mid-command using simple number keys.
Why Use BP.lsp Instead of Standard Polylines?
When drawing dozens of branching lines from a central hub, standard AutoCAD commands slow you down for a few reasons:
Eliminates redundant snapping: Once you set your base point, the script holds onto it. You just keep clicking destination points.
Instant color changes on the fly: Instead of opening the Properties Palette afterward to change colors, just type
1through9in the command prompt while drawing to swap active colors immediately.Remembers your last origin: Working on a similar cluster nearby? Press Enter to reuse the previously saved base point.
How to Use the Script
Follow these quick steps to run BP.lsp in your drawing:
Type
APPLOADin AutoCAD, selectBP.lsp, and load it.Type
BPand hit Enter.Pick your central base point on the screen. (If you have used the command before, press Enter or type
Pto reuse the last origin point).Click anywhere to place your lines. Polylines will instantly draw from your fixed base point to each target point.
To change color mid-draw, enter a number from
1to9(orBfor ByLayer) before clicking your next point.Press Spacebar or Enter on an empty prompt when you are done.
AutoLISP Code (BP.lsp)
Copy the script below and save it as BP.lsp in your AutoCAD support path:
(if (not *aa-prev-pt*) (setq *aa-prev-pt* nil))
(defun c:BP ( / pt1 input loop current-col-str col-idx old-cmdecho old-osmode *error* )
(defun *error* (msg)
(if old-cmdecho (setvar "CMDECHO" old-cmdecho))
(if old-osmode (setvar "OSMODE" old-osmode))
(command-s "_.undo" "_end")
(princ "\nCAD Lisp [www.daolpro.com]")
(princ)
)
(setq old-cmdecho (getvar "CMDECHO"))
(setq old-osmode (getvar "OSMODE"))
(setvar "CMDECHO" 0)
(command "_.undo" "_begin")
(setq col-idx "ByLayer")
(if *aa-prev-pt*
(progn
(initget "Previous P")
(setq pt1 (getpoint (strcat "\nSpecify base point [Previous(P)] : ")))
(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" "_none" pt1 "_none" input "")
(command "_.chprop" (entlast) "" "_Color" col-idx "")
)
)
)
)
)
(command "_.undo" "_end")
(setvar "CMDECHO" old-cmdecho)
(setvar "OSMODE" old-osmode)
(princ "\nCAD Lisp [www.daolpro.com]")
(princ)
)
A Few Quick Notes
Separate Entities: Each line drawn from the center is created as an independent polyline object, so you can edit, stretch, or move individual lines later.
Resetting Base Point: If you need to set a totally new center point, simply restart the
BPcommand and click a new spot on your drawing instead of pressingP.

Post a Comment