Short description
- Opens a DCL dialog to filter layout names with wildcards and quickly switch the current tab to the selected match.
- Includes optional preview switching while browsing and remembers the last used filter pattern across runs.

Command:
- Command: GoToLayout
Description:
- Builds a unique temporary DCL file each run and launches a dialog titled Go To Layout with a filter edit box and a matches list.
- Reads available tabs from layoutlist and explicitly includes Model so both model and paper-space tabs can be targeted.
- Filters using case-insensitive wcmatch against the user pattern, treating an empty pattern as *, and sorts matches case-insensitively for predictable navigation.
- Provides browsing controls: selecting a list item or using < Prev and Next > updates the highlighted match, with wrap-around at the ends.
- When Preview switch while browsing is enabled, the routine switches CTAB live as the selection changes; OK finalizes the selection, Cancel restores the original tab.
Helper function: (if any)
- _gtl:temp-dcl-path generates a unique temp DCL filepath in the TEMP directory for each run.
- _gtl:write-dcl writes the dialog definition to the temp file, including filter input, preview toggle, count text, match list, and navigation buttons.
- _gtl:layouts-raw returns layout names and adds Model so it is included in the match set.
- _gtl:sort-ci sorts strings case-insensitively for consistent ordering.
- _gtl:filter-layouts filters layout names using case-insensitive wcmatch; empty filter becomes *.
- _gtl:fill-list fills the matches list box with the current filtered list.
- gtl:_set-ctab-if-preview switches CTAB to the currently indexed match when preview is enabled.
- gtl:update rebuilds matches when the pattern changes, updates the count label, selects the first match, and enables or disables OK and navigation depending on whether any matches exist.
- gtl:on-list updates the current index from the list selection and triggers preview switching if enabled.
- gtl:prev and gtl:next navigate the match list with wrap-around and trigger preview switching if enabled.
- c:GoToLayout manages dialog lifecycle, stores the original tab, persists the last pattern, and applies or restores CTAB based on OK or Cancel.
Functionalities:
- Wildcard filter input supporting * and ? to quickly narrow layout names.
- Case-insensitive matching and sorting for reliable results regardless of layout name casing.
- Preview toggle that can switch CTAB live as the user browses matches.
- Navigation buttons < Prev and Next > with wrap-around to cycle through matches efficiently.
- Automatic enabling and disabling of OK and navigation when zero layouts match the filter pattern.
- Remembers the last used pattern in a global variable so subsequent runs start with the previous filter.
- Restores the original tab on cancel or dialog close for safe browsing workflows.
Result:
- On OK, switches CTAB to the selected layout or Model tab and prints a confirmation line.
- If no matches exist, OK is disabled and the command prevents switching; if reached defensively, the routine restores the original tab and reports no matches.
- On Cancel or close, restores the original tab and prints Cancelled. Original tab restored.
- Always unloads the dialog and deletes the temporary DCL file after the dialog closes.
- If the DCL file cannot be written or the dialog cannot be loaded, prints an error message and exits without changing tabs.
Images, animations etc.

Log in
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="GoToLayout">
<src:RibbonToolTip.ExpandedContent>
<StackPanel>
<TextBlock Background="AntiqueWhite" TextAlignment="Left">
<Bold>Function Syntax: GoToLayout</Bold>
<LineBreak/>
<Bold>Version: 2 Date: 24.12.2025</Bold>
<LineBreak/>
<LineBreak/>
<Hyperlink>AI+https://forums.augi.com/showthread.php?69541-A-way-to-select-a-layout-tab-with-a-lisp</Hyperlink>
<LineBreak/>
<Bold>Summary</Bold><LineBreak/>
This program provides an interactive way to find and switch to drawing layouts using wildcard filters, through a temporary DCL dialog generated at runtime.<LineBreak/>
<Bold>How the user runs it</Bold><LineBreak/>
Type <Run Foreground="DarkRed"><Bold>GOTOLAYOUT</Bold></Run> at the AutoCAD command line to open the dialog.<LineBreak/>
<Bold>What the user does in the dialog</Bold><LineBreak/>
• Enter a layout name filter using wildcards <Run Foreground="DarkRed"><Bold></Bold></Run> and <Run Foreground="DarkRed"><Bold>?</Bold></Run> (example: <Run Foreground="DarkRed">A</Run>, <Run Foreground="DarkRed">SHEET??</Run>).<LineBreak/>
• Review matching layouts in a list (the list includes <Run Foreground="DarkRed"><Bold>Model</Bold></Run>).<LineBreak/>
• Optionally enable <Run Foreground="DarkRed"><Bold>Preview switch while browsing</Bold></Run> to switch tabs as you move through the list.<LineBreak/>
• Use <Run Foreground="DarkRed"><Bold>Next</Bold></Run> and <Run Foreground="DarkRed"><Bold>Prev</Bold></Run> to cycle through matches (wrap-around navigation).<LineBreak/>
• Click <Run Foreground="DarkRed"><Bold>OK</Bold></Run> to commit the selected layout, or <Run Foreground="DarkRed"><Bold>Cancel</Bold></Run> to revert to the original tab.<LineBreak/>
<Bold>Functionalities</Bold><LineBreak/>
• Filters layouts using wildcard matching via <Run Foreground="DarkRed"><Bold>wcmatch</Bold></Run> with <Run Foreground="DarkRed"><Bold>*</Bold></Run> and <Run Foreground="DarkRed"><Bold>?</Bold></Run> patterns.<LineBreak/>
• Preserves original layout name casing for display and for switching tabs (no forced uppercase for the actual layout names).<LineBreak/>
• Sorts matching results alphabetically in a case-insensitive manner for predictable browsing.<LineBreak/>
• Disables <Run Foreground="DarkRed"><Bold>OK</Bold></Run> and disables navigation when there are zero matches, preventing invalid layout switches.<LineBreak/>
• Remembers the last used filter pattern (it reappears the next time you run the command).<LineBreak/>
• Supports optional live switching using <Run Foreground="DarkRed"><Bold>Preview</Bold></Run>, so users can visually confirm they are on the intended sheet before committing.<LineBreak/>
<Bold>Important behaviors to recognize</Bold><LineBreak/>
• The active tab is changed by setting <Run Foreground="DarkRed"><Bold>CTAB</Bold></Run> to the selected layout name.<LineBreak/>
• If the user cancels, the program restores the original <Run Foreground="DarkRed"><Bold>CTAB</Bold></Run> (even if preview switching was used).<LineBreak/>
• If the filter is empty, it is treated as <Run Foreground="DarkRed"><Bold>*</Bold></Run> (meaning all layouts match).<LineBreak/>
<Bold>Temporary files and cleanup</Bold><LineBreak/>
• The dialog is created by writing a temporary <Run Foreground="DarkRed"><Bold>.dcl</Bold></Run> file with a unique name each run (generated with <Run Foreground="DarkRed"><Bold>vl-filename-mktemp</Bold></Run>).<LineBreak/>
• The temporary <Run Foreground="DarkRed"><Bold>.dcl</Bold></Run> file is deleted after the dialog closes, whether the user clicks OK or Cancel.<LineBreak/>
</TextBlock>
<Grid>
<Image Source="GoToLayout_000.jpg" Stretch="Uniform"/>
</Grid>
<Grid>
<MediaElement
Source="GIF"
Stretch="Uniform"
Visibility="Visible"/>
</Grid>
</StackPanel>
</src:RibbonToolTip.ExpandedContent>
</src:RibbonToolTip>
</ResourceDictionary>

Leave a Reply
You must be logged in to post a comment.