[AutoCAD LISP] Draw Perfect Batting Insulation Instantly (BAT.lsp)
Manually drawing batting insulation in AutoCAD is one of those tedious,
repetitive tasks that unnecessarily drains your drafting time. If you don't
use an automated tool, you are usually stuck trying to scale a finicky
custom linetype—which often breaks or looks awkward at the endpoints—or
manually copying and stretching individual arcs. Adjusting these patterns
every time a wall thickness changes becomes a workflow nightmare.
Fortunately, you can eliminate this frustration entirely. With the BAT.lsp
routine, you can generate flawlessly proportioned batting insulation inside
any rectangular profile with just two simple clicks.
Why You Should Use the 'BAT' LISP
- Dynamic Scaling: It automatically reads the thickness and length of your designated area, scaling the insulation loops perfectly without any manual distortion.
- Auto-Direction Detection: By identifying your diagonal inputs, the LISP smart-detects whether the insulation needs to run horizontally or vertically.
- Seamless Endpoints: No more cut-off loops or awkward empty gaps. The code calculates the exact number of repeating segments required to fill the length seamlessly.
- Clean Single Polyline: The entire insulation pattern is drawn as a single, continuous polyline entity, making it incredibly easy to select, move, or modify later.
How It Works (Step-by-Step Guide)
- Load the LISP: Drag and drop the BAT.lsp file into your AutoCAD window, or load it using the APPLOAD command.
- Launch the Command: Type BAT in the command line and press Enter.
- Pick the First Corner: Click to specify the first diagonal corner point (pt1) of the area where you want the insulation.
- Pick the Opposite Corner: Click the second diagonal corner point (pt3).
- Instant Generation: The LISP turns off object snaps temporarily to prevent distortion, automatically calculates the optimal loop density, and draws the batting pattern instantly.
Wrapping Up
Drafting architectural details shouldn't feel like a chore. By
integrating the BAT.lsp routine into your daily workflow, you can
ensure that your insulation lines remain clean, standard-compliant,
and perfectly scaled every single time—all while saving valuable
hours. Give it a try on your next project and experience the
difference!
The LISP Code
(defun c:BAT( / os bl cm pt1 pt3 x1 y1 x3 y3 minx maxx miny maxy dx dy thk len pt_start pt_end sc_x sc_y n seg_len b1 b2 b3 b4 p1 p2 p3 p4 p5 p6 p7 p8 old_error)
(setq old_error *error*)
(defun *error* (msg)
(if os (setvar "osmode" os))
(if bl (setvar "blipmode" bl))
(if cm (setvar "cmdecho" cm))
(setq *error* old_error)
(princ)
)
(setq os (getvar "osmode") bl (getvar "blipmode") cm (getvar "cmdecho"))
(setvar "blipmode" 0)
(setvar "osmode" 1)
(setq pt1 (getpoint "\nSpecify first diagonal corner point: "))
(if pt1
(progn
(setq pt3 (getpoint pt1 "\nSpecify second diagonal corner point: "))
(if pt3
(progn
(setvar "osmode" 0)
(setvar "cmdecho" 0)
(setq x1 (car pt1) y1 (cadr pt1)
x3 (car pt3) y3 (cadr pt3))
(setq minx (min x1 x3) maxx (max x1 x3)
miny (min y1 y3) maxy (max y1 y3))
(setq dx (- maxx minx)
dy (- maxy miny))
(if (> dx dy)
(setq thk dy len dx
pt_start (list minx miny 0.0)
pt_end (list maxx miny 0.0))
(setq thk dx len dy
pt_start (list minx maxy 0.0)
pt_end (list minx miny 0.0))
)
(setq sc_y (/ thk 50.0))
(setq n (fix (+ 0.5 (/ len (* sc_y 25.0)))))
(if (< n 1) (setq n 1))
(setq seg_len (/ len n))
(setq sc_x (/ seg_len 25.0))
(setq ag1 (angle pt_start pt_end) ag2 (+ ag1 (/ pi 2.0)))
(command "_.pline" pt_start)
(repeat n
(setq b1 (polar pt_start ag2 (* sc_y 4.32))
b2 (polar pt_start ag2 (* sc_y 13.55))
b3 (polar pt_start ag2 (* sc_y 36.45))
b4 (polar pt_start ag2 (* sc_y 50.00)))
(setq p1 (polar b1 ag1 (* sc_x 8.23))
p2 (polar b2 ag1 (* sc_x 9.35))
p3 (polar b3 ag1 (* sc_x 3.15))
p4 (polar b4 ag1 (* sc_x 12.50))
p5 (polar b3 ag1 (* sc_x 21.85))
p6 (polar b2 ag1 (* sc_x 15.65))
p7 (polar b1 ag1 (* sc_x 16.77))
p8 (polar pt_start ag1 (* sc_x 25.00)))
(command "A" "S" p1 p2 "L" p3 "A" "S" p4 p5 "L" p6 "A" "S" p7 p8 "L")
(setq pt_start p8)
)
(command "")
)
)
)
)
(setvar "osmode" os)
(setvar "blipmode" bl)
(setvar "cmdecho" cm)
(setq *error* old_error)
(princ)
)

Post a Comment