第一步 安装ezdxf
pip3 install ezdxf
第二步 安装ODA File Converter
下载ODA File Converter,下载后安装。
ezdxf.addons.odafc会按照win_exec_path查找ODAFileConverter.exe文件。win_exec_path默认值为"C:\Program Files\ODA\ODAFileConverter\ODAFileConverter.exe",所以最好按照默认路径按照,可以减少后续麻烦。如果自定义按照,需要配置ODAFileConverter.exe路径。
配置路径有两种方式,一种是在代码里动态修改,e.g:
from ezdxf.addons import odafc
# 通过修改win_exec_path的值为自定义安装路径
odafc.win_exec_path = r'..\ODAFileConverter.exe'
另一种是在odafc.py文件里修改path路径。该文件在你的python包安装目录site-packages/ezdxf/addons里。
def _get_odafc_path(system: str) -> str:
"""Get ODAFC application path.
"""
if system != WINDOWS and unix_exec_path:
if Path(unix_exec_path).is_file():
return unix_exec_path
else:
logger.warning(
f"command '{unix_exec_path}' not found, using 'ODAFileConverter'"
)
#path = shutil.which("ODAFileConverter") # 此处注释掉然后改为你自己的安装路径
path = '你的安装路径'
if not path and system == WINDOWS:
path = win_exec_path
if not Path(path).is_file():
path = None
if not path:
raise ODAFCNotInstalledError(
f"Could not find ODAFileConverter in the path. "
f"Install application from https://www.opendesign.com/guestfiles/oda_file_converter"
)
return path