How to Switch Between CTB and STB Plot Styles in AutoCAD


Introduction

Managing plot styles in AutoCAD—whether CTB (Color-Dependent Plot Style Tables) or STB (Named Plot Style Tables)—can be a critical task for engineers, architects, and designers. Switching between these styles efficiently ensures consistency in output, especially when transitioning between legacy and modern workflows. This guide explores a practical approach to converting drawings from CTB to STB using a custom AutoLISP routine, tailored for Civil 3D and compatible with AutoCAD 2023.


Understanding CTB vs. STB Plot Styles

CTB (Color-Dependent Plot Style Tables)

  • Assigns plot styles based on object colors (e.g., color 1 = thick line, color 2 = dashed line).
  • Common in older AutoCAD versions and legacy projects.
  • Simpler for standardized workflows but less flexible for customization.

STB (Named Plot Style Tables)

  • Assigns plot styles independently of color, using named styles (e.g., “Normal,” “125,” “255”).
  • Offers greater control over line weights, screening, and other plot properties.
  • Preferred for modern workflows, especially in Civil 3D and Architecture, Engineering & Construction (AEC) projects.

Step-by-Step Guide: Convert CTB to STB Using AutoLISP

Prerequisites

  • AutoCAD 2023 or Civil 3D 2023 (tested on 64-bit Windows 10).
  • A saved drawing (unsaved drawings will trigger an error).
  • Access to the STB file (e.g., FDOT.stb) you want to apply.

1. Load the AutoLISP Routine

The provided AutoLISP script automates the conversion from CTB to STB by:

  • Switching the drawing to STB mode.
  • Assigning named plot styles to layers based on their color properties.
  • Ensuring compatibility with Civil 3D layer standards.

How to Use the Script

  1. Copy the LISP code below into a text editor (e.g., Notepad).
  2. Save the file as FDOT255.lsp (or your preferred filename).
  3. In AutoCAD, type APPLOAD in the command line.
  4. Browse and select the FDOT255.lsp file, then click Load.
  5. Type FDOT255 in the command line to execute the routine.
; Set drawing settings to FDOT.stb
(defun c:FDOT255 ()
  (if (= (getvar "PStyleMode") 1)
    (command "_convertpstyles" "acad - Convert.stb")
  )
  (cond
    ((= (getvar "DwgTitled") 0)
     (alert "Drawing must be saved first!")
     (exit)
    )
  )
  (vla-put-StyleSheet
    (vla-get-ActiveLayout
      (vla-get-ActiveDocument (vlax-get-acad-object))
    )
    "FDOT.stb"
  )
  (setq layers (vla-get-layers (vla-get-ActiveDocument (vlax-get-acad-object))))
  (vlax-for l layers
    (progn
      (cond
        ((equal (vla-get-color l) 8)  (setvar "CPLOTSTYLE" "125") (vla-put-plotstylename l "125"))
        ((equal (vla-get-color l) 9)  (setvar "CPLOTSTYLE" "125") (vla-put-plotstylename l "125"))
        ((equal (vla-get-color l) 250) (setvar "CPLOTSTYLE" "125") (vla-put-plotstylename l "125"))
        ((equal (vla-get-color l) 251) (setvar "CPLOTSTYLE" "125") (vla-put-plotstylename l "125"))
        ((equal (vla-get-color l) 252) (setvar "CPLOTSTYLE" "125") (vla-put-plotstylename l "125"))
        ((equal (vla-get-color l) 253) (setvar "CPLOTSTYLE" "125") (vla-put-plotstylename l "125"))
        ((equal (vla-get-color l) 254) (setvar "CPLOTSTYLE" "125") (vla-put-plotstylename l "125"))
        ((equal (vla-get-color l) 255) (setvar "CPLOTSTYLE" "Normal") (vla-put-plotstylename l "Normal"))
        (T (setvar "CPLOTSTYLE" "255") (vla-put-plotstylename l "255"))
      )
    )
  )
  (setvar "CPLOTSTYLE" "ByLayer")
  (princ)
)

2. Customizing the Script

The script above is specific to the FDOT.stb file and assigns:

  • Colors 8, 9, 250–254 → Plot style “125”.
  • Color 255 → Plot style “Normal”.
  • All other colors → Plot style “255”.

How to Adapt for Your STB File

  1. Replace “FDOT.stb” with your STB filename (e.g., "MyCustom.stb").
  2. Modify the cond block to map layer colors to your desired plot styles.
    Example:

    ((equal (vla-get-color l) 1) (vla-put-plotstylename l "Thin"))
    ((equal (vla-get-color l) 2) (vla-put-plotstylename l "Dashed"))

3. Verify the Conversion

After running the script:

  1. Check the Plot Style Manager (STYLESMANAGER command).
  2. Ensure layers now use named plot styles (STB) instead of color-dependent styles (CTB).
  3. Plot a test sheet to confirm the output matches expectations.

Best Practices for CTB/STB Management

1. Start with a Template

  • Always begin with a template file pre-configured with your preferred STB or CTB.
  • Avoid manual conversions by using standardized templates for new projects.

2. Backup Your Drawing

  • Save a copy of your drawing before running conversion scripts.
  • Use AutoCAD’s SAVEAS command to create a backup version.

3. Test on a Sample Drawing

  • Run the script on a non-critical drawing first to verify compatibility.
  • Check for layer overrides or custom properties that may need adjustment.

4. Document Your Workflow

  • Keep a record of plot style mappings (e.g., color → STB style).
  • Share the LISP script and instructions with your team for consistency.

Troubleshooting Common Issues

IssueSolution
“Drawing must be saved first!”Save the drawing (QSAVE or SAVEAS) before running the script.
Plot styles not applyingEnsure the STB file exists in AutoCAD’s plot style search path.
Script errorsCheck for typos in the LISP code or unsupported AutoCAD versions.
Layers not updatingVerify layer colors match the script’s conditions (e.g., color 8 → “125”).

Conclusion

Switching between CTB and STB plot styles in AutoCAD doesn’t have to be manual or error-prone. By leveraging AutoLISP, you can automate the process, ensuring consistency and efficiency—especially in Civil 3D and AEC workflows. The provided script is a starting point; customize it to fit your STB file and layer standards.

For seamless transitions, always:
✅ Use pre-configured templates.
Test scripts on sample drawings.
Document your plot style mappings.

Ready to streamline your plotting workflow? Load the script, run it, and experience the power of automated plot style conversion in AutoCAD!


References: AutoCAD 2023 Documentation, Civil 3D Forums, AEC Collection Best Practices.