Short description
- ChangeLayer — DCL layer picker with wildcard filter and “pick from drawing” option
- Lists only visible layers (not off, not frozen) and supports * / ? pattern matching
- Remembers the last filter via environment variable and can auto-filter based on an object’s layer

Command:
- • ChangeLayer
Description:
- Opens a temporary DCL dialog titled Select Layer with a filter edit box and a single-select list of layers.
- Builds the layer list from the drawing’s layer table, including only layers that are not Off and not Frozen, then sorts them alphabetically.
- Allows filtering the list using wildcard patterns (* and ?) and updates the list live as the filter changes.
- Provides a Pick Layer from Drawing button that lets the user select an object and automatically uses that object’s layer as the filter pattern, then reopens the dialog.
- On OK, returns the chosen layer name; the command then sets CLAYER to that layer and prints confirmation; on cancel, prints a cancel message.
Helper function: (if any)
- • Drawing-Visible-Layers-lst — scans the LAYER table and returns a sorted list of layer names that are not Off (bit 1) and not Frozen (bit 4).
- • Update-List — applies wcmatch filtering to the full layer list and repopulates the DCL list_box.
- • Highlight-Layer — finds a layer name within the currently filtered list and selects/highlights it in the list box.
- • Show-Dialog — loads the generated DCL file, initializes the filter field, wires action_tile handlers, runs the dialog, unloads it, and returns the dialog result code.
- • LayerList-popup — orchestrates the DCL creation, dialog loop (including “pick from drawing”), persistence of last filter, and returns the selected layer name.
Functionalities:
- • Visible layer enumeration — uses tblnext over LAYER and filters by flags in group code 70 to exclude Off/Frozen layers.
- • Last filter persistence — reads CHLAY-LAST-FILTER from environment; defaults to * if none; saves it back on exit.
- • Temporary DCL generation — writes a layerfilter.dcl-style file to a temp path using vl-filename-mktemp and open/write-line.
- • Wildcard filtering — uses wcmatch against the filter pattern; treats an empty filter as *.
- • Live list refresh — filter edit_box action updates filter-pat and repopulates the list box immediately.
- • Single selection tracking — list_box action stores the selected index so the chosen layer can be returned on OK.
- • Pick layer from drawing — dialog button exits with a special code (2), prompts entsel, extracts group code 8 (layer), sets filter to that layer, then reopens dialog.
- • Cleanup — unloads the dialog, deletes the temporary DCL file, and writes the last-used filter to the environment.
- • Apply current layer — c:ChangeLayer sets CLAYER to the returned layer name and prints confirmation, otherwise prints cancel/no-selection message.
Result:
- If the user clicks OK after selecting a layer from the filtered list, the routine returns that layer name and the command sets it as the current layer (CLAYER).
- If the user clicks Pick Layer from Drawing, the filter is replaced with the picked object’s layer and the dialog reopens to streamline selection.
- If canceled or no valid list selection is made, the current layer is unchanged and a cancel/no-selection message is printed; the last filter pattern is still saved for next time.
Images, animations etc.



