added more info and how-to about ODA

This commit is contained in:
listyantidewi1
2026-04-19 11:00:05 +07:00
parent a07b480a71
commit e93f542fc3
4 changed files with 102 additions and 4 deletions
+32
View File
@@ -150,6 +150,38 @@ If you only need the core tools, install the minimal set:
pip install Flask Pillow PyMuPDF "qrcode[pil]" markdown reportlab img2pdf python-docx
```
### Enabling DWG support (ODA File Converter)
DXF files work out of the box once you install `ezdxf` and `matplotlib`. For **DWG** files, the app shells out to the free **ODA File Converter** (by Open Design Alliance) to convert DWG → DXF, then renders the DXF. There is no reliable pure-Python library that reads DWG, so this extra step is necessary.
1. **Download** the installer for your OS from [opendesign.com](https://www.opendesign.com/guestfiles/oda_file_converter). It's a free guest download — no account required.
2. **Run the installer.** Defaults are fine.
3. **Add it to your PATH** so the Flask app can find it. The app looks for a binary named `ODAFileConverter` or `oda_file_converter` using `shutil.which()`.
- **Windows** — add the install folder (contains `ODAFileConverter.exe`) to your `Path`:
- Press `Win + R``sysdm.cpl`*Advanced* tab → *Environment Variables*
- Under *System variables*, select `Path`*Edit**New* → paste the folder, e.g.:
```
C:\Program Files\ODA\ODAFileConverter 26.4.0
```
- Click OK, open a **new** terminal, run `where ODAFileConverter` to verify.
- **macOS** — symlink the binary into `/usr/local/bin`:
```bash
sudo ln -s /Applications/ODAFileConverter.app/Contents/MacOS/ODAFileConverter /usr/local/bin/ODAFileConverter
```
Verify with `which ODAFileConverter`.
- **Linux** — the `.deb` / `.rpm` package usually installs the binary on `PATH` automatically. If not:
```bash
sudo ln -s /opt/ODAFileConverter_QT5*/ODAFileConverter /usr/local/bin/ODAFileConverter
```
Verify with `which ODAFileConverter`.
4. **Restart the Flask server.** PATH is read once at startup, so a running server won't see the new entry. After restart, the CAD tool page will show a green *"DWG support is enabled"* banner.
**No ODA, no problem:** if you can't install it (e.g. on a restricted machine), open your DWG in free tools like [Autodesk Viewer](https://viewer.autodesk.com/), LibreCAD, or QCAD, export as DXF, then upload the DXF here.
---
## Project Structure
+35 -4
View File
@@ -134,12 +134,43 @@ def ocr_pdf_page():
@bp.route("/cad-to-pdf")
def cad_to_pdf_page():
desc = "Convert DXF (or DWG with ODA File Converter) drawings to PDF or PNG"
if not ODA_CONVERTER:
desc += " — DWG requires ODA File Converter on PATH"
if ODA_CONVERTER:
notes = (
'<p><i class="bi bi-check-circle-fill" style="color:#2ec4b6"></i> '
'<strong>DWG support is enabled.</strong> ODA File Converter was detected at '
f'<code>{ODA_CONVERTER}</code>.</p>'
'<p>DXF files are rendered directly. DWG files are auto-converted to DXF first.</p>'
)
else:
notes = (
'<p><strong>DXF works out of the box.</strong> DWG files need the free '
'<a href="https://www.opendesign.com/guestfiles/oda_file_converter" target="_blank" rel="noopener">'
'ODA File Converter</a> installed and available on your system <code>PATH</code>.</p>'
'<details>'
'<summary>How to install ODA File Converter</summary>'
'<ol>'
'<li>Download the installer for your OS from '
'<a href="https://www.opendesign.com/guestfiles/oda_file_converter" target="_blank" rel="noopener">opendesign.com</a> '
'(free, guest download — no account required).</li>'
'<li>Run the installer. Defaults are fine.</li>'
'<li><strong>Add it to your PATH so this app can find it:</strong>'
'<ul>'
'<li><strong>Windows:</strong> add <code>C:\\Program Files\\ODA\\ODAFileConverter_title_version</code> '
'(the folder containing <code>ODAFileConverter.exe</code>) to your <em>System Environment Variables</em> &rarr; <code>Path</code>.</li>'
'<li><strong>macOS:</strong> <code>ln -s /Applications/ODAFileConverter.app/Contents/MacOS/ODAFileConverter /usr/local/bin/ODAFileConverter</code></li>'
'<li><strong>Linux:</strong> the <code>.deb</code>/<code>.rpm</code> package installs <code>ODAFileConverter</code> on PATH automatically. Otherwise symlink the binary into <code>/usr/local/bin</code>.</li>'
'</ul></li>'
'<li>Open a new terminal and verify: <code>ODAFileConverter</code> (should launch the tool GUI, or exit silently).</li>'
'<li><strong>Restart this Flask server</strong> so it picks up the updated PATH.</li>'
'</ol>'
'<p style="margin-top:.4rem">Alternative: open your DWG in free tools like <a href="https://www.autodesk.com/viewers" target="_blank" rel="noopener">Autodesk Viewer</a>, LibreCAD, or QCAD and export it as DXF, then upload the DXF here.</p>'
'</details>'
)
return render_template("upload_tool.html",
title="CAD to PDF/Image",
description=desc,
description="Convert DXF drawings to PDF or PNG. DWG is supported when ODA File Converter is installed.",
notes=notes,
endpoint="/convert/cad-to-pdf",
accept=".dxf,.dwg",
multiple=False,
+29
View File
@@ -224,6 +224,35 @@ a { color: var(--primary); text-decoration: none; }
.tool-header h1 { font-size: 1.5rem; margin-bottom: .3rem; }
.tool-header p { color: var(--text-light); }
.tool-notes {
background: #fff8e1;
border-left: 3px solid #f5b700;
border-radius: 4px;
padding: .75rem 1rem;
margin-bottom: 1.25rem;
font-size: .88rem;
line-height: 1.5;
color: #5a4200;
}
.tool-notes p { margin: 0 0 .5rem; }
.tool-notes p:last-child { margin-bottom: 0; }
.tool-notes code {
background: rgba(0,0,0,.06);
padding: .1rem .35rem;
border-radius: 3px;
font-size: .82rem;
}
.tool-notes details { margin-top: .5rem; }
.tool-notes details > summary {
cursor: pointer;
font-weight: 600;
color: #8a6300;
}
.tool-notes details[open] > summary { margin-bottom: .5rem; }
.tool-notes ol, .tool-notes ul { margin: .25rem 0 .5rem 1.2rem; padding: 0; }
.tool-notes li { margin-bottom: .2rem; }
.tool-notes a { color: #b26f00; }
/* ── Upload Zone ──────────────────────────────── */
.upload-zone {
border: 2px dashed var(--border);
+6
View File
@@ -9,6 +9,12 @@
<p>{{ description }}</p>
</div>
{% if notes %}
<div class="tool-notes">
{{ notes|safe }}
</div>
{% endif %}
<form id="tool-form" data-endpoint="{{ endpoint }}">
{% if text_input %}
<div class="form-group">