AutoLISP PDF Naming Patterns for DWG, Layout and Sheet Numbers
Design predictable PDF names before you write batch plotting code, including DWG name, Layout name and optional project or sheet identifiers.
Main idea: Naming is data design. Decide the naming rule before the plotting loop so files are predictable and collisions are handled deliberately.
Best use: Separate-PDF issue sets, consultant exports and automated folder output.
Start with the manual workflow
Write five real examples of the final file names you want. Include awkward Layout names, spaces and duplicate sheet labels.
Before automating a production workflow, review Free Autolisp Safe Pdf Filename, One Multi-Sheet PDF vs Separate PDFs in AutoCAD PUBLISH, and CAD PDF & Publishing Guide.
Build the automation in small layers
Step 1 — Choose the naming tokens
Where: Office naming standard
Do this: Decide which fields belong in the PDF name.
Check: Every token has a source.
Step 2 — Normalize unsafe characters
Where: AutoLISP string helper
Do this: Replace characters that are unsafe or confusing in file names.
Check: A Layout cannot create an invalid path.
Step 3 — Define separator and case
Where: Examples
Do this: Choose hyphen/underscore and uppercase/lowercase rules.
Check: All examples are consistent.
Step 4 — Define collision behavior
Where: Output folder
Do this: Choose skip, suffix, timestamp or prompt when a file exists.
Check: No silent overwrite occurs.
Step 5 — Reuse the helper everywhere
Where: Current Layout and batch routines
Do this: Call one naming function from every plotting routine.
Check: One change updates the whole automation family.
Write the naming rule as examples before code
For a drawing named A101-Floor-Plan.dwg with Layout A101, a simple rule might create A101-Floor-Plan-A101.pdf. A document-control rule might instead need PRJ123-A101-Rev03.pdf. Those are different data problems even though both end in .pdf.
Test names that contain slashes, colons, quotation marks, long descriptions and duplicated sheet numbers. Decide the collision policy before plotting. A safe automation tool should never discover its overwrite policy in the middle of an issue set.
What the code should control
- DWGNAME / vl-filename-base
- CTAB or Layout Name
- String sanitization
- Existing-file detection
- Optional project/sheet metadata
What you should deliberately leave manual at first
Do not add complex title-block attribute extraction until the basic DWG + Layout pattern is stable and tested.
Failure modes to design for
- Two different Layout names sanitize to the same file name.
- The naming rule exceeds path-length or downstream document-control limits.
- A routine silently overwrites last week’s issued PDF.
- Different tools implement slightly different naming rules.
When this becomes a production tool
Put the naming function in a shared library used by every plotting command, then version the convention together with the office CAD standard.
Official Autodesk references
Frequently asked questions
Should the Layout name always be in the PDF name?
Not always, but it is a simple reliable source when Layouts already follow the sheet-number convention.
Should I overwrite existing PDFs automatically?
For general-purpose tools, skipping or explicitly confirming is safer.
Can I read title-block attributes later?
Yes, but treat that as a second layer after the base naming function is stable.
Explore more in AutoLISP Plotting & PDF Automation.
