NCopyExtra

Short description

Sort / Purpose: Copy nested objects from xrefs or blocks into the current drawing so they become local entities on local layers that mirror the xref layer properties. β€’ Scope: Works on objects selected with NENTSEL / NENTSELp, including items on xref layers like “_XREF|VG_KK”. β€’ Goal: Quickly β€œdetach” geometry from xrefs by copying it out onto new local layers that inherit color, linetype, and lineweight from the original xref layer.

Command:

Command name: NCopyExtra How to run: Load the LISP file, then type NCopyExtra in the command line and press Enter. β€’ Selection: Repeatedly pick nested objects (e.g. in xrefs or blocks) when prompted; press Enter to finish and exit the loop.

Description:

β€’ Environment setup: Grabs the current AutoCAD application, active document, and layer table to manage layer creation and property copying. β€’ Nested selection: Uses NENTSELp to let you pick objects inside xrefs or block references, capturing both the picked entity and its transform matrix. β€’ Layer name read: Reads the original entity’s layer name (for example “_XREF|VG_KK”) from its DXF group 8 data. β€’ Xref prefix cleanup: Detects a “|” in the layer name and trims off the xref prefix so only the local layer name remains (e.g. turns “_XREF|VG_KK” into “VG_KK”). β€’ Entity cloning: Creates a new entity in the current space using ENTMAKEX with the original entity’s DXF data. β€’ Transform application: Applies the nested transform matrix returned by NENTSELp so the copied entity appears in the correct location and orientation in the current space. β€’ Layer object retrieval: Gets the full original layer object (including the xref prefix) from the layer table to read its visual properties. β€’ Local layer ensure: Checks if the trimmed local layer already exists; if not, creates it, otherwise reuses the existing local layer object. β€’ Property mirroring: Copies color, linetype, and lineweight from the xref layer object to the corresponding local layer, synchronizing their appearance. β€’ Layer reassignment: Assigns the newly created entity to the trimmed local layer name so it no longer resides on an xref layer. β€’ Loop behavior: Repeats the selection–copy–layer process for each picked object until you press Enter with no selection to end the command.

Helper function: (if any)​

Core tools and functions used: β€’ vl-load-com: Enables COM / ActiveX access so VLA layer and entity properties can be read and written. β€’ vlax-get-acad-object: Retrieves the main AutoCAD application object. β€’ vla-get-ActiveDocument: Accesses the current drawing document where entities and layers live. β€’ vla-get-Layers: Returns the Layers collection used to query existing layers and add new ones. β€’ nentselp: Picks nested entities and returns both the entity name and the transformation matrix for proper world placement. β€’ entget: Reads DXF data from the picked entity to get its layer name and geometry definition. β€’ entmakex: Creates a new entity from the original entity’s DXF list in the active space. β€’ vlax-tmatrix: Converts the nentsel transformation list into a transformation matrix object usable by VLA. β€’ vla-transformby: Applies the nested transformation so the copy is correctly positioned and oriented. β€’ vla-item: Fetches specific Layer objects by name from the Layers collection (both original xref layer and local layer). β€’ vla-add: Creates a new layer when the trimmed local layer does not yet exist. β€’ vla-put-Color / LineType / Lineweight: Transfer visual properties from the xref layer to the local mirrored layer. β€’ vla-put-Layer: Assigns the copied entity to the desired local layer name.

Functionalities:

β€’ Xref geometry extraction: Copies geometry out of xrefs or nested blocks into the current drawing space while preserving position and orientation. β€’ Layer name cleaning: Automatically strips the xref prefix from layer names so copied entities end up on clean local layers (e.g. “VG_KK” instead of “_XREF|VG_KK”). β€’ Local layer creation: Automatically creates missing local layers on the fly when they do not already exist in the drawing. β€’ Visual property sync: Mirrors color, linetype, and lineweight from the original xref layer to the local layer to maintain the same visual appearance. β€’ Entity relocation: New copies are placed directly on the local (non-xref) layer, making them independent from the xref reference. β€’ Multi-pick workflow: You can keep picking objects one after another and each one will be copied and re-layered until you press Enter to finish. β€’ Safe layer handling: Operates only on layers that actually exist and ensures new layers are properly initialized before use.

Result:

