mozman / ezdxf

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

File path replacement error #1114

Closed DELAGREEN closed 5 months ago

DELAGREEN commented 5 months ago
Traceback (most recent call last):
  File "/home/nzxt/rep/dwg_to_text/test.py", line 13, in <module>
    frontend = Frontend(RenderContext(doc), backend)
  File "/home/nzxt/rep/dwg_to_text/venv/lib/python3.10/site-packages/ezdxf/addons/drawing/properties.py", line 360, in __init__
    doc.filename.replace("\\", os.path.sep)
TypeError: Path.replace() takes 2 positional arguments but 3 were given
  1. Python script
    
    from ezdxf.addons.drawing import Frontend, RenderContext
    from ezdxf.addons.drawing import layout, pymupdf

Конвертируем DWG в DXF

doc = odafc.readfile('input.dwg')

Создаем контекст рендеринга

msp = doc.modelspace() backend = pymupdf.PyMuPdfBackend()

Создаем frontend и рендерим DXF в PDF

frontend = Frontend(RenderContext(doc), backend) frontend.draw_layout(msp)

Записываем PDF в файл

with open("output.pdf", "wb") as fp: fp.write(backend.get_pdf_bytes(layout.Page(0, 0)))



2. ezdxf v1.3.0 and the Ubuntu 22.04.4 LTS.

I solved the problem simply by commenting out the code in the library.
![image](https://github.com/mozman/ezdxf/assets/60788008/dc2ad307-9957-4cee-8d08-99291d95dd6a)