LockAllVp

Short description

πŸ”’ AutoCAD layout viewport lock manager for locking or unlocking PaperSpace viewports in selected layouts from a DCL dialog.

Image 000 24

Command:

LOCKALLVP, LockAllVp, _LOCKALLVP

Description:

πŸ”’ LockAllVp is an AutoLISP / Visual LISP utility for batch locking and unlocking PaperSpace viewports across selected AutoCAD layouts.
🧭 It is designed for sheet-production workflows where plotted layouts must keep their viewport scale, pan, and orientation protected.
πŸ“‹ The routine builds a custom DCL dialog, lists layouts in tab order, shows viewport status per layout, and lets the user lock or unlock selected layouts without repeatedly switching tabs.
πŸ›‘οΈ It uses ActiveX DisplayLocked on AcDbViewport objects and avoids calling -VPORTS directly inside DCL, reducing command-context instability.

Helper function: (if any)​

LV:GetLayoutsTabOrder lists layouts by tab order.
LV:GetLayoutViewports traverses each layout block and collects AcDbViewport entities.
LV:_IsOverallPSViewport skips the overall PaperSpace viewport when Number = 1.
LV:LayoutStatus reports Locked, Unlocked, Mixed, NoVP, or Model.
LV:_SetLockedForLayouts applies DisplayLocked values and stores undo frames.
LV:CopyClipboard sends selected layout/status rows to the Windows clipboard using MSHTML or PowerShell/clip fallback.

Functionalities:

πŸ” Wildcard layout filter using * and ? for fast layout searching.
πŸ“‘ Multi-select layout list with Select All and Select None.
πŸ‘οΈ Status display for Locked, Unlocked, Mixed, NoVP, and Model.
πŸ”’ Lock selected layouts in one operation.
πŸ”“ Unlock selected layouts in one operation.
↩️ Manual multi-level undo stack for viewport lock changes.
πŸ“‹ Copy selected layout names and statuses to the clipboard.
🧩 Optional Include Model toggle, while Model is reported safely and not treated like a PaperSpace viewport workflow.

Result:

βœ… Faster control of viewport lock states across many layout tabs.
βœ… Reduced risk of accidental viewport scale or pan changes before plotting.
βœ… Clear QA overview of which layouts are fully locked, unlocked, mixed, or have no viewports.
βœ… Clipboard-friendly layout/status report for checking or documenting sheet readiness.

Images, animations etc.

Image 000 24
Image 001 14
Image 002 10
Image 003 7
Image 004 4
Pixel

XAML code:

ο»Ώ<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:src="clr-namespace:Autodesk.Windows;assembly=AdWindows">
    
<src:RibbonToolTip x:Key="LockAllVp">
<src:RibbonToolTip.ExpandedContent>
<StackPanel>
<TextBlock Background="AntiqueWhite" TextAlignment="Left">
<Bold>Function Syntax: LOCKALLVP / LockAllVp / _LOCKALLVP</Bold>
<LineBreak/>
<Bold>Version: 1.1 Date: 20.06.2026 6:38:55PM</Bold>
<LineBreak/>
<Hyperlink>AI+https://www.cadtutor.net/forum/topic/75876-unlocking-all-viewports-kent-cooper-kent1cooper/</Hyperlink>
<LineBreak/>
<Bold>Description</Bold><LineBreak/>


