import ezdxf
from pathlib import Path


def inspect_blocks(dxf_path):
    doc = ezdxf.readfile(dxf_path)
    print(f"Datei: {dxf_path}")
    print("Gefundene Blöcke und Attribute:\n")
    for block in doc.blocks:
        if block.name.startswith('*'):  # Überspringe anonyme/Standardblöcke
            continue
        print(f"Block: {block.name}")
        attribs = [e for e in block if e.dxftype() == "ATTDEF"]
        if attribs:
            print("  Attribute:")
            for att in attribs:
                print(f"    Tag: {att.dxf.tag}, Prompt: {att.dxf.prompt}")
        else:
            print("  (Keine Attribute)")
        print("-" * 40)


if __name__ == "__main__":
    dxf_file = "data/blocks.dxf"
    inspect_blocks(dxf_file) 