Hey guys,
I'm currently trying to achieve the following: We have a set of DXF files, which we need to load, merge, reposition and rotate and then save as one file.
Loading the individual DXF files works quite well with the documented Importer Plugin. However, I can't figure out how to reposition or rotate an imported file.
Accessing the model space of an imported dxf file only returns a single INSERT element, so I don't seem to get access to the lines and other entities directly.
As far as I understand there are two possible solutions:
1. Use dxfattribs to reposition and rotation
2. Change the Vector of the INSERT Element directly
I didn't have any luck with both solutions. Can someone point me to the right direction?
This is the code I currently have:
import ezdxf
from ezdxf.addons import Importer
targetDoc = ezdxf.new()
sourceDoc = ezdxf.readfile("dxf/file1.dxf")
importer = Importer(sourceDoc, targetDoc)
importer.import_modelspace()
importer.import_paperspace_layouts()
msp = sourceDoc.modelspace()
targetBlock = targetDoc.blocks.new('TEST1')
importer.import_entities(msp, targetBlock)
importer.finalize()
sourceDoc2 = ezdxf.readfile("dxf/file2.dxf")
importer2 = Importer(sourceDoc2, targetDoc)
importer2.import_modelspace()
importer2.import_paperspace_layouts()
msp2 = sourceDoc2.modelspace()
targetBlock2 = targetDoc.blocks.new('TEST2')
importer2.import_entities(msp2, targetBlock2)
importer2.finalize()
targetDoc.saveas('test.dxf')