Export Mixin¶
Extracts entity data from the active drawing and exports to Excel (XLSX) or JSON.
The exported Excel file contains three sheets: Entities, Layers, and Blocks.
adapters.mixins.export_mixin.ExportMixin
¶
Mixin for data extraction and export operations.
get_entity_counts
¶
Get instant counts of main entity types using SelectionSets (O(K)).
| RETURNS | DESCRIPTION |
|---|---|
Dict[str, int]
|
Dictionary with counts mapping internal name to count: |
Dict[str, int]
|
{ "Line": 120, "Polyline": 40, "LWPolyline": 15, "Circle":... } |
extract_drawing_data
¶
extract_drawing_data(
only_selected: bool = False,
limit: int = 500,
offset: int = 0,
entity_type: Optional[str] = None,
) -> list[dict]
Extract drawing data (entities) with their properties.
Optimized iteration through ModelSpace or selected entities with reduced COM calls. Uses property caching and batch processing for improved performance.
| PARAMETER | DESCRIPTION |
|---|---|
only_selected
|
If True, extract only selected entities. If False, extract all. Defaults to False for backward compatibility.
TYPE:
|
limit
|
Maximum number of entities to return per page. Defaults to 500.
TYPE:
|
offset
|
Number of entities to skip before extracting. Defaults to 0.
TYPE:
|
entity_type
|
Optional DXF type name to filter by (e.g., 'LINE', 'LWPOLYLINE').
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[dict]
|
List of dictionaries with columns: |
list[dict]
|
|
list[dict]
|
|
list[dict]
|
|
list[dict]
|
|
list[dict]
|
|
list[dict]
|
|
list[dict]
|
|
list[dict]
|
|
list[dict]
|
|
export_to_excel
¶
Export drawing data to Excel file.
Uses the configured output directory from config.json for security, similar to save_drawing(). If only filename provided, saves to output directory.
| PARAMETER | DESCRIPTION |
|---|---|
filepath
|
Path to output Excel file (default: "drawing_data.xlsx") - If filename only, saved to config output directory - If path provided, must be within output directory
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if successful, False otherwise |