Function Syntax: LAYOUTNUM / _LAYOUTNUM / LayoutNum Version: 1.1 Date: 20.06.2026 6:38:55PM AI+https://www.cadtutor.net/forum/topic/14298-tabsortlsp/ LayoutNum — Layout Numbering and Renaming Utility This program will prompt the user with a dialog to filter, select, preview, and rename drawing layouts (paper space tabs), using a controlled numbering scheme. How to Run Commands: LAYOUTNUM, _LAYOUTNUM, LayoutNum Running any of these commands opens the Layout Numbering dialog. What the User Must DoOptionally enter a wildcard filter using * and ? to narrow the layout list.Select one or more layouts from the list (multi-select).Enter rename parameters: Starting Number, Width, Prefix, Suffix.Review the Preview (Old to New) before committing changes. Primary FunctionalitiesFilter layouts by wildcard pattern: Apply Filter rebuilds the visible list using patterns such as A* or Sheet??.Multi-select layout targeting: The list supports selecting multiple layouts for batch renaming.Select All and Select None: Quickly select every visible layout or clear the selection.Preview before rename: Shows a calculated mapping of each selected layout name to the proposed new name.Batch rename with numbering: Renames selected layouts to Prefix plus a sequential number plus Suffix.Zero padding control: Width controls numeric padding, such as 01 or 001.Ordering control: Numbering can follow Tab Order or Alphabetical order.Automatic conflict resolution: Optionally appends -1, -2, and so on, if a generated name already exists.Include Model option: Model can be shown in the list, but it is flagged as cannot rename and will block applying changes if selected. Dialog Buttons and ActionsApply Filter: Applies the wildcard filter and refreshes the visible layout list without renaming.Refresh Preview: Recomputes the Old to New mapping from the current selection and rename settings.Apply: Performs the renaming immediately and keeps the dialog open.Undo: Reverts the most recent Apply or OK rename operation using a safe internal rename history.OK: Performs the renaming and closes the dialog.Cancel: Closes the dialog without performing a new rename action. Important Behaviors and ConstraintsModel layout cannot be renamed: If Model is included and selected, renaming is blocked to prevent invalid operations.Undo is manual and safe: Undo does not rely on AutoCAD UNDO command calls during the dialog, avoiding ARX exceptions.No forced exit: The dialog remains open after Apply so the user can apply multiple rename passes.User settings persist between runs (filter, numbering, width, prefix, suffix, options). Typical Use Case ExampleFilter: * to show all layouts.Select layouts: Layout1 and Layout2.Set: Starting Number 1, Width 2, Prefix aaa_, Suffix blank.Preview shows: Layout1 => aaa_01 and Layout2 => aaa_02.Press Apply to rename without closing, or OK to rename and close. Description 🔢 LayoutNum is an AutoCAD and Civil 3D AutoLISP layout renumbering utility with a DCL interface, preview list, Apply, safe multi-level Undo, OK, and Cancel workflow. 📑 It helps rename selected layout tabs using starting numbers, padding width, prefix, suffix, order modes, filters, and automatic conflict resolution. Function Syntax 🚀 Main dialog command: LAYOUTNUM 🔁 Alias command: _LAYOUTNUM 🔁 Alias command: LayoutNum 🧰 Load the LSP with APPLOAD and run the command in AutoCAD or Civil 3D. SEO Optimized Overview 🔢 LayoutNum is an SEO-friendly AutoCAD layout renaming and layout numbering tool for production drawings with many paper-space tabs. 📑 The routine builds a temporary DCL dialog titled Layout Numbering with wildcard filter, multi-select layout list, preview panel showing Old to New names, Select All, Select None, Apply, Undo, OK, and Cancel. 🧮 Users define the starting number, numeric width, prefix, suffix, and order mode to generate consistent layout names for Civil 3D sheets and AutoCAD plotting tabs. 🧠 The tool supports tab-order or alphabetical processing, optional inclusion of Model for reference, automatic conflict resolution using -1, -2 style suffixes, and persistent defaults for repeated runs. 🛡️ The code intentionally avoids calling AutoCAD UNDO from DCL callbacks and instead uses a manual multi-level undo stack that restores previous layout names safely. 📌 This is useful for batch layout renaming, sheet numbering, drawing package cleanup, plan set standardization, plotting tab organization, and Civil 3D production-sheet management. Primary Workflow 1️⃣ Load LayoutNum into AutoCAD or Civil 3D with APPLOAD. 2️⃣ Run LAYOUTNUM from the command line. 3️⃣ Use the dialog or command prompts to select the target layouts, layers, viewports, or plot settings. 4️⃣ Review the preview, status list, or command-line feedback before applying changes. 5️⃣ Apply the operation and verify the result in the active drawing. Main Functionalities ✅ Rename selected layout tabs in batch. ✅ Filter layout names with wildcard patterns using * and ?. ✅ Preview every planned rename as Old to New before applying changes. ✅ Generate names from prefix, starting number, zero-padding width, and suffix. ✅ Process selected layouts by tab order or alphabetical order. ✅ Select all filtered layouts or clear the selection quickly. ✅ Auto-resolve naming conflicts when enabled. ✅ Apply renames while keeping the dialog open. ✅ Use a safe manual multi-level undo stack instead of command-line UNDO from DCL callbacks. ✅ Remember previous dialog values for faster repeated numbering sessions. Important Commands and Helper Functions 🧩 LayoutNum:WriteDCL dynamically creates the Layout Numbering dialog. 🧩 LayoutNum:LayoutsTabOrder collects layout objects in tab order with optional Model inclusion. 🧩 LayoutNum:SortByName sorts layout rows alphabetically when Alpha order is selected. 🧩 LayoutNum:PadNumber formats layout numbers with the requested numeric width. 🧩 LayoutNum:ComputeRenamePlan builds the Old to New preview plan from selected layouts. 🧩 LayoutNum:ResolveConflict creates an alternate name when Auto-resolve is enabled. 🧩 LayoutNum:ValidateBeforeRename prevents Model renaming, duplicate names, invalid numbers, and name conflicts. 🧩 LayoutNum:ApplyRename performs the layout renaming through vla-put-Name and records undo frames. 🧩 LayoutNum:DoUndo restores renamed layouts from the manual undo stack. 🧩 LayoutNum:Cleanup unloads the temporary dialog and deletes the DCL file. Practical Result 🎯 The result is a controlled, preview-based layout renaming workflow for AutoCAD and Civil 3D drawings. 📑 Users can standardize sheet names, add project prefixes, apply numbered sequences, and repair layout naming order without manual tab-by-tab edits. ✅ LayoutNum improves CAD sheet organization, plotting consistency, and production drawing management. Important Notes ⚠️ The tool changes real layout tab names in the active drawing. ⚠️ Model can be displayed for reference but cannot be renamed. ⚠️ Without Auto-resolve, duplicate generated names or existing-name conflicts block the operation. ⚠️ Testing on a backup drawing is recommended before renaming large drawing packages. ⚠️ Layout name rules are still governed by AutoCAD; invalid names may be rejected by vla-put-Name. Tags 🏷️ AutoCAD, 🏷️ Civil 3D, 🏷️ AutoLISP, 🏷️ Visual LISP, 🏷️ DCL dialog, 🏷️ CAD automation, 🏷️ CAD productivity, 🏷️ Layout renaming, 🏷️ Layout numbering, 🏷️ Batch rename, 🏷️ Sheet numbering, 🏷️ Paper space, 🏷️ Layout tabs, 🏷️ Plot tabs, 🏷️ Layout preview, 🏷️ Safe undo, 🏷️ vla-put-Name, 🏷️ LAYOUTNUM