<Bold><Run Foreground="DodgerBlue">πŸ”’ Command name</Run></Bold><LineBreak/>
<Run>LOCKALLVP / LockAllVp / _LOCKALLVP</Run><LineBreak/>
<LineBreak/>
<Bold><Run Foreground="DodgerBlue">πŸš€ Description</Run></Bold><LineBreak/>
<Run>LockAllVp is an AutoCAD AutoLISP utility that batch locks or unlocks PaperSpace viewports in selected layouts. It is useful when preparing sheets for plotting, checking layout viewport states, or protecting viewport scales from accidental edits.</Run><LineBreak/>
<LineBreak/>
<Bold><Run Foreground="DodgerBlue">🧩 Dialog workflow</Run></Bold><LineBreak/>
<Run>The command opens a custom DCL interface with layout filtering, multi-selection, viewport status display, lock/unlock actions, selected count, clipboard copy, and manual undo.</Run><LineBreak/>
<LineBreak/>
<Bold><Run Foreground="DodgerBlue">πŸ“‹ Key features</Run></Bold><LineBreak/>
<Run>Wildcard filter with * and ?, Select All, Select None, Include Model toggle, Locked/Unlocked/Mixed/NoVP status, clipboard export, and multi-level undo inside the dialog.</Run><LineBreak/>
<LineBreak/>
<Bold><Run Foreground="DodgerBlue">πŸ› οΈ Technical behavior</Run></Bold><LineBreak/>
<Run>The code reads AutoCAD layouts in tab order, traverses PaperSpace layout blocks, detects AcDbViewport objects, skips the overall PaperSpace viewport, and applies the ActiveX DisplayLocked property.</Run><LineBreak/>
<LineBreak/>
<Bold><Run Foreground="DodgerBlue">βœ… Result</Run></Bold><LineBreak/>
<Run>The drawing manager can quickly make many layouts plot-safe by locking viewport display without opening each layout manually.</Run><LineBreak/>
<LineBreak/>
<Bold><Run Foreground="DodgerBlue">⚠️ Important notes</Run></Bold><LineBreak/>
<Run>This routine modifies viewport lock states. It avoids -VPORTS inside DCL and uses a manual undo stack while the dialog is open.</Run><LineBreak/>
<LineBreak/>
<Bold><Run Foreground="Orange">πŸ”Ž SEO keywords</Run></Bold><LineBreak/>
<Run>AutoCAD AutoLISP tool for Civil 3D productivity, drawing management, layout automation, viewport control, layer workflows, DCL dialogs, and CAD production QA: LockAllVp.</Run><LineBreak/>
<LineBreak/>
<Bold><Run Foreground="Yellow">🏷️ Tags</Run></Bold><LineBreak/>
<Run Foreground="Yellow">🏷️ AutoCAD, 🏷️ AutoLISP, 🏷️ Visual LISP, 🏷️ Civil 3D, 🏷️ Layouts, 🏷️ PaperSpace, 🏷️ Viewports, 🏷️ Viewport Lock, 🏷️ DCL Dialog, 🏷️ Sheet Production, 🏷️ CAD Automation, 🏷️ LOCKALLVP</Run><LineBreak/>







This program displays a dialog that lets you <Span Foreground="Red">Lock</Span> or <Span Foreground="Red">Unlock</Span> all Paper Space viewports in the <Span Foreground="DarkRed">selected layouts</Span>, without using fragile ARX command calls from inside DCL callbacks.<LineBreak/>
It is designed to be stable in AutoCAD and Civil 3D by using <Span Foreground="DarkRed">COM properties</Span> to change viewport lock state and by avoiding command-based locking during dialog actions.<LineBreak/>
<Bold>Commands</Bold>
<LineBreak/>
β€’ <Span Foreground="DarkRed">LOCKALLVP</Span> run the dialog tool.<LineBreak/>
β€’ <Span Foreground="DarkRed">LockAllVp</Span> run the dialog tool (same as above).<LineBreak/>
β€’ <Span Foreground="DarkRed">_LOCKALLVP</Span> run the dialog tool (underscore alias).<LineBreak/>
<Bold>User Workflow</Bold>
<LineBreak/>

Run <Span Foreground="DarkRed">LOCKALLVP</Span> to open the dialog.<LineBreak/>

Optionally filter layouts using wildcard pattern <Span Foreground="DarkRed">*</Span> and <Span Foreground="DarkRed">?</Span> then click <Span Foreground="DarkRed">Apply</Span> to rebuild the list.<LineBreak/>

Select one or more layouts in the list (multi-select).<LineBreak/>

Click <Span Foreground="Red">Lock</Span> or <Span Foreground="Red">Unlock</Span>
<LineBreak/>

The list immediately refreshes to show updated status per layout.<LineBreak/>

Use <Span Foreground="DarkRed">Undo</Span> to revert the last Lock or Unlock operation, including multi-level undo frames.<LineBreak/>

