Short 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.
Command:
🚀 Main command: LayersNameToClipboard
🧩 Load the LSP in AutoCAD or Civil 3D, then type the command at the command line.
Description:
📋 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.
Helper function: (if any)
🧩 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.
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.
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.
Images, animations etc.
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="LayersNameToClipboard"> <src:RibbonToolTip.ExpandedContent> <StackPanel> <TextBlock Background="AntiqueWhite" TextAlignment="Left"> <Bold>Function Syntax: LayersNameToClipboard</Bold> <LineBreak/> <Bold>Version: 1.1 Date: 20.06.2026 6:38:54PM</Bold> <LineBreak/> <Hyperlink>web</Hyperlink> <LineBreak/> <Bold>Command name</Bold><LineBreak/> <Run>LayersNameToClipboard (type </Run><Run Foreground="DarkRed">LayersNameToClipboard</Run><Run> at the AutoCAD command line)</Run><LineBreak/> <Bold>Description</Bold><LineBreak/> <Run>This routine collects the </Run><Run Foreground="DarkRed">unique layer names</Run><Run> 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 </Run><Run Foreground="DarkRed">Windows clipboard</Run><Run> as plain text (one layer name per line).</Run><LineBreak/> <Bold>Prerequisite</Bold><LineBreak/> <Run>• Requires Visual LISP COM support via </Run><Run Foreground="DarkRed">(vl-load-com)</Run><Run>.</Run><LineBreak/> <Bold>User interaction</Bold><LineBreak/> <Run>• The user is prompted to create a selection set using </Run><Run Foreground="DarkRed">(ssget)</Run><Run>.</Run><LineBreak/> <Run>• If the user cancels or selects nothing, the routine prints </Run><Run Foreground="DarkRed">Nothing selected</Run><Run>.</Run><LineBreak/> <Bold>High-level workflow</Bold><LineBreak/> <Run>• Builds a selection set using </Run><Run Foreground="DarkRed">ssget</Run><Run>.</Run><LineBreak/> <Run>• Iterates through each entity in the selection set using </Run><Run Foreground="DarkRed">sslength</Run><Run> and </Run><Run Foreground="DarkRed">ssname</Run><Run>.</Run><LineBreak/> <Run>• Converts each entity name to a VLA object using </Run><Run Foreground="DarkRed">vlax-ename->vla-object</Run><Run>.</Run><LineBreak/> <Run>• Verifies the object exposes a Layer property using </Run><Run Foreground="DarkRed">vlax-property-available-p</Run><Run>.</Run><LineBreak/> <Run>• Reads the layer name using </Run><Run Foreground="DarkRed">vla-get-layer</Run><Run> and cleans it via </Run><Run Foreground="DarkRed">StripSimpleCodes</Run><Run>.</Run><LineBreak/> <Run>• Maintains a list of unique layer names by checking membership before adding.</Run><LineBreak/> <Run>• Converts the unique list to a newline-separated string.</Run><LineBreak/> <Run>• Copies the result to the Windows clipboard through an </Run><Run Foreground="DarkRed">htmlfile COM object</Run><Run> and ClipboardData SetData call.</Run><LineBreak/> <Run>• Prints a summary showing the number of unique layers copied and echoes the copied content.</Run><LineBreak/> <Bold>Functionalities</Bold><LineBreak/> <Run>• Extracts layer names from a user selection set.</Run><LineBreak/> <Run>• Ensures the output contains only </Run><Run Foreground="DarkRed">unique</Run><Run> layer names (no duplicates).</Run><LineBreak/> <Run>• Removes simple formatting sequences embedded in the layer string using </Run><Run Foreground="DarkRed">StripSimpleCodes</Run><Run>.</Run><LineBreak/> <Run>• Outputs the layer list as </Run><Run Foreground="DarkRed">plain text</Run><Run>, one entry per line.</Run><LineBreak/> <Run>• Copies the final list directly to the </Run><Run Foreground="DarkRed">clipboard</Run><Run> for immediate paste into other applications.</Run><LineBreak/> <Bold>Helper function behavior</Bold><LineBreak/> <Run>• <Run Foreground="DarkRed">StripSimpleCodes</Run> removes sequences that start with a backslash and typically end at the next semicolon.</Run><LineBreak/> <Run>• Intended to remove full formatting tokens such as \A1; \C256; \fArial; so only the readable layer name remains.</Run><LineBreak/> <Bold>Important commands and calls highlighted</Bold><LineBreak/> <Run>• <Run Foreground="DarkRed">(ssget)</Run> — prompts the user to select objects.</Run><LineBreak/> <Run>• <Run Foreground="DarkRed">sslength</Run> and <Run Foreground="DarkRed">ssname</Run> — iterates through the selection set.</Run><LineBreak/> <Run>• <Run Foreground="DarkRed">vlax-ename->vla-object</Run> — converts entity names to ActiveX objects.</Run><LineBreak/> <Run>• <Run Foreground="DarkRed">vlax-property-available-p</Run> — verifies the Layer property exists on the object.</Run><LineBreak/> <Run>• <Run Foreground="DarkRed">vla-get-layer</Run> — reads the layer name.</Run><LineBreak/> <Run>• <Run Foreground="DarkRed">vlax-create-object "htmlfile"</Run> — creates a COM object to access ClipboardData.</Run><LineBreak/> <Run>• <Run Foreground="DarkRed">ClipboardData SetData</Run> — writes the newline-separated text to the clipboard.</Run><LineBreak/> <Bold>Outputs and messages</Bold><LineBreak/> <Run>• If layers are found: prints </Run><Run Foreground="DarkRed">Copied N unique layer name(s) to clipboard</Run><Run> and lists the names.</Run><LineBreak/> <Run>• If the selection contains no valid Layer properties or nothing usable: prints </Run><Run Foreground="DarkRed">No valid layers found</Run><Run>.</Run><LineBreak/> <Run>• If nothing is selected: prints </Run><Run Foreground="DarkRed">Nothing selected</Run><Run>.</Run><LineBreak/> <Bold>Operational notes and limitations</Bold><LineBreak/> <Run>• Clipboard support relies on Windows COM interfaces; behavior may differ in non-Windows environments.</Run><LineBreak/> <Run>• The uniqueness check is case-sensitive because it uses </Run><Run Foreground="DarkRed">member</Run><Run> on strings; layers that differ only by case may appear separately.</Run><LineBreak/> <Run>• 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.</Run><LineBreak/> <Bold><Run Foreground="DodgerBlue">Description</Run></Bold><LineBreak/> <Run Foreground="White">📋 LayersNameToClipboard is an AutoCAD AutoLISP clipboard utility that reads the Layer property from selected objects and copies unique cleaned layer names.</Run><LineBreak/> <Run Foreground="White">🧹 It includes a simple formatting-code stripping helper and is useful for preparing layer-name lists for documentation, filters, Excel, and CAD QA workflows.</Run><LineBreak/> <LineBreak/> <Bold><Run Foreground="DodgerBlue">Function Syntax</Run></Bold><LineBreak/> <Run Foreground="White">🚀 Main command: </Run><Bold><Run Foreground="Orange">LayersNameToClipboard</Run></Bold><LineBreak/> <Run Foreground="White">📌 Load the LSP file with APPLOAD or from your AutoCAD startup suite, then run the command from the command line.</Run><LineBreak/> <LineBreak/> <Bold><Run Foreground="DodgerBlue">SEO Optimized Overview</Run></Bold><LineBreak/> <Run Foreground="White">📋 This AutoCAD command collects selected objects, converts them to VLA objects, and reads the Layer property where available.</Run><LineBreak/> <Run Foreground="White">🧹 The StripSimpleCodes helper removes backslash-based formatting codes from text before the layer name is stored.</Run><LineBreak/> <Run Foreground="White">🔎 Duplicate layer names are ignored so the final result contains each layer only once.</Run><LineBreak/> <Run Foreground="White">📄 The layer list is converted into newline-separated text, printed in the command line, and copied to the Windows clipboard.</Run><LineBreak/> <Run Foreground="White">⚙️ Clipboard output is created through the Windows htmlfile ActiveX clipboardData interface.</Run><LineBreak/> <LineBreak/> <Bold><Run Foreground="LimeGreen">Primary Workflow</Run></Bold><LineBreak/> <Run Foreground="White">1️⃣ Run LayersNameToClipboard.</Run><LineBreak/> <Run Foreground="White">2️⃣ Select drawing objects.</Run><LineBreak/> <Run Foreground="White">3️⃣ The routine reads the VLA Layer property for each object.</Run><LineBreak/> <Run Foreground="White">4️⃣ Duplicate names are removed and a newline-separated list is generated.</Run><LineBreak/> <Run Foreground="White">5️⃣ Paste the copied list into documentation, filters, scripts, or Excel.</Run><LineBreak/> <LineBreak/> <Bold><Run Foreground="LimeGreen">Core Functionalities</Run></Bold><LineBreak/> <Run Foreground="White">✅ Read unique layer names from selected AutoCAD objects.</Run><LineBreak/> <Run Foreground="White">✅ Use VLA object property access instead of raw DXF entity data.</Run><LineBreak/> <Run Foreground="White">✅ Check whether the selected object exposes a Layer property.</Run><LineBreak/> <Run Foreground="White">✅ Remove duplicate names from the collected list.</Run><LineBreak/> <Run Foreground="White">✅ Copy the cleaned list to the clipboard as newline-separated text.</Run><LineBreak/> <Run Foreground="White">✅ Print the number of copied unique layer names for confirmation.</Run><LineBreak/> <LineBreak/> <Bold><Run Foreground="DodgerBlue">Important Commands and Helper Functions</Run></Bold><LineBreak/> <Run Foreground="White">🧩 StripSimpleCodes removes simple AutoCAD formatting fragments such as \A1;, \C256;, and \fArial; from a text string.</Run><LineBreak/> <Run Foreground="White">🧩 C:LayersNameToClipboard runs the selection, VLA property reading, unique-list creation, clipboard copy, and command-line output.</Run><LineBreak/> <LineBreak/> <Bold><Run Foreground="LimeGreen">Result</Run></Bold><LineBreak/> <Run Foreground="White">✅ Unique selected-object layer names are copied to the Windows clipboard.</Run><LineBreak/> <Run Foreground="White">✅ The output can be pasted into layer filters, Excel sheets, text reports, scripts, or project documentation.</Run><LineBreak/> <LineBreak/> <Bold><Run Foreground="DarkOrange">Operational Notes</Run></Bold><LineBreak/> <Run Foreground="White">📌 This command operates on the current selection only.</Run><LineBreak/> <Run Foreground="DarkRed">⚠️ Objects without a Layer property are skipped.</Run><LineBreak/> <Run Foreground="DarkRed">⚠️ Clipboard output requires Visual LISP ActiveX and the Windows htmlfile clipboard object.</Run><LineBreak/> <LineBreak/> <Bold><Run Foreground="DodgerBlue">Best Use Cases</Run></Bold><LineBreak/> <Run Foreground="White">📋 VLA-based layer name extraction from selected objects.</Run><LineBreak/> <Run Foreground="White">🧹 Clean copied layer lists for documentation and filters.</Run><LineBreak/> <Run Foreground="White">📊 CAD QA and layer audit workflows.</Run><LineBreak/> <LineBreak/> <Bold><Run Foreground="Yellow">Tags</Run></Bold><LineBreak/> <Run Foreground="Yellow">🏷️ AutoCAD, 🏷️ AutoLISP, 🏷️ Civil 3D, 🏷️ Layer Names, 🏷️ Clipboard, 🏷️ VLA Object, 🏷️ Layer Reporting, 🏷️ CAD QA, 🏷️ Text Cleanup</Run><LineBreak/> </TextBlock> <!-- Use MediaElement for GIF (static first frame) and Image as fallback --> </StackPanel> </src:RibbonToolTip.ExpandedContent> </src:RibbonToolTip> </ResourceDictionary>

Leave a Reply
You must be logged in to post a comment.