mozman / ezdxf

Python interface to DXF
https://ezdxf.mozman.at
MIT License
937 stars 191 forks source link

MULTILEADERS are missing when converting R2007 DWG files #1077

Open xbdr419 opened 6 months ago

xbdr419 commented 6 months ago

Hello, after I read a DWG file and save it directly, the dimension elements are lost. Here is the code. I hope to get some optimization. My current version is 1.1.4b2. 感谢。

from ezdxf.addons import odafc
doc = odafc.readfile(r'.\testt\demo.dwg')
odafc.export_dwg(doc, 'demo.dwg', version='R2007', replace=True)

source file: image

save file: image

dwg file:

demo.zip

mozman commented 6 months ago

I don't know exactly the problem but it's related to the MULTILEADER entity in R2007 format.

It works when you first convert the DWG to R2013:

import ezdxf
from ezdxf.addons import odafc

def main():
    odafc.convert('demo.dwg', 'demo_R2013.dxf', version="R2013")
    doc = ezdxf.readfile('demo_R2013.dxf')
    odafc.export_dwg(doc, 'demo_out.dwg')
    # odafc.export_dwg(doc, 'demo_out.dwg', version="R2007")  # if you really need R2007

if __name__ == "__main__":
    main()

image

xbdr419 commented 6 months ago

Thanks, that is indeed the way to go, my initial aim was to preserve the version information of the source file, which is the R2007 .

mozman commented 6 months ago

Simpler version:

import ezdxf
from ezdxf.addons import odafc

def main():
    # due a bug this requires the odafc version format - fixed in next version
    doc = odafc.readfile('demo.dwg', version="ACAD2013")
    odafc.export_dwg(doc, 'demo_out.dwg')
    # odafc.export_dwg(doc, 'demo_out.dwg', version="R2007")  # if you really need R2007

if __name__ == "__main__":
    main()
mozman commented 6 months ago

There is no hope of solving this problem. When I create a new drawing in R2007 DXF format using MLEADER, there are no problems. i.e. This is a specific problem that may take a lot of time to analyze - but I've already spent far too much time on this unnecessary (for me) and extremely (unnecessarily) complex entity. Therefore not a quick solution.

xbdr419 commented 6 months ago

Thank you very much, this has been able to solve my problem.

mozman commented 6 months ago

This is a bug and the issue stays open even I won't fix it.