Log in to download.
Log in
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="ChangeLayer">
<src:RibbonToolTip.ExpandedContent>
<StackPanel>
<TextBlock Background="AntiqueWhite" TextAlignment="Left">
<Bold>Function Syntax: ChangeLayer</Bold>
<LineBreak/>
<Bold>Version: 1 Date: 09.09.2025</Bold>
<LineBreak/>
<LineBreak/>
<Hyperlink>AI+https://www.theswamp.org/index.php?topic=58620.0</Hyperlink>
<LineBreak/>
<Bold>Description</Bold>
<LineBreak/>
This AutoLISP program provides an intuitive interface for managing and switching between layers in an AutoCAD drawing.
<LineBreak/>
The user is presented with a filtered, searchable, and selectable list of visible layers, including an option to pick a layer directly from an object in the drawing.
<LineBreak/>
It streamlines layer control by allowing wildcard-based filtering and persistent settings across sessions.
<LineBreak/>
<Bold>Key Functionalities:</Bold>
<LineBreak/>
<TextBlock>
Prompts the user with a <Run Foreground="DarkRed">dialog interface</Run> to select a layer from the list of <Run Foreground="DarkRed">visible and unfrozen layers</Run>.
<LineBreak/>
</TextBlock>
<TextBlock>
Includes an <Run Foreground="DarkRed">edit box</Run> for entering a <Run Foreground="Red">wildcard-based filter</Run> (<Run Foreground="DarkRed">asterix</Run> and <Run Foreground="DarkRed">?</Run> supported).
<LineBreak/>
</TextBlock>
<TextBlock>
When the filter field is <Run Foreground="DarkRed">left empty</Run>, all visible layers are displayed.
<LineBreak/>
</TextBlock>
<TextBlock>
Adds a <Run Foreground="Red">Pick Layer from Drawing</Run> button that allows the user to select any entity in the drawing to <Run Foreground="DarkRed">automatically extract its layer</Run> and populate the filter.
<LineBreak/>
</TextBlock>
<TextBlock>
The matching layer is <Run Foreground="DarkRed">highlighted in the list box</Run>, ready for confirmation.
<LineBreak/>
</TextBlock>
<TextBlock>
The layer is <Run Foreground="Red">only changed</Run> when the user confirms with the <Run Foreground="DarkRed">OK</Run> button — <Run Foreground="DarkRed">Cancel</Run> exits with no changes.
<LineBreak/>
</TextBlock>
<TextBlock>
Remembers the <Run Foreground="DarkRed">last used filter</Run> across command runs using the AutoCAD registry (<Run Foreground="Red">setenv or getenv</Run> mechanisms).
<LineBreak/>
</TextBlock>
<TextBlock>
Only <Run Foreground="DarkRed">visible and unfrozen</Run> layers are considered for the list (layers that are OFF or FROZEN are skipped).
<LineBreak/>
</TextBlock>
<TextBlock>
The core command can be executed using: <Run Foreground="Red">CHLAY</Run>
<LineBreak/>
</TextBlock>
<Bold>Typical Use Case:</Bold>
<LineBreak/>
The user types <Run Foreground="Red">CHLAY</Run> in the command line.
<LineBreak/>
A dialog appears, showing all available layers (filtered using the last-used or default filter).
<LineBreak/>
The user can manually type a filter, select a layer from the list, or click <Run Foreground="Red">Pick Layer from Drawing</Run> to populate the filter and list automatically.
<LineBreak/>
Once the desired layer is highlighted, clicking <Run Foreground="DarkRed">OK</Run> sets that layer as the <Run Foreground="DarkRed">current active layer</Run>.
<LineBreak/>
<Bold>Important Commands:</Bold>
<LineBreak/>
<Run Foreground="Red">CHLAY</Run> — Launches the layer selection interface.
<LineBreak/>
<Run Foreground="Red">setenv or getenv</Run> — Used to persist the last-used filter.
<LineBreak/>
<Run Foreground="Red">entsel</Run> — Allows selecting an entity from the drawing.
<LineBreak/>
<Run Foreground="Red">assoc 8</Run> — Retrieves the layer name from the selected entity.
<LineBreak/>
<Run Foreground="Red">wcmatch</Run> — Performs wildcard-based filtering on layer names.
<LineBreak/>
<Bold>Layer Conditions:</Bold>
<LineBreak/>
Only layers that are both <Run Foreground="DarkRed">ON</Run> and <Run Foreground="DarkRed">THAWED</Run> are included in the list box.
<LineBreak/>
The logic filters layers using bitwise checks on <Run Foreground="Red">assoc 70</Run>.
<LineBreak/>
</TextBlock>
<Grid>
<Image Source="ChangeLayer_000.jpg" Stretch="Uniform"/>
</Grid>
<Grid>
<Image Source="ChangeLayer_001.jpg" Stretch="Uniform"/>
</Grid>
<Grid>
<Image Source="ChangeLayer_002.jpg" Stretch="Uniform"/>
</Grid>
</StackPanel>
</src:RibbonToolTip.ExpandedContent>
</src:RibbonToolTip>
</ResourceDictionary>
Additional info:
Based on / Source code:
Open Website
Share this page:
Subscribe
Login
0 Comments
Oldest