Result: Each picked nested object is duplicated into the current drawing as an independent entity on a clean local layer whose properties match the original xref layer. β€’ Independent geometry: The copied entities no longer depend on the xref; they are fully local and editable even if the xref is unloaded or detached. β€’ Clean layer structure: The drawing gets local layers (without xref prefixes) that visually match the xref layers, helping to standardize and simplify layer naming. β€’ Consistent appearance: Because color, linetype, and lineweight are cloned from the original xref layer, the copied entities look identical to what they were inside the xref. β€’ Controlled extraction: You decide interactively which pieces to pull from the xref or block, one pick at a time, instead of exploding or binding the entire reference. Copy code: Copy NCopyExtra LISP

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="NCopyExtra">
<src:RibbonToolTip.ExpandedContent>
<StackPanel>
<TextBlock Background="AntiqueWhite" TextAlignment="Left">
<Bold>Function Syntax: NCopyExtra</Bold>
<LineBreak/>
<Bold>Version: 1 Date: 13.10.2025</Bold>
<LineBreak/>
<LineBreak/>
<Hyperlink>AI+https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-ncopy-multiple-at-same-place-or-pause-the-ncopy-command/td-p/10932882</Hyperlink>
<LineBreak/>
<Bold>Command name</Bold><LineBreak/>
<Run>NCopyExtra (type </Run><Run Foreground="DarkRed">NCopyExtra</Run><Run> at the AutoCAD command line)</Run><LineBreak/>
<LineBreak/>

<Bold>Description</Bold><LineBreak/>
<Run>This routine copies a selected object and places the new copy onto a </Run><Run Foreground="DarkRed">local layer name</Run><Run> (xref prefix removed), while preserving the original object geometry and matching the layer properties (color, linetype, lineweight) from the xref layer.</Run><LineBreak/>
<LineBreak/>

<Bold>User interaction</Bold><LineBreak/>
<Run>β€’ The user is repeatedly prompted to </Run><Run Foreground="DarkRed">select an object to copy</Run><Run>.</Run><LineBreak/>
<Run>β€’ The routine continues in a loop until the user </Run><Run Foreground="DarkRed">cancels selection</Run><Run> (for example Esc).</Run><LineBreak/>
<LineBreak/>

<Bold>High-level workflow</Bold><LineBreak/>
<Run>β€’ Accesses the current AutoCAD document and its layer table using </Run><Run Foreground="DarkRed">ActiveX (VLA and VLAX)</Run><Run>.</Run><LineBreak/>
<Run>β€’ Reads the selected object entity data, including its </Run><Run Foreground="DarkRed">layer (group code 8)</Run><Run>.</Run><LineBreak/>
<Run>β€’ If the layer is an xref layer (contains </Run><Run Foreground="DarkRed">|</Run><Run>), it trims the prefix and keeps only the part after the separator.</Run><LineBreak/>
<Run>β€’ Creates a new entity from the original entity list using </Run><Run Foreground="DarkRed">entmakex</Run><Run>.</Run><LineBreak/>
<Run>β€’ Applies the correct transformation matrix from the selection pick data so the copy appears in the correct position and orientation using </Run><Run Foreground="DarkRed">vla-transformby</Run><Run>.</Run><LineBreak/>
<Run>β€’ Retrieves the </Run><Run Foreground="DarkRed">xref layer object</Run><Run> (full layer name including xref prefix) from the Layers collection.</Run><LineBreak/>
<Run>β€’ Ensures the </Run><Run Foreground="DarkRed">local trimmed layer</Run><Run> exists, creating it if needed.</Run><LineBreak/>
<Run>β€’ Copies key properties from the xref layer to the local layer (color, linetype, lineweight).</Run><LineBreak/>
<Run>β€’ Assigns the new entity to the local trimmed layer.</Run><LineBreak/>
<LineBreak/>

<Bold>Functionalities</Bold><LineBreak/>
<Run>β€’ Object duplication that preserves the original entity definition using </Run><Run Foreground="DarkRed">entget</Run><Run> and </Run><Run Foreground="DarkRed">entmakex</Run><Run>.</Run><LineBreak/>
<Run>β€’ Automatic xref layer name cleanup (</Run><Run Foreground="DarkRed">_XREF|LayerName</Run><Run> becomes </Run><Run Foreground="DarkRed">LayerName</Run><Run>).</Run><LineBreak/>
<Run>β€’ Automatic creation of the destination layer if it does not exist (adds the trimmed name to the local drawing).</Run><LineBreak/>
<Run>β€’ Layer standards carry-over from the xref layer to the local layer:</Run><LineBreak/>
<Run>  β€’ <Run Foreground="DarkRed">Color</Run> is copied.</Run><LineBreak/>
<Run>  β€’ <Run Foreground="DarkRed">Linetype</Run> is copied.</Run><LineBreak/>
<Run>  β€’ <Run Foreground="DarkRed">Lineweight</Run> is copied.</Run><LineBreak/>
<Run>β€’ Ensures the copied entity is placed onto the </Run><Run Foreground="DarkRed">trimmed local layer</Run><Run> via </Run><Run Foreground="DarkRed">vla-put-layer</Run><Run>.</Run><LineBreak/>
<LineBreak/>

