LayoutNum

Short description

  • Provides a DCL dialog to batch rename layouts using sequential numbering with optional prefix, suffix, and zero-padding, with filtering and preview.
  • Supports in-dialog Apply and multi-level Undo without calling AutoCAD UNDO from DCL callbacks, to avoid stability issues.
layoutnum 000

Command:

  • Commands: LAYOUTNUM, _LAYOUTNUM, LayoutNum

Description:

  • Builds a unique DCL dialog definition at runtime and lists layouts with a wildcard filter, optionally including Model in the list as a non-renamable entry.
  • Allows selecting multiple layouts, choosing ordering by tab order or alphabetical, and defining rename parameters: starting number, width (zero-padding), prefix, suffix, and optional auto-resolve for name conflicts.
  • Displays a preview list showing Old => New names before applying changes; preview refreshes when selection or options change.
  • Applies renaming using ActiveX by setting each layout object name, wrapped in a safe undo mark for editor-level undo grouping, while also recording rename frames for the dialog’s own manual undo stack.
  • Implements Undo inside the dialog by replaying stored rename frames in reverse to restore old names, avoiding the AutoCAD UNDO command inside DCL callbacks.
  • Persists the last-used UI values (filter, numbering, prefix/suffix, order, auto-resolve, include model) so the next run starts with the prior settings.

Helper function: (if any)​

  • LayoutNum:WriteDCL builds a unique dialog name and writes the full DCL string to a temporary file, returning the file path and dialog name.
  • LayoutNum:LayoutsTabOrder collects layout objects with their tab order and returns a sorted list used for display and renaming sequence.
  • LayoutNum:RebuildDisplay applies the filter and ordering, rebuilds the layout list, preserves selection, and refreshes the preview.
  • LayoutNum:GetSelectedItems maps list box indices to the underlying layout entries for consistent selection handling.
  • LayoutNum:ComputeRenamePlan generates the proposed new names based on start, pad, prefix, suffix, order, and conflict policy, marking Model as non-renamable.
  • LayoutNum:ValidateBeforeRename validates selection and numeric inputs and checks name uniqueness and conflicts when auto-resolve is disabled.
  • LayoutNum:ApplyRename performs renames, records a frame of (object old new) for manual undo, refreshes lists, and updates defaults for convenience.
  • LayoutNum:DoUndo restores the last rename frame in reverse order to avoid collisions and keeps selection on restored names after refresh.
  • _StartUndo and _EndUndo manage VLA undo marks safely without invoking the UNDO command inside DCL callbacks.
  • LayoutNum:Cleanup unloads the dialog and deletes the temporary DCL file to prevent leftovers across runs.
  • c:LAYOUTNUM, c:_LAYOUTNUM, c:LayoutNum are safe command entry points calling LayoutNum:Run.

Functionalities:

  • Wildcard filter with a dedicated Apply Filter action that rebuilds the displayed list without renaming anything.
  • Multi-select layouts with Select All and Select None shortcuts and a live status indicator showing shown and selected counts.
  • Preview panel showing proposed renames as Old => New, with a Refresh Preview button and auto-refresh on option changes.
  • Renaming options including starting number, zero-padding width, prefix, suffix, order mode (tab order or alphabetical), and auto-resolve for conflicts by appending -1, -2, and so on.
  • Non-destructive handling of Model when included: it can be listed but is blocked from renaming and triggers validation alerts if selected for rename.
  • Bottom controls: Apply renames and keeps dialog open, Undo restores prior rename sets, OK renames and closes, Cancel closes without applying a new rename.
  • Safety rule avoids calling AutoCAD UNDO from DCL callbacks and instead uses a manual undo stack, while still grouping changes with VLA undo marks.
  • Persists last-used settings across runs for faster repeat usage.

Result:

  • On Apply, selected layouts are renamed immediately according to the preview plan, the dialog stays open, and Undo becomes available for rollback of the last rename operation.
  • On Undo, the most recent rename frame is reverted and the selection is restored to the reverted layout names; supports multi-level undo until the stack is empty.
  • On OK, performs the rename then closes the dialog, persisting the current UI settings for the next run.
  • On Cancel or close, no new rename is applied by this action and the dialog exits after capturing settings and cleaning up the temporary DCL file.
  • If validation fails, shows an alert explaining the issue and prevents renaming until corrected.
  • If no paper-space layouts exist, prints a message and exits without opening the dialog.

Images, animations etc.

layoutnum 000
layoutnum 001
layoutnum 002
layoutnum 003
Pixel

Additional info:

Share this page:

Page Tag: Lisp

  • LayoutNum

    Short description Provides a DCL dialog to batch rename layouts using sequential numbering with optional prefix, suffix, and zero-padding, with filtering and preview. Supports in-dialog Apply and multi-level Undo without calling AutoCAD UNDO from DCL callbacks, to avoid stability issues. Command: Commands: LAYOUTNUM, _LAYOUTNUM, LayoutNum Description: Builds a unique DCL dialog definition at runtime and…

  • LockAllVp

    Short description Tags: Layouts, Paper Space, Viewports, DCL, Dialog_UI, Lisp, CAD, Clipboard Suggested tags not in list: ObjectARX, COM_Automation, Stability, Undo_Stack Command: • LOCKALLVP Open the dialog to lock or unlock viewports in selected layouts. • LockAllVp Alias command to run the same dialog workflow. • _LOCKALLVP Underscore alias for macro use. Description: This tool…

  • Zoom Extend

    Short description LZE summary LZE opens a DCL selection dialog for Layouts, then runs Zoom Extents in Paper Space on the selected layouts after the dialog closes. Key stability rule The zoom action is executed after the dialog closes to avoid UI timing issues. Command: Command LZE Runs Zoom Extents on selected layouts in Paper…

  • Zoom Window

    Short description LZW summary LZW opens a DCL selection dialog for Layouts, then prompts for a window and runs Zoom Window in Paper Space on the selected layouts after the dialog closes. Key stability rule The zoom action is executed after the dialog closes to avoid UI timing issues. Command: Command LZW Runs Zoom Window…

  • Layouts_list

    Short description Shows a DCL dialog listing all layouts with wildcard filtering and multi-select, then copies the selected layout names to the Windows clipboard (one per line). Includes optional Model tab inclusion, selection count display, and Select All or Select None shortcuts. Command: Commands: ALL_LAYOUTS_LIST, All_Layouts_list Description: Collects layout names from the active drawing using…

  • FreezeLayersInVP

    Short description Shows a DCL dialog to filter and multi-select layers, then freezes the selected layers in the current viewport using VPLAYER. Supports filtering by Current layers, Xref layers, or Current_and_Xref, with an optional Xref picker and a fixed-width “faux columns” layer list. Command: Commands: FreezeLayersInVP and alias FLVP Description: Builds an embedded DCL file…

  • TitleBlocksTools

    Short description Title Blocks Tools – Unified Menu System Comprehensive dialog-based interface for exporting and updating titleblock attributes via CSV with integrated help, file management, and reload utilities. Command: Commands: TitleBlocksTools, EXPTBCSV_EXPORT, UTB2 Description: This integrated toolset combines CSV export and import functionality for titleblock attribute management: Main Menu Dialog provides radio button selection between…