ezdxf配置odafc用于读取或转换dwg文件

第一步 安装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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值