<Bold>Important commands and calls highlighted</Bold><LineBreak/>
<Run>β€’ <Run Foreground="DarkRed">nentselp</Run> β€” interactive selection that also provides transformation context (used for correct placement).</Run><LineBreak/>
<Run>β€’ <Run Foreground="DarkRed">entget</Run> β€” reads the original entity definition.</Run><LineBreak/>
<Run>β€’ <Run Foreground="DarkRed">entmakex</Run> β€” creates the new copied entity in the drawing database.</Run><LineBreak/>
<Run>β€’ <Run Foreground="DarkRed">vla-transformby</Run> β€” applies the selection matrix so the new entity matches the original’s position and orientation.</Run><LineBreak/>
<Run>β€’ <Run Foreground="DarkRed">vla-item</Run> and <Run Foreground="DarkRed">vla-add</Run> β€” reads and creates layers in the drawing.</Run><LineBreak/>
<Run>β€’ <Run Foreground="DarkRed">vla-put-Color</Run>, <Run Foreground="DarkRed">vla-put-LineType</Run>, <Run Foreground="DarkRed">vla-put-Lineweight</Run> β€” transfers layer properties.</Run><LineBreak/>
<Run>β€’ <Run Foreground="DarkRed">vla-put-layer</Run> β€” assigns the copied entity to the cleaned layer name.</Run><LineBreak/>
<LineBreak/>

<Bold>Operational notes and limitations</Bold><LineBreak/>
<Run>β€’ This routine depends on </Run><Run Foreground="DarkRed">Visual LISP ActiveX</Run><Run>, so include </Run><Run Foreground="DarkRed">(vl-load-com)</Run><Run> before running it.</Run><LineBreak/>
<Run>β€’ It copies the raw entity data; complex or proxy entities may behave differently depending on object type and available DXF data.</Run><LineBreak/>
<Run>β€’ The xref layer must exist in the drawing layer table under its full name for the property copy step to succeed.</Run><LineBreak/>


</TextBlock>
            
<Grid>
<Image Source="PNG" Stretch="Uniform"/>
</Grid>

<Grid>
<MediaElement
 Source="GIF"
 Stretch="Uniform"
 Visibility="Visible"/>
 </Grid>

</StackPanel>
</src:RibbonToolTip.ExpandedContent>
</src:RibbonToolTip>
</ResourceDictionary>



Additional info:

Share this page:

Leave a Reply

