Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Convert AutoCAD DWG files (1983-2026) to Excel databases using DwgExporter CLI. Extract layers, blocks, attributes, and geometry data without Autodesk licenses.
.claude/skills/datadrivenconstruction-dwg-to-excel/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-01 | ✗→✓ | ▲ Improved | 125% | 0% |
| case-02 | ✗→✓ | ▲ Improved | 133% | 0% |
| case-04 | ✗→✓ | ▲ Improved | 144% | 0% |
| case-07 | ✗→✓ | ▲ Improved | 147% | 0% |
| case-08 | ✗→✓ | ▲ Improved | 79% | 0% |
AutoCAD DWG files contain valuable project data locked in proprietary format:
Extracting this data typically requires AutoCAD licenses or complex programming.
DwgExporter.exe converts DWG files to structured Excel databases offline, without Autodesk licenses.
bashDwgExporter.exe <input_dwg> [options]
| Output | Description | |--------|-------------| | .xlsx | Excel database with all entities | | .pdf | PDF drawings from layouts |
| Version Range | Description | |---------------|-------------| | R12 (1992) | Legacy DWG | | R14 (1997) | AutoCAD 14 | | 2000-2002 | DWG 2000 format | | 2004-2006 | DWG 2004 format | | 2007-2009 | DWG 2007 format | | 2010-2012 | DWG 2010 format | | 2013-2017 | DWG 2013 format | | 2018-2026 | DWG 2018 format |
bash# Basic conversion DwgExporter.exe "C:\Projects\FloorPlan.dwg" # Export with PDF drawings DwgExporter.exe "C:\Projects\FloorPlan.dwg" sheets2pdf # Batch processing all DWG in folder for /R "C:\Projects" %f in (*.dwg) do DwgExporter.exe "%f" # PowerShell batch conversion Get-ChildItem "C:\Projects\*.dwg" -Recurse | ForEach-Object { & "C:\DDC\DwgExporter.exe" $_.FullName }
pythonimport subprocess import pandas as pd from pathlib import Path from typing import List, Optional, Dict, Any from dataclasses import dataclass from enum import Enum class DWGEntityType(Enum): """DWG entity types.""" LINE = "LINE" POLYLINE = "POLYLINE" LWPOLYLINE = "LWPOLYLINE" CIRCLE = "CIRCLE" ARC = "ARC" ELLIPSE = "ELLIPSE" SPLINE = "SPLINE" TEXT = "TEXT" MTEXT = "MTEXT" DIMENSION = "DIMENSION" INSERT = "INSERT" # Block reference HATCH = "HATCH" SOLID = "SOLID" POINT = "POINT" ATTRIB = "ATTRIB" ATTDEF = "ATTDEF" @dataclass class DWGEntity: """Represents a DWG entity.""" handle: str entity_type: str layer: str color: int linetype: str lineweight: float # Geometry (depends on entity type) start_x: Optional[float] = None start_y: Optional[float] = None end_x: Optional[float] = None end_y: Optional[float] = None # Block reference data block_name: Optional[str] = None rotation: Optional[float] = None scale_x: Optional[float] = None scale_y: Optional[float] = None # Text data text_content: Optional[str] = None text_height: Optional[float] = None @dataclass class DWGBlock: """Represents a DWG block definition.""" name: str base_point_x: float base_point_y: float entity_count: int is_dynamic: bool attributes: List[str] @dataclass class DWGLayer: """Represents a DWG layer.""" name: str color: int linetype: str is_on: bool is_frozen: bool is_locked: bool lineweight: float entity_count: int class DWGExporter: """DWG to Excel converter using DDC DwgExporter CLI.""" def __init__(self, exporter_path: str = "DwgExporter.exe"): self.exporter = Path(exporter_path) if not self.exporter.exists(): raise FileNotFoundError(f"DwgExporter not found: {exporter_path}") def convert(self, dwg_file: str, export_pdf: bool = False) -> Path: """Convert DWG file to Excel.""" dwg_path = Path(dwg_file) if not dwg_path.exists(): raise FileNotFoundError(f"DWG file not found: {dwg_file}") cmd = [str(self.exporter), str(dwg_path)] if export_pdf: cmd.append("sheets2pdf") result = subprocess.run(cmd, capture_output=True, text=True) if result.returncode != 0: raise RuntimeError(f"Export failed: {result.stderr}") # Output file is same name with .xlsx extension return dwg_path.with_suffix('.xlsx') def batch_convert(self, folder: str, include_subfolders: bool = True, export_pdf: bool = False) -> List[Dict[str, Any]]: """Convert all DWG files in folder.""" folder_path = Path(folder) pattern = "**/*.dwg" if include_subfolders else "*.dwg" results = [] for dwg_file in folder_path.glob(pattern): try: output = self.convert(str(dwg_file), export_pdf) results.append({ 'input': str(dwg_file), 'output': str(output), 'status': 'success' }) print(f"✓ Converted: {dwg_file.name}") except Exception as e: results.append({ 'input': str(dwg_file), 'output': None, 'status': 'failed', 'error': str(e) }) print(f"✗ Failed: {dwg_file.name} - {e}") return results def read_entities(self, xlsx_file: str) -> pd.DataFrame: """Read converted Excel as DataFrame.""" xlsx_path = Path(xlsx_file) if not xlsx_path.exists(): raise FileNotFoundError(f"Excel file not found: {xlsx_file}") return pd.read_excel(xlsx_file, sheet_name="Elements") def get_layers(self, xlsx_file: str) -> pd.DataFrame: """Get layer summary from converted file.""" df = self.read_entities(xlsx_file) if 'Layer' not in df.columns: raise ValueError("Layer column not found in data") summary = df.groupby('Layer').agg({ 'Handle': 'count' }).reset_index() summary.columns = ['Layer', 'Entity_Count'] return summary.sort_values('Entity_Count', ascending=False) def get_blocks(self, xlsx_file: str) -> pd.DataFrame: """Get block reference summary.""" df = self.read_entities(xlsx_file) # Filter to INSERT entities (block references) blocks = df[df['EntityType'] == 'INSERT'] if blocks.empty: return pd.DataFrame(columns=['Block_Name', 'Count']) summary = blocks.groupby('BlockName').agg({ 'Handle': 'count' }).reset_index() summary.columns = ['Block_Name', 'Count'] return summary.sort_values('Count', ascending=False) def get_text_content(self, xlsx_file: str) -> pd.DataFrame: """Extract all text content from DWG.""" df = self.read_entities(xlsx_file) # Filter to text entities text_types = ['TEXT', 'MTEXT', 'ATTRIB'] texts = df[df['EntityType'].isin(text_types)] if 'TextContent' in texts.columns: return texts[['Handle', 'EntityType', 'Layer', 'TextContent']].copy() return texts[['Handle', 'EntityType', 'Layer']].copy() def get_entity_statistics(self, xlsx_file: str) -> Dict[str, int]: """Get entity type statistics.""" df = self.read_entities(xlsx_file) if 'EntityType' not in df.columns: return {} return df['EntityType'].value_counts().to_dict() def extract_block_attributes(self, xlsx_file: str, block_name: str) -> pd.DataFrame: """Extract attributes from specific block type.""" df = self.read_entities(xlsx_file) # Find block references blocks = df[(df['EntityType'] == 'INSERT') & (df['BlockName'] == block_name)] # Find associated attributes # Attributes typically follow their parent INSERT in handle order result_data = [] for _, block in blocks.iterrows(): block_handle = block['Handle'] block_data = { 'Block_Handle': block_handle, 'X': block.get('InsertX', 0), 'Y': block.get('InsertY', 0), 'Rotation': block.get('Rotation', 0) } # Add any attribute columns for col in df.columns: if col.startswith('Attr_'): block_data[col] = block.get(col) result_data.append(block_data) return pd.DataFrame(result_data) class DWGAnalyzer: """Advanced DWG analysis tools.""" def __init__(self, exporter: DWGExporter): self.exporter = exporter def analyze_drawing_structure(self, dwg_file: str) -> Dict[str, Any]: """Analyze complete drawing structure.""" xlsx = self.exporter.convert(dwg_file) df = self.exporter.read_entities(str(xlsx)) analysis = { 'file': dwg_file, 'total_entities': len(df), 'layers': self.exporter.get_layers(str(xlsx)).to_dict('records'), 'entity_types': self.exporter.get_entity_statistics(str(xlsx)), 'blocks': self.exporter.get_blocks(str(xlsx)).to_dict('records') } # Calculate extents if coordinates available if 'X' in df.columns and 'Y' in df.columns: analysis['extents'] = { 'min_x': df['X'].min(), 'max_x': df['X'].max(), 'min_y': df['Y'].min(), 'max_y': df['Y'].max() } return analysis def compare_drawings(self, dwg1: str, dwg2: str) -> Dict[str, Any]: """Compare two DWG files.""" xlsx1 = self.exporter.convert(dwg1) xlsx2 = self.exporter.convert(dwg2) df1 = self.exporter.read_entities(str(xlsx1)) df2 = self.exporter.read_entities(str(xlsx2)) layers1 = set(df1['Layer'].unique()) if 'Layer' in df1.columns else set() layers2 = set(df2['Layer'].unique()) if 'Layer' in df2.columns else set() return { 'file1': dwg1, 'file2': dwg2, 'entity_count_diff': len(df2) - len(df1), 'layers_added': list(layers2 - layers1), 'layers_removed': list(layers1 - layers2), 'common_layers': list(layers1 & layers2) } def find_duplicates(self, xlsx_file: str, tolerance: float = 0.001) -> pd.DataFrame: """Find duplicate entities at same location.""" df = self.exporter.read_entities(xlsx_file) if 'X' not in df.columns or 'Y' not in df.columns: return pd.DataFrame() # Round coordinates for grouping df['X_rounded'] = (df['X'] / tolerance).round() * tolerance df['Y_rounded'] = (df['Y'] / tolerance).round() * tolerance # Find duplicates duplicates = df[df.duplicated( subset=['EntityType', 'Layer', 'X_rounded', 'Y_rounded'], keep=False )] return duplicates.sort_values(['X_rounded', 'Y_rounded']) # Convenience functions def convert_dwg_to_excel(dwg_file: str, exporter_path: str = "DwgExporter.exe") -> str: """Quick conversion of DWG to Excel.""" exporter = DWGExporter(exporter_path) output = exporter.convert(dwg_file) return str(output) def batch_convert_dwg(folder: str, exporter_path: str = "DwgExporter.exe", include_subfolders: bool = True) -> List[str]: """Batch convert all DWG files in folder.""" exporter = DWGExporter(exporter_path) results = exporter.batch_convert(folder, include_subfolders) return [r['output'] for r in results if r['status'] == 'success']
| Sheet | Content | |-------|---------| | Elements | All DWG entities with properties | | Layers | Layer definitions | | Blocks | Block definitions | | Layouts | Drawing layouts/sheets |
| Column | Type | Description | |--------|------|-------------| | Handle | string | Unique entity handle | | EntityType | string | LINE, CIRCLE, INSERT, etc. | | Layer | string | Layer name | | Color | int | Color index (0-256) | | Linetype | string | Linetype name | | Lineweight | float | Line weight in mm | | X, Y, Z | float | Entity coordinates | | BlockName | string | For INSERT entities | | TextContent | string | For TEXT/MTEXT |
python# Initialize exporter exporter = DWGExporter("C:/DDC/DwgExporter.exe") # Convert single file xlsx = exporter.convert("C:/Projects/Plan.dwg") print(f"Output: {xlsx}") # Read and analyze df = exporter.read_entities(str(xlsx)) print(f"Total entities: {len(df)}") # Get layer statistics layers = exporter.get_layers(str(xlsx)) print(layers) # Get block usage blocks = exporter.get_blocks(str(xlsx)) print(blocks) # Extract text annotations texts = exporter.get_text_content(str(xlsx)) for _, row in texts.iterrows(): print(f"{row['Layer']}: {row.get('TextContent', 'N/A')}")
pythonexporter = DWGExporter() xlsx = exporter.convert("drawing.dwg") layers = exporter.get_layers(str(xlsx)) # Check for non-standard layers standard_layers = ['0', 'WALLS', 'DOORS', 'WINDOWS', 'DIMENSIONS'] non_standard = layers[~layers['Layer'].isin(standard_layers)] print("Non-standard layers:", non_standard['Layer'].tolist())
python# Extract all door blocks with attributes doors = exporter.extract_block_attributes(str(xlsx), "DOOR") print(doors[['Block_Handle', 'Attr_DOOR_TYPE', 'Attr_DOOR_SIZE']])
pythonanalyzer = DWGAnalyzer(exporter) diff = analyzer.compare_drawings("rev1.dwg", "rev2.dwg") print(f"Entities added: {diff['entity_count_diff']}") print(f"New layers: {diff['layers_added']}")
python# Full pipeline: DWG → Excel → Analysis → Report from dwg_exporter import DWGExporter, DWGAnalyzer # 1. Convert DWG exporter = DWGExporter("C:/DDC/DwgExporter.exe") xlsx = exporter.convert("project.dwg") # 2. Analyze structure analyzer = DWGAnalyzer(exporter) analysis = analyzer.analyze_drawing_structure("project.dwg") # 3. Generate report print(f"Drawing: {analysis['file']}") print(f"Entities: {analysis['total_entities']}") print(f"Layers: {len(analysis['layers'])}") print(f"Blocks: {len(analysis['blocks'])}")
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-03 | fail→fail | 17,607 | 18,611 | +6% | 1 | 1 | 0% | 3,253 | 8,151 | +151% | 0 | 0 | — |
case-01 | fail→pass | 13,083 | 6,681 | -49% | 1 | 1 | 0% | 2,466 | 5,553 | +125% | 0 | 0 | — |
case-02 | fail→pass | 13,788 | 7,840 | -43% | 1 | 1 | 0% | 2,520 | 5,866 | +133% | 0 | 0 | — |
case-04 | fail→pass | 13,349 | 10,734 | -20% | 1 | 1 | 0% | 2,601 | 6,336 | +144% | 0 | 0 | — |
case-05 | fail→fail | 13,444 | 16,106 | +20% | 1 | 1 | 0% | 2,157 | 7,107 | +229% | 0 | 0 | — |
case-06 | fail→fail | 16,487 | 14,476 | -12% | 1 | 1 | 0% | 3,041 | 6,984 | +130% | 0 | 0 | — |
case-07 | fail→pass | 12,078 | 3,222 | -73% | 1 | 1 | 0% | 1,977 | 4,878 | +147% | 0 | 0 | — |
case-08 | fail→pass | 17,651 | 12,409 | -30% | 1 | 1 | 0% | 2,796 | 5,018 | +79% | 0 | 0 | — |
case-09 | fail→pass | 9,656 | 2,834 | -71% | 1 | 1 | 0% | 1,511 | 4,837 | +220% | 0 | 0 | — |
case-10 | fail→pass | 13,291 | 11,089 | -17% | 1 | 1 | 0% | 2,454 | 6,492 | +165% | 0 | 0 | — |
case-11 | fail→pass | 10,682 | 7,045 | -34% | 1 | 1 | 0% | 1,883 | 5,751 | +205% | 0 | 0 | — |
case-12 | pass→pass | 8,225 | 6,822 | -17% | 1 | 1 | 0% | 1,586 | 5,764 | +263% | 0 | 0 | — |
case-13 | fail→fail | 17,626 | 15,355 | -13% | 1 | 1 | 0% | 3,567 | 7,365 | +106% | 0 | 0 | — |
case-14 | pass→pass | 11,587 | 4,697 | -59% | 1 | 1 | 0% | 1,726 | 5,233 | +203% | 0 | 0 | — |
case-15 | pass→pass | 10,973 | 6,299 | -43% | 1 | 1 | 0% | 2,183 | 5,516 | +153% | 0 | 0 | — |
case-16 | pass→pass | 6,331 | 5,192 | -18% | 1 | 1 | 0% | 1,120 | 5,322 | +375% | 0 | 0 | — |
case-17 | pass→pass | 6,131 | 5,170 | -16% | 1 | 1 | 0% | 1,162 | 5,259 | +353% | 0 | 0 | — |
case-18 | fail→pass | 5,009 | 5,375 | +7% | 1 | 1 | 0% | 917 | 5,395 | +488% | 0 | 0 | — |
case-19 | pass→pass | 11,445 | 6,472 | -43% | 1 | 1 | 0% | 2,318 | 5,576 | +141% | 0 | 0 | — |
case-20 | pass→pass | 6,129 | 1,546 | -75% | 1 | 1 | 0% | 853 | 4,624 | +442% | 0 | 0 | — |
case-21 | pass→pass | 9,357 | 7,426 | -21% | 1 | 1 | 0% | 1,874 | 5,788 | +209% | 0 | 0 | — |
case-22 | fail→pass | 17,566 | 8,402 | -52% | 1 | 1 | 0% | 3,414 | 6,128 | +79% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted. The headline lift of +45 percentage points is the difference between those two pass rates over the 22 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.