Function Syntax: ChangeLayerToSelected Version: 1 Date: 28.10.2025 N/A Command name ChangeLayerToCurrent (type ChangeLayerToCurrent at the AutoCAD command line) Description This routine lets the user choose a target layer using a filtered dialog or by picking an object in the drawing to capture its layer, and then moves a user-selected set of objects to that chosen layer using CHPROP. User interaction • The routine opens a dialog titled Select Layer (Filtered). • The dialog provides: • Edit box: Filter by Name (live filters layer list). • Dropdown: Matching Layers (choose target layer). • Button: Pick Layer From Drawing (select an entity to use its layer). • OK and Cancel buttons. • After a layer is confirmed, the user is prompted to select objects to move, with multi-selection enabled. High-level workflow • Loads the last used target layer from ChangeLayer_LastLayer. • Loads the last used filter text from ChangeLayer_LastFilter. • Builds a list of all non-xref layers in the drawing by iterating the Layers collection and excluding names matching *|*. • Writes a temporary DCL file and enters a dialog loop. • In the dialog, it maintains a live list of matching layers based on the current filter string. • Supports an alternate selection path where the user clicks Pick Layer From Drawing and then selects an entity to capture its layer. • Persists the chosen layer and the current filter back to environment variables for next time. • After the dialog completes with OK, it prompts for object selection and moves those objects to the chosen layer using CHPROP. Functionalities • Displays a layer-selection dialog with a live name filter. • Excludes xref layers from the selectable list by pattern *|*. • Remembers the last filter and last selected layer across runs using getenv and setenv. • Allows choosing a target layer by: • Selecting it from the filtered dropdown list. • Picking an object in the drawing and using that object layer. • Moves selected entities to the chosen layer using CHPROP with the LA option. • Supports multi-selection of entities to move (window, crossing, shift-add and remove, etc.). Dialog logic details • The dialog is rebuilt in a loop to allow the Pick Layer From Drawing workflow without losing state. • The layer list is filtered using wildcard matching: • It compares names using strcase and wcmatch against pattern *filter*. • Default dropdown selection priority: • Picked layer, if set and present in the filtered list. • Last used layer, if present in the filtered list. • Otherwise the first entry in the filtered list. Important commands and calls highlighted getenv and setenv — stores and recalls the last layer and filter text. vlax-for with Layers — enumerates all layer names from the drawing. wcmatch "*|*" — filters out xref layers. load_dialog, new_dialog, start_dialog — runs the temporary DCL dialog. action_tile — implements live filtering and captures user decisions. entsel and assoc 8 — reads the layer of a picked entity. ssget — selects the objects that will be moved to the chosen layer. CHPROP with LA — moves the selected objects to the chosen layer. Outputs and messages • If the dialog fails to load: prints Unable to load dialog. • If the user cancels: prints Operation cancelled. • If the user picks an object but its layer is not in the non-xref list: prints Picked layer not found in list. • If no objects are selected for the final move: prints No objects selected. • On success: prints that the entities were moved to the selected layer and echoes the layer name. Operational notes and limitations • Filtering is case-insensitive due to the use of strcase on both the layer name and filter pattern. • Xref filtering is based solely on the presence of a pipe character in the name; any non-xref layer containing a pipe will be excluded. • The routine uses AutoCAD commands for property changes; command localization or command overrides could affect behavior in some environments. • The dialog is written to a temporary file and deleted afterward; if the temp folder is not writable, the dialog cannot be created.