Page Tag: 🏷️ Autocad Lisps

  • NCopyExtra

    β€”

    by

    Short description Sort / Purpose: Copy nested objects from xrefs or blocks into the current drawing so they become local entities on local layers that mirror the xref layer properties. β€’ Scope: Works on objects selected with NENTSEL / NENTSELp, including items on xref layers like “_XREF|VG_KK”. β€’ Goal: Quickly β€œdetach” geometry from xrefs by…

  • CopyPaste2BasePoint

    β€”

    by

    Short description Command: Description: Helper function: (if any)​ Functionalities: Result: Images, animations etc. XAML code: Expand Code ↓ Select Code Copy Code Expand Code ⬇ Select Code Copy Code Additional info: Based on / Source code: Share this page:

  • CopyMove2MidPoint

    β€”

    by

    Short description Command: Description: Helper function: (if any)​ Functionalities: Result: Images, animations etc. XAML code: Expand Code ↓ Select Code Copy Code Expand Code ⬇ Select Code Copy Code Additional info: Based on / Source code: Share this page:

  • CookieCutter2

    β€”

    by

    Short description Command: Description: Helper function: (if any)​ Functionalities: Result: Images, animations etc. XAML code: Expand Code ↓ Select Code Copy 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="CookieCutter2"> <src:RibbonToolTip.ExpandedContent> <StackPanel> <TextBlock Background="AntiqueWhite" TextAlignment="Left"> <Bold>Function Syntax: CookieCutter2 / CC / DelOutside / CookieCutter2Multi / CC2M</Bold> <LineBreak/> <Bold>Version: 1.1 Date: 20.06.2026 6:38:50PM</Bold> <LineBreak/> <Hyperlink>https://www.cadtutor.net/forum/topic/66934-help-lisp-cookiecutter2-v12-mod-by-vva-dont-trim-polyline-3d/</Hyperlink> <LineBreak/> <Bold><Run Foreground="DodgerBlue">πŸš€…

  • CenterAreaCentroid

    β€”

    by

    Short description Command: Description: Helper function: (if any)​ Functionalities: Result: Images, animations etc. XAML code: Expand Code ↓ Select Code Copy Code Expand Code ⬇ Select Code Copy Code Additional info: Based on / Source code: Share this page:

  • TotalLengthPolyline

    β€”

    by

    Short description Command: Description: Helper function: (if any)​ Functionalities: Result: Images, animations etc. XAML code: Expand Code ↓ Select Code Copy 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="TotalLengthPolyline"> <src:RibbonToolTip.ExpandedContent> <StackPanel> <TextBlock Background="AntiqueWhite" TextAlignment="Left"> <Bold>Function Syntax: tlen</Bold> <LineBreak/> <Hyperlink>https://gist.github.com/kevinluo201/51450de14f63382c046c6d840bb42c96</Hyperlink> <LineBreak/> <Bold><Run Foreground="DodgerBlue">πŸ“ Description</Run></Bold><LineBreak/> <Run Foreground="White">This AutoLISP program </Run><Bold><Run Foreground="Orange">TLEN</Run></Bold><Run Foreground="White"> calculates and reports the total length…

  • TotalLengthAreaDetailed_vs_01

    Short description Short description Calculates total length or area of selected objects, copies an Excel ready formula to the clipboard, and optionally places a formatted result as MText in AutoCAD using the current UCS. Command: Command name TotalLengthAreaDetailed Description: What it does β€’ Dialog choice Lets you choose between Length or Area, set Excel related…

  • TotalLengthAll

    β€”

    by

    Short description Command: Description: Helper function: (if any)​ Functionalities: Result: Images, animations etc. XAML code: Expand Code ↓ Select Code Copy 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="TotalLengthAll"> <src:RibbonToolTip.ExpandedContent> <StackPanel> <TextBlock Background="AntiqueWhite" TextAlignment="Left"> <Bold>Function Syntax: Elen</Bold> <LineBreak/> <Hyperlink>http://www.asmitools.com </Hyperlink> <LineBreak/> <Bold><Run Foreground="DodgerBlue">πŸ“ TotalLengthAll</Run></Bold><LineBreak/> <Run Foreground="White">AutoCAD LISP utility for calculating the total length of selected curve-based…

  • TLength

    β€”

    by

    Short description Command: Description: Helper function: (if any)​ Functionalities: Result: Images, animations etc. XAML code: Expand Code ↓ Select Code Copy 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="TLength"> <src:RibbonToolTip.ExpandedContent> <StackPanel> <TextBlock Background="AntiqueWhite" TextAlignment="Left"> <Bold>Function Syntax: TLENGTH</Bold> <LineBreak/> <Bold>Version: 1.0 Date: 20.06.2026 6:38:49PM</Bold> <LineBreak/> <Hyperlink>AI+https://gist.github.com/kevinluo201/51450de14f63382c046c6d840bb42c96</Hyperlink> <LineBreak/> <Bold><Run Foreground="DodgerBlue">πŸ“ Function Syntax: TLENGTH</Run></Bold><LineBreak/> <Bold><Run Foreground="Orange">Command: TLENGTH</Run></Bold><LineBreak/> <LineBreak/> <Run…

  • SumLengthField

    β€”

    by

    Short description Command: Description: Helper function: (if any)​ Functionalities: Result: Images, animations etc. XAML code: Expand Code ↓ Select Code Copy 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="SumLengthField"> <src:RibbonToolTip.ExpandedContent> <StackPanel> <TextBlock Background="AntiqueWhite" TextAlignment="Left"> <Bold>Function Syntax: SumLengthField (Current units) / SumLengthField_1 (Current units with 0.001 conversion factor (mm->m))</Bold> <LineBreak/> <Hyperlink>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/length-field-lisp-by-lee-mac-to-modify-gt-old-length-current/m-p/10578203#M56399</Hyperlink> <LineBreak/> <Bold>Program Overview</Bold><LineBreak/> This program offers…