1

I have a dxf file blocks.dxf containing multiple block entities. I have another dxf file in.dxf into which I need to import the block entities of the previous dxf file blocks.dxf.

How do I copy the block entities from one file to another using ezdxf Python module so that the copied blocks can be inserted anywhere in the in.dxf file?

Masoud Rahimi
  • 5,785
  • 15
  • 39
  • 67

1 Answers1

0

For people still looking for an answer on how to copy block definitions:

    #generate list of blocks to import
    list_of_blocks = df_uni_temp[mask].RefNo2.tolist()

    doc_blocks = ezdxf.readfile('blocks.dxf')
    doc = ezdxf.readfile('in.dxf')
    importer = Importer(doc_blocks, doc)
    #iterate through list of blocks
    for b in list_of_blocks :
        print(b)
        importer.import_block(b)
    importer.finalize()