Function Syntax: LayersNameToClipboard Version: 1.1 Date: 20.06.2026 6:38:54PM 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. Description 📋 LayersNameToClipboard is an AutoCAD AutoLISP clipboard utility that reads the Layer property from selected objects and copies unique cleaned layer names. 🧹 It includes a simple formatting-code stripping helper and is useful for preparing layer-name lists for documentation, filters, Excel, and CAD QA workflows. Function Syntax 🚀 Main command: LayersNameToClipboard 📌 Load the LSP file with APPLOAD or from your AutoCAD startup suite, then run the command from the command line. SEO Optimized Overview 📋 This AutoCAD command collects selected objects, converts them to VLA objects, and reads the Layer property where available. 🧹 The StripSimpleCodes helper removes backslash-based formatting codes from text before the layer name is stored. 🔎 Duplicate layer names are ignored so the final result contains each layer only once. 📄 The layer list is converted into newline-separated text, printed in the command line, and copied to the Windows clipboard. ⚙️ Clipboard output is created through the Windows htmlfile ActiveX clipboardData interface. Primary Workflow 1️⃣ Run LayersNameToClipboard. 2️⃣ Select drawing objects. 3️⃣ The routine reads the VLA Layer property for each object. 4️⃣ Duplicate names are removed and a newline-separated list is generated. 5️⃣ Paste the copied list into documentation, filters, scripts, or Excel. Core Functionalities ✅ Read unique layer names from selected AutoCAD objects. ✅ Use VLA object property access instead of raw DXF entity data. ✅ Check whether the selected object exposes a Layer property. ✅ Remove duplicate names from the collected list. ✅ Copy the cleaned list to the clipboard as newline-separated text. ✅ Print the number of copied unique layer names for confirmation. Important Commands and Helper Functions 🧩 StripSimpleCodes removes simple AutoCAD formatting fragments such as \A1;, \C256;, and \fArial; from a text string. 🧩 C:LayersNameToClipboard runs the selection, VLA property reading, unique-list creation, clipboard copy, and command-line output. Result ✅ Unique selected-object layer names are copied to the Windows clipboard. ✅ The output can be pasted into layer filters, Excel sheets, text reports, scripts, or project documentation. Operational Notes 📌 This command operates on the current selection only. ⚠️ Objects without a Layer property are skipped. ⚠️ Clipboard output requires Visual LISP ActiveX and the Windows htmlfile clipboard object. Best Use Cases 📋 VLA-based layer name extraction from selected objects. 🧹 Clean copied layer lists for documentation and filters. 📊 CAD QA and layer audit workflows. Tags 🏷️ AutoCAD, 🏷️ AutoLISP, 🏷️ Civil 3D, 🏷️ Layer Names, 🏷️ Clipboard, 🏷️ VLA Object, 🏷️ Layer Reporting, 🏷️ CAD QA, 🏷️ Text Cleanup