0

I want to move, rotate the component of the blocks in dxf file using python. What I am thinking now is re-drawing the components, but I doubt that I cannot draw some arbitrary curves by that method. So, I want to find the way to copy and move the whole blocks in dxf file.

import ezdxf as ezd
import numpy as np

def dxf_load_edge(dxfname):
    dxfload = ezd.readfile(dxfname)
    dxfms = dxfload.modelspace()
    blockref = dxfms.query('LWPOLYLINE')
    print(blockref)
    points=[]
    move_x = 50
    move_y = 70
    dxf_new = ezd.new()

Please anybody tell me what to code next, or functions that I should use and thank you very much.

EJ Song
  • 123
  • 2
  • 13

1 Answers1

0

This question is very similar to the following question here in StackOverflow:

Python and ezdxf copying blocks

Basically, I understand from the documentation that you cannot copy or move block references in a layout. The way around it is to first import your block definitions using the Importer function from a source modelspace into a modelspace of a target drawing. Then you can add block references (based on the block defitions you imported) into specific locations in a modelspace or paperspace using the add_blockref function. You can call as many block references as you want through this method.

There are sample codes in the tutorial and previous question in the links provided.