|

Validate AutoCAD Plot Settings Before a Batch Plot with AutoLISP

Build a preflight routine that reports bad devices, missing plot styles and inconsistent media before any PDF files are created.

Main idea: The best batch plot routine often starts as a report-only checker. Detect problems before the expensive output loop.

Best use: Large DWGs with many Layouts or office standards where one bad sheet can stop a publish job.

Start with the manual workflow

List the minimum requirements for a Layout to be ‘ready’: approved device, allowed paper/media, valid CTB/STB and expected Plot with Plot Styles state.

Build the automation in small layers

Step 1 — Define pass/fail rules

Where: CAD standards document

Do this: Write explicit allowed values.

Check: The checker is based on a real standard.

Step 2 — Read each Layout

Where: AutoLISP/ActiveX

Do this: Collect ConfigName, CanonicalMediaName, StyleSheet and plot-style state.

Check: Every Layout has a record.

Step 3 — Compare with allowed values

Where: In-memory lists or config data

Do this: Mark each field PASS/WARN/FAIL.

Check: The result is explainable.

Step 4 — Print a summary

Where: Command line or CSV report

Do this: Show failing Layouts before plotting.

Check: A user can fix issues without generating PDFs.

Step 5 — Allow batch only after preflight

Where: Plot command

Do this: Run output only when required checks pass or the user deliberately accepts warnings.

Check: Bad standards do not propagate silently.

Think of preflight as a gate, not a report nobody reads

A useful preflight gives each Layout a clear result. For example: FAIL if the PC3 is missing, FAIL if the requested media does not exist, FAIL if a CTB drawing has no StyleSheet, and perhaps WARN if a viewport is unlocked.

The batch command can then refuse to run while failures remain. This is much safer than creating forty PDFs and expecting someone to notice afterward that three sheets were plotted to the wrong paper size.

What the code should control

  • ConfigName
  • CanonicalMediaName
  • StyleSheet
  • PlotWithPlotStyles
  • PSTYLEMODE
  • Layout name

What you should deliberately leave manual at first

Do not try to auto-fix every failed condition in the first checker. Reporting is safer and easier to trust.

Failure modes to design for

  • The ‘approved’ values are hard-coded but never updated.
  • A missing PC3 is treated as a warning when it should stop output.
  • Custom paper names vary by driver and are compared blindly.
  • The checker reports problems but the batch routine ignores the report.

When this becomes a production tool

Split preflight and repair into separate commands. A read-only checker can be deployed widely; a repair command should require stronger testing and permissions.

Official Autodesk references

Frequently asked questions

Why not just let PUBLISH fail?

Because a preflight gives a specific Layout and setting before output time is wasted.

Should warnings stop the batch?

Define that per rule. Missing device or media is usually a failure; a nonstandard but valid naming rule might be only a warning.

Can the checker be read-only?

Yes, and that is a good first production version.

Explore more in AutoLISP Plotting & PDF Automation.