mozman / ezdxf

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

I can't make odafc-addon to work (for windows). #1176

Open iakovos-panourgias opened 5 days ago

iakovos-panourgias commented 5 days ago

Describe the bug I am trying to use the odafc-addon to convert a DWG to a DXF. I've read the manual and I've created a new config file with the correct PATH for "win_exec_path". I've moved ODAFileConverter to a path without spaces. However, ezdxf keeps throwing the not found exception.

To Reproduce

  1. A simplified and executable Python script which triggers the error.

Contents of the "ezdxf_config.ini" file:

[odafc-addon]
win_exec_path = "D:\ODAFileConverter25.4.0\ODAFileConverter.exe"

Python script:

import ezdxf
from ezdxf.addons import odafc
from pathlib import Path
import os

ezdxf.options.read_file("ezdxf_config.ini")

# I was trying to reproduce the logic of "_get_odafc_path()"
win_exec_path = ezdxf.options.get("odafc-addon", "win_exec_path").strip('"')
print(win_exec_path)
print(os.path.exists(win_exec_path))
path = win_exec_path
print(path)
print(Path(path))
if not Path(path).is_file():
    print("Not a file path")

# Actual ezdxf call:
odafc.convert('../ORIGINAL/Test.dwg', "Test.dxf", version="ACAD2018", audit=False)

Output of the script:

D:\ODAFileConverter25.4.0\ODAFileConverter.exe
True
D:\ODAFileConverter25.4.0\ODAFileConverter.exe
D:\ODAFileConverter25.4.0\ODAFileConverter.exe
Traceback (most recent call last):
  File "D:\test\test.py", line 41, in <module>
    odafc.convert('../ORIGINAL/Test.dwg', "Test.dxf", version="ACAD2018", audit=False)    
  File "D:\_env\Lib\site-packages\ezdxf\addons\odafc.py", line 292, in convert
    _execute_odafc(arguments)
  File "D:\_env\Lib\site-packages\ezdxf\addons\odafc.py", line 490, in _execute_odafc
    oda_fc = _get_odafc_path(system)
             ^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\_env\Lib\site-packages\ezdxf\addons\odafc.py", line 389, in _get_odafc_path
    raise ODAFCNotInstalledError(
ezdxf.addons.odafc.ODAFCNotInstalledError: Could not find ODAFileConverter in the path. Install application from https://www.opendesign.com/guestfiles/oda_file_converter

The ODAFileConverter.exe (to show that it exists):

PS D:\test> ls D:\ODAFileConverter25.4.0\ODAFileConverter.exe

    Directory: D:\ODAFileConverter25.4.0

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a---           25/4/2024  1:54 μμ         360512 ODAFileConverter.exe

PS D:\test> dir D:\ODAFileConverter25.4.0\ODAFileConverter.exe  |  select Name,Attributes                                

Name                          Attributes
----                          ----------
ODAFileConverter.exe Archive, Compressed
  1. Information about the ezdxf version and the OS. python version : 3.12 ezdxf version : 1.3.3 Installed on a Windows 10 machine using conda.

Expected behavior The convert operation should start. It doesn't. I get the "ODAFCNotInstalledError" exception.

mozman commented 4 days ago

Please read the docs how to use config files: https://ezdxf.mozman.at/docs/options.html#config-files

mozman commented 4 days ago

You have to change the path before importing the odafc module.

mozman commented 4 days ago

You can set the path direct in the odafc add-on without using a config file. This is a bit of a hack, but the add-on will not be changed in the near future.

odafc.win_exec_path = r"your\path\to\ODAFileConverter.exe"