Function Syntax: GetLabelText Version: 1.0 Date: 04.06.2026 18:04:07 Version: 1.1 Date: 02.07.2026 6:24:06AM https://forums.autodesk.com/t5/civil-3d-customization-forum/civil3d-api-c-extract-label-text/td-p/6988920 AutoCAD Civil 3D Label Extractor Plugin Description Main command: GETLABELTEXT General action of the program This program opens a modeless Civil 3D Label Extractor window that allows the user to pick Civil 3D labels, profile views, section views, and related annotation objects directly from the drawing, extract their visible text, classify the extracted information, filter it, export it, and use it to update MLeader station text. Important workflow: The command GETLABELTEXT opens the window first with an empty table. The user then clicks Pick Labels inside the dialog to select objects from AutoCAD Civil 3D. Code type: This is a compiled AutoCAD Civil 3D .NET plugin written in C# targeting .NET Framework 4.8 and x64 AutoCAD Civil 3D. Main window structureExtract and Filter tab: Extracts label text, displays rows in a grid, applies filters, copies text, formats station text, updates MLeader text, and exports data.Band Manager tab: Loads profile view and section view band rows, lets the user change band styles and data sources, then writes those changes back to the drawing.Style Auditor tab: Audits band styles in the Civil 3D drawing, shows which styles are used or unused, and supports replacing one style across all profile views and section views. Command behavior When the user runs GETLABELTEXT, the plugin creates a new MainForm with an empty extraction list and displays it as a modeless AutoCAD dialog. Because the dialog is modeless, AutoCAD remains interactive while the window is open. The user does not need to select labels before launching the command. Selection happens later from the Pick Labels button. Pick Labels functionality • Prompts the user to select Civil 3D labels, profile views, section views, or other supported annotation objects in the drawing. • Extracts visible text from selected objects and appends the result to the existing table. • Allows repeated picking without closing and reopening the dialog. • Uses a document lock while reading drawing objects to keep AutoCAD database access safe. • For small selections, extraction runs directly in the UI workflow. • For selections of 25 or more objects, the plugin displays a cancellable progress dialog. • If no text is found, the program shows an information message instead of modifying the table. • After extraction, active text and style filters are cleared so newly added rows are immediately visible. Extracted data shown in the grid • Extracted Text. • Formatted Text. • Station, when the station column is enabled. • Color name. • Band style name. • Label style name. • Band label styles. • Data source 1. • Data source 2. • Feature type. • Alignment name. • View name. • Checked status for export selection. Supported Civil 3D extraction logic • Reads ProfileView objects and extracts profile view band text, graph text, alignment name, view name, style name, data sources, and band label information. • Reads SectionView objects and extracts section view band text, graph text, sample line station, alignment name, view name, data source, and band style information. • Reads general AutoCAD and Civil 3D entities by exploding them and collecting DBText and MText content. • Cleans MText formatting codes before storing the text in the grid. • Detects feature type based on the selected object class, such as Alignment, Profile View, Section View, Section, Corridor, Feature Line, CoGo Point, Pipe, Structure, Parcel, Surface, Label, or Annotation. • Reads style names and label style names using direct API access and reflection fallback where needed. Band extraction aspect: The code uses Civil 3D typed API access for band items, including bottom bands, top bands, band style IDs, profile sources, section sources, and band label style data. Filtering functionality • Filter by alignment. • Filter by feature type. • Filter by band style. • Filter by label style. • Filter by data source. • Search inside extracted text. • Search inside style fields using wildcard patterns. • Group rows by color, band style, label style, feature type, or alignment and view. • Save filter preferences in the Windows registry and restore them when the tool opens again. Duplicate detection • The program checks whether the same extracted text appears under different band styles. • Duplicate text with different styles is highlighted in orange. • This helps the user detect copy-paste inconsistencies or wrong band style assignments in Civil 3D annotation data. Station formatting functionality • Converts raw station text such as km112+69.381 into km 11,2+69.381. • Only converts strings that start with the literal km prefix and contain a valid station pattern. • Leaves unrelated text unchanged, such as coordinate strings or object names. • Adds the converted value to the Formatted Text column. • Provides a Copy Fmt. button to copy formatted text from selected rows. MLeader update functionality • The user selects a row in the grid. • The user clicks Update MLeader. • The user picks an MLeader in the drawing. • The plugin replaces the first matching km station value inside the MLeader text with the selected row's formatted station text. • If no station pattern is found inside the MLeader, the plugin asks whether the entire MLeader text should be replaced. • The Reuse target option allows the same MLeader to be updated repeatedly with different selected rows. Export and copy functionality • Copy selected rows to the clipboard. • Double-click any grid cell to copy that cell text. • Use Ctrl+C to copy selected row text. • Use Ctrl+A to select all visible rows. • Export visible rows to a UTF-8 CSV file. • Export visible rows to an XLSX file. • The XLSX export includes a Label Data sheet and a Summary sheet. • The summary sheet counts band styles and label styles. Band Manager functionality • Allows switching between Profile Views and Section Views. • Lists available views from the active Civil 3D drawing. • Loads bottom and top band rows for the selected view. • Displays band location, band style name, source 1, and source 2. • Lets the user choose a different band style from a drop-down list. • Lets the user change profile or section data sources where available. • Applies selected changes back to the Civil 3D profile view or section view in one transaction. • Uses Civil 3D methods such as GetBottomBandItems, GetTopBandItems, SetBottomBandItems, and SetTopBandItems. Style Auditor functionality • Reads the Civil 3D band style library from the active drawing. • Compares available band styles against the styles found in the extracted table. • Shows used styles in green. • Shows unused styles in red. • Displays style name, style type, and use count. • Supports replacing a selected style with another style across all profile views and section views in the drawing. • Performs the batch style replacement in a single Civil 3D transaction. Safety and usability features • Uses AutoCAD document locking when reading or modifying the drawing database. • Uses transactions for safe database operations. • Handles Civil 3D API differences with reflection fallback for properties that may not exist in every Civil 3D version. • Shows user-friendly error and information messages for failed selection, failed extraction, empty results, and MLeader update problems. • Stores UI filter preferences under the Windows registry key used by the plugin. • Includes a build tag shown in the status bar so the user can confirm which DLL build is loaded. • Keeps preview panel code in the source, but the preview panel is currently disabled by the SHOW_PREVIEW_PANEL constant. Build and loading note: The project builds a DLL named GetLabelText.dll. AutoCAD loads the plugin with NETLOAD, then the user runs GETLABELTEXT. Configuration note: The project imports AutoCAD and Civil 3D references from a local shared props file path. That path must exist on the build computer or be updated before building. Final result The plugin gives the user a structured Civil 3D label extraction and management tool. It helps collect label text from profile views, section views, and annotations, review the data in a filterable grid, detect inconsistent duplicate text, format station values, export results to CSV or XLSX, update MLeader station text, manage band styles, and audit unused or used Civil 3D band styles directly inside AutoCAD Civil 3D.