Merge dxf files from multiple pages into one page

83 Views Asked by At

I tried to merge multiple dxf files into one dxf file.

I've used Importer of ezdxf (Python package) but the result was that dxf files were accumulated in layers on one page.

def merge(source, target):
    try:
        source = ezdxf.readfile(source)

    except ezdxf.DXFError as e:
        print("DXF file not found")
        return False

    try:
        importer = Importer(source, target)
        importer.import_modelspace()
        importer.finalize()

    except Exception as e:
        print("Error: ", e.__class__)

This is the input dxf files: enter image description here

enter image description here

This is the current output dxf file: enter image description here

The result I want is continuous dxf files on one page like following: enter image description here

How can I achieve this?

1

There are 1 best solutions below

0
skaihugger On BEST ANSWER

Thanks for the KJ's comment. This worked for me and I just need to adjust the translation amount in the y-axis.

transform.inplace(sdoc.modelspace(), Matrix44.translate(0, index * 0, 0))

Please check this official ezdxf doc about combining multiple dxf files. https://ezdxf.readthedocs.io/en/stable/tutorials/xref_module.html#load-modelspace