Use <Span Foreground="DarkRed">Copy to Clipboard</Span> to copy selected layout names plus their status.<LineBreak/>
<Bold>What the Dialog Shows</Bold>
<LineBreak/>
β€’ Each list row displays: <Span Foreground="DarkRed">Layout Name</Span> on the left and <Span Foreground="DarkRed">Status</Span> on the right.<LineBreak/>
β€’ Status values: <Span Foreground="DarkRed">Locked</Span>, <Span Foreground="DarkRed">Unlocked</Span>, <Span Foreground="DarkRed">Mixed</Span>, <Span Foreground="DarkRed">NoVP</Span>, <Span Foreground="DarkRed">Model</Span>.<LineBreak/>
β€’ The <Span Foreground="DarkRed">Selected</Span> counter updates based on the current multi-selection.<LineBreak/>
<Bold>Viewport Detection Logic</Bold>
<LineBreak/>
β€’ The program scans each chosen layout by reading the layout <Span Foreground="DarkRed">Block</Span> contents and collecting entities of type <Span Foreground="DarkRed">AcDbViewport</Span>.<LineBreak/>
β€’ It skips the overall Paper Space viewport when possible by ignoring viewport <Span Foreground="DarkRed">Number = 1</Span> to avoid unintended global effects.<LineBreak/>
β€’ If no valid viewports are found in a layout, the status becomes <Span Foreground="DarkRed">NoVP</Span>.<LineBreak/>
<Bold>Functionalities</Bold>
<LineBreak/>
β€’ <Span Foreground="DarkRed">Wildcard filtering</Span> of layouts using <Span Foreground="DarkRed">*</Span> and <Span Foreground="DarkRed">?</Span> with an Apply button that rebuilds the visible list.<LineBreak/>
β€’ <Span Foreground="DarkRed">Multi-select layouts</Span> with <Span Foreground="DarkRed">Select All</Span> and <Span Foreground="DarkRed">Select None</Span> controls.<LineBreak/>
β€’ <Span Foreground="Red">Lock</Span> all detected Paper Space viewports in the selected layouts by setting <Span Foreground="DarkRed">DisplayLocked</Span> to true via COM.<LineBreak/>
β€’ <Span Foreground="Red">Unlock</Span> all detected Paper Space viewports in the selected layouts by setting <Span Foreground="DarkRed">DisplayLocked</Span> to false via COM.<LineBreak/>
β€’ <Span Foreground="DarkRed">Live status refresh</Span> after Lock or Unlock so the list updates immediately to Locked, Unlocked, Mixed, or NoVP.<LineBreak/>
β€’ <Span Foreground="DarkRed">Safe Undo</Span> that stores changes as handle plus prior lock state and can revert multiple operations without calling AutoCAD UNDO from DCL.<LineBreak/>
β€’ <Span Foreground="DarkRed">Copy to Clipboard</Span> for selected layouts, copying lines formatted as layout name then status (tab-separated), one per line.<LineBreak/>
β€’ Optional <Span Foreground="DarkRed">Include Model</Span> toggle to show Model in the list, but Model is not modified and is displayed as <Span Foreground="DarkRed">Model</Span> status.<LineBreak/>
<Bold>Important Technical Notes</Bold>
<LineBreak/>
β€’ The tool intentionally avoids calling command-based viewport locking from DCL callbacks to reduce the risk of <Span Foreground="Red">ARX hard crashes</Span> and stack errors.<LineBreak/>
β€’ Lock and Unlock operations use COM property writes on <Span Foreground="DarkRed">AcDbViewport</Span> objects, which is typically more stable during UI interaction.<LineBreak/>
β€’ Undo is implemented as an internal stack of changes rather than using AutoCAD command undo inside the dialog callbacks.<LineBreak/>
<Bold>Result</Bold>
<LineBreak/>
After running the tool, the selected layouts will have their Paper Space viewports set to <Span Foreground="Red">Locked</Span> or <Span Foreground="Red">Unlocked</Span>
<LineBreak/>






</TextBlock>
            
<Grid>
<Image Source="Image_000.jpg" Stretch="Uniform"/>
</Grid>

<Grid>
<Image Source="Image_001.jpg" Stretch="Uniform"/>
</Grid>

<Grid>
<Image Source="Image_002.jpg" Stretch="Uniform"/>
</Grid>

<Grid>
<Image Source="Image_003.jpg" Stretch="Uniform"/>
</Grid>

<Grid>
<Image Source="Image_004.jpg" Stretch="Uniform"/>
</Grid>

</StackPanel>
</src:RibbonToolTip.ExpandedContent>
</src:RibbonToolTip>
</ResourceDictionary>

Share this page:

Leave a Reply

Page Tag: 🏷️ PaperSpace

  • LockAllVp

    β€”

    by

    Short descriptionπŸ”’ AutoCAD layout viewport lock manager for locking or unlocking PaperSpace viewports in selected layouts from a DCL dialog. Command:LOCKALLVP, LockAllVp, _LOCKALLVP Description:πŸ”’ LockAllVp is an AutoLISP / Visual LISP utility for batch locking and unlocking PaperSpace viewports across selected AutoCAD layouts. 🧭 It is designed for sheet-production workflows where plotted layouts must keep…