| """Investigate what entities are in these DXF files.""" |
|
|
| import ezdxf |
| import tempfile |
| import os |
|
|
| files = [ |
| "/Volumes/WorkSpace/Project/REMB/examples/663409.dxf", |
| "/Volumes/WorkSpace/Project/REMB/examples/930300.dxf" |
| ] |
|
|
| for dxf_path in files: |
| print("=" * 70) |
| print(f"Analyzing: {dxf_path.split('/')[-1]}") |
| print("=" * 70) |
| |
| try: |
| doc = ezdxf.readfile(dxf_path) |
| msp = doc.modelspace() |
| |
| |
| entity_types = {} |
| total = 0 |
| |
| for entity in msp: |
| etype = entity.dxftype() |
| entity_types[etype] = entity_types.get(etype, 0) + 1 |
| total += 1 |
| |
| print(f"Total entities: {total}") |
| print(f"\nEntity breakdown:") |
| for etype, count in sorted(entity_types.items(), key=lambda x: -x[1]): |
| print(f" {etype}: {count}") |
| |
| |
| print(f"\nGeometry analysis:") |
| |
| |
| points = list(msp.query('POINT')) |
| if points: |
| print(f" Found {len(points)} POINT entities") |
| print(f" Sample: {points[0].dxf.location if points else 'N/A'}") |
| |
| |
| circles = list(msp.query('CIRCLE')) |
| if circles: |
| print(f" Found {len(circles)} CIRCLE entities") |
| if circles: |
| c = circles[0] |
| print(f" Sample: center={c.dxf.center}, radius={c.dxf.radius}") |
| |
| |
| arcs = list(msp.query('ARC')) |
| if arcs: |
| print(f" Found {len(arcs)} ARC entities") |
| |
| |
| splines = list(msp.query('SPLINE')) |
| if splines: |
| print(f" Found {len(splines)} SPLINE entities") |
| |
| |
| texts = list(msp.query('TEXT')) |
| if texts: |
| print(f" Found {len(texts)} TEXT entities") |
| if texts: |
| print(f" Sample text: '{texts[0].dxf.text}'") |
| |
| except Exception as e: |
| print(f"Error: {e}") |
| import traceback |
| traceback.print_exc() |
| |
| print() |
|
|