Function Syntax: CopyC3DEntitiesToClipboard AI Description This AutoLISP routine extracts visible text from selected Civil 3D labels or AutoCAD entities by duplicating the selection, exploding the duplicated objects, collecting generated TEXT and MTEXT content, copying the cleaned text to the Windows clipboard, and deleting the temporary exploded entities afterward. The original selected Civil 3D labels or AutoCAD objects are intended to remain unchanged because the routine works on copied objects instead of directly exploding the originals. The main command is CopyC3DEntitiesToClipboard. The routine is useful when Civil 3D labels need to be converted temporarily into plain text so their displayed values can be copied into Excel, Notepad, Word, emails, QA notes, reports, or project documentation. The code works as a command-line utility and does not use a DCL dialog. Main Command โ€ข ๐Ÿ“Œ CopyC3DEntitiesToClipboard โ€” starts the duplicate, explode, text extraction, clipboard copy, and cleanup workflow. Loading Method โ€ข ๐Ÿงฐ Load LISP File โ€” load the file CopyC3DEntitiesToClipboard.lsp in AutoCAD or Civil 3D using APPLOAD. โ€ข ๐Ÿ“Œ Run Command โ€” run CopyC3DEntitiesToClipboard from the AutoCAD or Civil 3D command line. User Workflow โ€ข ๐Ÿš€ Start Command โ€” the user runs CopyC3DEntitiesToClipboard. โ€ข ๐Ÿ“Œ Select Objects โ€” the command prompts the user to select Civil 3D labels or other entities that may produce text after exploding. โ€ข ๐Ÿง  Use Pickfirst When Available โ€” the routine first checks the implied selection using ssget "_I" and then falls back to a normal ssget selection if needed. โ€ข ๐Ÿ“‹ Copy Objects In Place โ€” each selected object is duplicated in the same position before any explode operation is performed. โ€ข ๐Ÿ’ฅ Explode Temporary Copy โ€” the duplicated object is exploded with EXPLODE so generated AutoCAD entities can be inspected. โ€ข ๐Ÿงฉ Explode Nested Blocks โ€” if the exploded result includes block references, the routine attempts to explode those nested INSERT entities too. โ€ข ๐Ÿ“ Collect Text โ€” the routine searches the exploded entities for TEXT and MTEXT objects. โ€ข ๐Ÿงน Clean MText Codes โ€” text is cleaned with StripMTextCodes_2 if that helper exists, otherwise a basic fallback cleanup is used. โ€ข ๐Ÿ“‹ Copy To Clipboard โ€” the extracted text is copied to the Windows clipboard using htmlfile, MSForms.DataObject, or clip.exe as fallback methods. โ€ข ๐Ÿงน Delete Temporary Geometry โ€” the routine builds a selection set of the exploded temporary entities, uses PSELECT with Previous, then uses ERASE to remove the temporary exploded objects. โ€ข โœ… Report Result โ€” the command line reports how many text items were copied to the clipboard. Functionalities โ€ข ๐Ÿ“Œ Pickfirst Selection Support โ€” the routine can use objects already selected before the command starts through ssget "_I". โ€ข ๐Ÿ“Œ Manual Selection Support โ€” if no pickfirst selection exists, the routine asks the user to select objects normally with ssget. โ€ข ๐Ÿ“‹ Duplicate Before Explode โ€” the routine copies each selected entity in place so the original object is not intentionally exploded or modified. โ€ข ๐Ÿ”„ COM Copy Fallback โ€” the routine first tries vla-copy, then falls back to the AutoCAD COPY command from 0,0,0 to 0,0,0 if COM copy fails. โ€ข ๐Ÿ’ฅ Temporary Explode Workflow โ€” the duplicated entity is exploded with EXPLODE so Civil 3D label graphics can become readable AutoCAD text objects. โ€ข ๐Ÿงฉ Nested Block Explosion โ€” exploded INSERT entities are processed again so text inside nested blocks can also be collected. โ€ข ๐Ÿ“ TEXT Extraction โ€” the routine reads the DXF group 1 value from TEXT objects. โ€ข ๐Ÿ“ MTEXT Extraction โ€” the routine combines MTEXT DXF groups 1 and 3 to capture long MTEXT content. โ€ข ๐Ÿงน MText Formatting Cleanup โ€” the routine removes or replaces common MTEXT control codes such as paragraph codes, underline codes, overline codes, and braces. โ€ข ๐Ÿ“‹ Clipboard Export โ€” all extracted text is combined into a plain-text list and copied to the Windows clipboard. โ€ข ๐Ÿ” Multiple Clipboard Methods โ€” the code tries htmlfile first, then MSForms.DataObject, then a temporary file piped through clip.exe. โ€ข ๐Ÿงน Temporary Object Cleanup โ€” exploded temporary entities are erased after the text has been copied. โ€ข โ†ฉ๏ธ Undo Grouping โ€” the workflow is wrapped inside UNDO BEGIN and UNDO END so the operation can be treated as one undo group in AutoCAD. โ€ข ๐Ÿ”‡ Command Echo Control โ€” the routine sets CMDECHO to 0 during processing and restores the previous value afterward. โ€ข โšก No Dialog Workflow โ€” the command runs directly from the command line without a DCL interface, making it fast for repeated label-to-clipboard extraction tasks. Important Helper Logic โ€ข ๐Ÿ”’ Error Handler โ€” *error* restores CMDECHO and suppresses normal cancel, break, and exit messages. โ€ข ๐Ÿง  Pickset Validator โ€” _is-pickset checks whether a returned value is a valid AutoCAD selection set. โ€ข ๐Ÿ“Œ Selection Helper โ€” _get-pickset retrieves the implied selection first and then asks the user to select objects if needed. โ€ข ๐Ÿ“‹ Copy Helper โ€” _copy-in-place duplicates an entity using vla-copy or the AutoCAD COPY command as fallback. โ€ข ๐Ÿ’ฅ Explode Collector โ€” _explode-collect runs EXPLODE, collects all newly created entities, and attempts to explode nested block references. โ€ข ๐Ÿงน Text Cleaner โ€” _clean-text uses StripMTextCodes_2 when available and otherwise performs a basic MTEXT formatting cleanup. โ€ข ๐Ÿ“ Text Reader โ€” _text-from-entity reads plain text from TEXT and MTEXT entities. โ€ข ๐Ÿ“‹ Clipboard Helper โ€” _clipboard-put tries three Windows clipboard routes: htmlfile, MSForms.DataObject, and clip.exe. โ€ข ๐Ÿงน Deletion Selection Builder โ€” the routine collects temporary exploded entities into ssDel and then erases them using PSELECT and ERASE. Important Code Notes โ€ข ๐Ÿ“Œ Command Name โ€” the command name is CopyC3DEntitiesToClipboard. โ€ข ๐Ÿ”ด Platform Requirement โ€” the clipboard workflow is Windows-specific because it uses COM objects and clip.exe. โ€ข ๐Ÿ”ด Selection Filter Note โ€” the routine prompts for Civil 3D labels, but the code uses ssget without a Civil 3D label filter, so any selectable object can be chosen. โ€ข ๐Ÿ”ด Explode Dependency โ€” text is collected only if the duplicated object explodes into TEXT or MTEXT entities. โ€ข ๐Ÿ”ด Text Cleanup Dependency โ€” advanced MTEXT cleanup depends on StripMTextCodes_2 if that helper function is loaded. Otherwise the routine uses only a basic fallback cleanup. โ€ข ๐Ÿ”ด Non Explodable Object Note โ€” if a copied object cannot be exploded, the copied temporary object may not produce text and should be checked in the drawing after testing. โ€ข ๐Ÿ”ด Undo Handler Note โ€” the routine starts an AutoCAD undo group, but the error handler does not explicitly close the undo group if an unexpected error occurs after UNDO BEGIN. โ€ข ๐Ÿ”ด Clipboard Limitation โ€” the routine copies plain text only. It does not create a CSV file, Excel file, table, report, label, band, ProfileView, SectionView, Alignment, or export database. โ€ข ๐Ÿ”ด Civil 3D Object Limitation โ€” the routine does not modify Civil 3D objects. It only duplicates, explodes temporary copies, extracts text, copies text to the clipboard, and removes the temporary exploded entities. Final Result The final result is a fast Civil 3D label and AutoCAD text extraction workflow. The user can select labels or objects, let the routine duplicate and explode temporary copies, collect generated TEXT and MTEXT values, copy the cleaned result to the Windows clipboard, and automatically remove the temporary exploded geometry. This improves productivity, reduces manual label copying, speeds up QA documentation, supports fast transfer to Excel or reports, and helps Civil 3D users extract visible label information without permanently exploding the original design objects.