Function Syntax: LayersNameToClipboard web Command name LayersNameToClipboard (type LayersNameToClipboard at the AutoCAD command line) Description This routine collects the unique layer names of the objects in a user selection set, strips simple MText-style formatting codes from the layer strings, and copies the resulting list to the Windows clipboard as plain text (one layer name per line). Prerequisite • Requires Visual LISP COM support via (vl-load-com). User interaction • The user is prompted to create a selection set using (ssget). • If the user cancels or selects nothing, the routine prints Nothing selected. High-level workflow • Builds a selection set using ssget. • Iterates through each entity in the selection set using sslength and ssname. • Converts each entity name to a VLA object using vlax-ename->vla-object. • Verifies the object exposes a Layer property using vlax-property-available-p. • Reads the layer name using vla-get-layer and cleans it via StripSimpleCodes. • Maintains a list of unique layer names by checking membership before adding. • Converts the unique list to a newline-separated string. • Copies the result to the Windows clipboard through an htmlfile COM object and ClipboardData SetData call. • Prints a summary showing the number of unique layers copied and echoes the copied content. Functionalities • Extracts layer names from a user selection set. • Ensures the output contains only unique layer names (no duplicates). • Removes simple formatting sequences embedded in the layer string using StripSimpleCodes. • Outputs the layer list as plain text, one entry per line. • Copies the final list directly to the clipboard for immediate paste into other applications. Helper function behavior StripSimpleCodes removes sequences that start with a backslash and typically end at the next semicolon. • Intended to remove full formatting tokens such as \A1; \C256; \fArial; so only the readable layer name remains. Important commands and calls highlighted (ssget) — prompts the user to select objects. sslength and ssname — iterates through the selection set. vlax-ename->vla-object — converts entity names to ActiveX objects. vlax-property-available-p — verifies the Layer property exists on the object. vla-get-layer — reads the layer name. vlax-create-object "htmlfile" — creates a COM object to access ClipboardData. ClipboardData SetData — writes the newline-separated text to the clipboard. Outputs and messages • If layers are found: prints Copied N unique layer name(s) to clipboard and lists the names. • If the selection contains no valid Layer properties or nothing usable: prints No valid layers found. • If nothing is selected: prints Nothing selected. Operational notes and limitations • Clipboard support relies on Windows COM interfaces; behavior may differ in non-Windows environments. • The uniqueness check is case-sensitive because it uses member on strings; layers that differ only by case may appear separately. • The formatting stripper removes backslash-initiated segments up to the next semicolon; unusual strings without semicolons are handled by removing a short portion after the backslash.