Short description
- ChangeLayerToCurrent — DCL filtered layer chooser + optional “pick layer from drawing”, then move selected objects to that layer
- Filters layer names (non-Xref only) using a substring-style match and remembers last filter + last chosen layer
- After choosing a layer, prompts for a multi-selection of objects and runs CHPROP to change their layer

Command:
- ChangeLayerToCurrent
Description:
- Reads the last used layer and last filter from environment variables ChangeLayer_LastLayer and ChangeLayer_LastFilter to initialize the dialog state.
- Builds a sorted list of all drawing layers excluding Xref layers (names matching *|*).
- Creates a temporary DCL dialog with a filter edit box, a popup list of matching layers, and a button to pick a layer from an object in the drawing.
- When the user clicks OK, stores the chosen layer and filter back to the environment, then proceeds to object selection and changes those objects to the chosen layer via CHPROP.
- If the user clicks Pick Layer From Drawing, the routine prompts for an object, captures its layer, and reopens the dialog with that layer preselected (while retaining the last filter text).
Helper function: (if any)
- • get-all-layers — collects all non-Xref layer names from the document’s Layers collection and sorts them alphabetically.
- • update-layer-list — filters the layer list using a case-insensitive “contains” match (*filter*), repopulates the popup list, and sets a preselection (picked layer, else last layer, else first item).
- • Environment persistence — uses setenv / getenv to remember last filter and last selected layer between runs.
Functionalities:
- • Layer scope — enumerates layers from the active document and excludes Xref layers by rejecting names matching *|*.
- • Temporary DCL generation — writes a dialog definition to a temp .dcl file and loads it each loop iteration.
- • Filter behavior — filter text is applied as a substring match using wcmatch against *filter* (case-insensitive); empty filter shows all layers.
- • Preselection rules — if a picked layer exists in the filtered list, it is selected; else if the last used layer exists, it is selected; otherwise the first entry is selected.
- • OK handler — captures current filter and selected popup index, resolves the layer name, saves ChangeLayer_LastFilter and ChangeLayer_LastLayer, then closes dialog with result 1.
- • Pick-from-drawing handler — closes dialog with result 2, prompts for an entity via entsel, reads group code 8 (layer), validates it exists in the non-Xref layer list, then reopens the dialog.
- • Final object selection — after OK, prompts for a multi-selection using ssget (no single-select flags), allowing window/crossing and add/remove selection gestures.
- • Apply layer change — runs _.CHPROP on the selected set and sets property LA to the chosen layer name.
- • Cleanup — unloads the dialog each loop and deletes the temporary DCL file at the end of the routine.
Result:
- The user chooses a target layer from a filtered popup list (optionally seeded by picking an object’s layer), and the last filter/selection are remembered for the next run.
- After confirming the layer, the user selects multiple objects and those entities are moved to the chosen layer using CHPROP.
- If the user cancels the dialog or selects no objects, no changes are made and the routine prints a cancel/no-selection message.
Images, animations etc.



Log in to download.
Log in
Log in
Additional info:
Based on / Source code:
Open Website
Share this page:
Tags: Layers
Tags: Layers
