Learn the basics of AutoCAD and More!

Lesson 5.12 – A Custom Drawing Setup Routine

πŸ› οΈ Lesson 5.12 – A Custom Drawing Setup Routine with AutoLISP

Learn how to automate an entire drawing setup: units, limits, layers, and title block insertion in a single AutoLISP command.


πŸ“š What You’ll Learn

By the end of this lesson, you’ll be able to:

  • Set drawing units and limits programmatically
  • Create and configure layers as part of the setup
  • Insert a pre-defined title block
  • Combine all tasks into one reusable startup routine

🧠 Why It Matters

Setting up new drawings manually is time-consuming and prone to inconsistency. With a single custom routine, you can apply your CAD standards in secondsβ€”improving speed, accuracy, and professionalism.

πŸ› οΈ Tools You’ll Use

FunctionPurpose
commandExecutes AutoCAD commands (e.g., UNITS, LIMITS, etc.)
tblsearchChecks if an item (e.g., layer) already exists
strcaseNormalizes text for case-sensitive checks
Custom scriptsCalls other routines like layer creation and block fill

🧭 Lesson Structure

1️⃣ Set Units and Limits

You can automate basic setup options:

(command "UNITS" 2 4 1 2 0 0)  ; Decimal, precision 0.00, inches, clockwise
(command "LIMITS" "0,0" "420,297") ; A3 sheet size
(command "ZOOM" "A") ; Zoom to drawing limits

2️⃣ Create Layers

Integrate or call your custom layer routine (from Lesson 3.5):

(c:makelayers) ; Must be defined or loaded separately

3️⃣ Insert Title Block

Insert a predefined block and fill in attributes:

(command "._-INSERT" "TITLEBLOCK" '(0 0 0) 1 1 0)
(c:filltitleblock) ; Must be defined separately

4️⃣ Full Setup Routine

(defun c:setupdrawing ( / )
(prompt "\\n--- Starting Drawing Setup ---")

;; Set Units
(command "UNITS" 2 4 1 2 0 0)

;; Set Limits and Zoom
(command "LIMITS" "0,0" "420,297")
(command "ZOOM" "A")

;; Load linetypes
(command "-linetype" "Load" "*" "acad.lin" "")

;; Create standard layers
(c:makelayers)

;; Insert title block
(command "._-INSERT" "TITLEBLOCK" '(0 0 0) 1 1 0)

;; Fill attributes
(c:filltitleblock)

(prompt "\\nβœ” Drawing setup complete.")
(princ)
)

βœ… Lesson Checklist

TaskCompleted
Defined drawing units and limits☐
Created and configured standard layers☐
Inserted and filled a title block with attributes☐
Combined steps into a single AutoLISP routine☐

πŸ“Œ Quick Tips

TipWhy It Helps
Use consistent layer naming across all routinesEnsures compatibility in block attributes
Insert blocks at origin (0,0) when possibleKeeps layout predictable and consistent
Include a units prompt if templates vary by regionImproves portability for international teams
Use (load "scriptname") to import helper filesKeeps main routine clean and modular

🧩 Real-World Applications

Use CaseWhat It AutomatesWhy It Helps
Architectural title sheetUnits, layers, block, limitsSpeeds up template creation
Civil layout baseGrading layers, A1 sheet setupReduces repetitive startup tasks
Client-specific standardsColor, fonts, title stylesApplies standard branding instantly

πŸ“ Files and Resources

File / ResourceDescription
setupdrawing.lspFull routine that automates the drawing setup
drawing_setup_checklist.docxStep-by-step manual checklist (optional or backup)
titleblock_template.dwgBlock file required for the INSERT command (external DWG)

πŸ“– Review Table

FunctionDescriptionExample
commandRuns AutoCAD commands(command "UNITS" 2 4 1 2 0 0)
c:makelayersCustom function to make layers(c:makelayers)
c:filltitleblockCustom function to fill attributes(c:filltitleblock)
loadLoad a helper script(load "filename.lsp")