LayersNameToClipboard

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.

Pixel

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>

Additional info:

Share this page:

Leave a Reply

Page Tag: 🏷️ Layer Reporting

  • LayersNameToClipboard

    β€”

    by

    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…