DXF 转图片 / SVG 转换器:CAD 数据可视化 - Openclaw Skills

作者:互联网

2026-04-17

AI教程

什么是 DXF 转图片 / SVG 转换器?

DXF 转图片 / SVG 技能旨在桥接复杂工程数据与易于访问的视觉媒体。通过将其集成到 Openclaw Skills,开发人员和设计师可以立即将来自 Rhino 或地图获取工具等 CAD 图纸渲染为位图或矢量文件。这对于需要在 T@elegrimm 等聊天环境中预览技术图纸,或将其嵌入文档而无需完整 CAD 套件的工作流至关重要。

该工具利用高性能 Python 库,确保 DXF 文件中的每个图层和实体都能准确呈现。无论您是需要用于项目更新的快速缩略图,还是用于进一步矢量编辑的高保真 SVG,此技能都能提供在 AI 驱动环境中处理 CAD 文件所需的自动化能力。

下载入口:https://github.com/openclaw/skills/tree/main/skills/qrost/dxf-to-image

安装与下载

1. ClawHub CLI

从源直接安装技能的最快方式。

npx clawhub@latest install dxf-to-image

2. 手动安装

将技能文件夹复制到以下位置之一

全局模式 ~/.openclaw/skills/ 工作区 /skills/

优先级:工作区 > 本地 > 内置

3. 提示词安装

将此提示词复制到 OpenClaw 即可自动安装。

请帮我使用 Clawhub 安装 dxf-to-image。如果尚未安装 Clawhub,请先安装(npm i -g clawhub)。

DXF 转图片 / SVG 转换器 应用场景

  • 将建筑 DXF 文件转换为 PNG 图片,以便在 T@elegrimm 对话中即时共享。
  • 生成 CAD 图纸的 SVG 版本,用于基于 Web 的设计工具或演示文稿。
  • 将地图数据批量处理为高分辨率 JPG 文件,用于项目报告。
  • 为 AI 代理提供在技术支持环节中向用户“可视化”CAD 数据的内容。
DXF 转图片 / SVG 转换器 工作原理
  1. AI 代理接收转换 DXF 文件的请求,并识别源路径和目标格式。
  2. 代理通过 shell 执行转换脚本,传递输出目录、尺寸和分辨率的特定参数。
  3. 该技能利用 ezdxf 库解析 CAD 数据,并使用 matplotlib 或 Pillow 渲染最终的视觉输出。
  4. 生成的文件保存到允许的媒体目录(如 /tmp 或 ~/.openclaw/media/)以便安全检索。
  5. 代理自动通过通信界面将转换后的图像或矢量路径交付给用户。

DXF 转图片 / SVG 转换器 配置指南

要在您的 Openclaw Skills 设置中使用此技能,请确保您已准备好所需的 Python 环境。导航到技能文件夹并运行以下命令:

pip install ezdxf matplotlib Pillow

注意:位图格式(PNG/JPG)需要 matplotlib,而 SVG 导出可由 ezdxf 绘图插件原生处理。

DXF 转图片 / SVG 转换器 数据架构与分类体系

该技能通过将基于矢量的 DXF 实体转换为基于像素或简化的矢量格式来管理数据。它遵循严格的路径约定,以保持与 Openclaw Skills 媒体工具的兼容性。

参数 类型 描述
input 路径 要转换的源 .dxf 文件
--format 字符串 目标输出:png, jpg, 或 svg
--width/--height 整数 位图输出的像素尺寸
--dpi 整数 PNG/JPG 质量的每英寸点数(默认:150)
--margin 整数 SVG 矢量导出的页边距(单位:mm)
name: dxf-to-image
version: 1.0.0
description: Convert DXF to PNG, JPG, or SVG for sharing (e.g. T@elegrimm) or further editing.
author: qrost
permissions:
  - shell:exec

DXF to Image / SVG

Convert DXF (CAD) files to PNG, JPG, or SVG. Useful when you have DXF from map-grabber, Rhino, or other CAD tools and need a raster image to send in ch@t or a vector SVG for editing.

Dependencies

  • ezdxf (DXF read + drawing add-on)
  • matplotlib (for PNG/JPG only)
  • Pillow (for JPG only)

Setup: OpenClaw does not install Python packages automatically. After installing this skill, run once: pip install -r requirements.txt (from the skill folder). If a script fails with ModuleNotFoundError, install the missing package.

Usage

Convert DXF to PNG, JPG, or SVG

Parameters:

  • input: Path to the DXF file.
  • -o, --output: Output file path (default: same name as input with .png, .jpg, or .svg).
  • -f, --format: png (default), jpg, or svg.
  • --width, --height: Output size in pixels for PNG/JPG only (keeps aspect ratio if only one is set).
  • --dpi: DPI for PNG/JPG (default 150).
  • --margin: Margin in mm for SVG (default 2).
# DXF to PNG (default)
python3 scripts/convert_dxf.py drawing.dxf -o drawing.png

# DXF to SVG (vector, no matplotlib for this path)
python3 scripts/convert_dxf.py site.dxf -f svg -o site.svg

# DXF to JPG
python3 scripts/convert_dxf.py site.dxf -f jpg -o site.jpg

# Fixed width 800px (height auto)
python3 scripts/convert_dxf.py map.dxf -o map.png --width 800

Sending images to T@elegrimm

Used from the OpenClaw T@elegrimm conversation. Run the script with -o .png or -o .jpg, then send that file to the user via the OpenClaw message/media tool.

OpenClaw allowed paths: The message tool only sends files from allowed dirs (~/.openclaw/media/, ~/.openclaw/agents/, or /tmp). Use e.g. -o ~/.openclaw/media/out.png or -o /tmp/out.png; do not use the skill install directory or sending will fail.

Agent behavior: When the user asks to convert a DXF to PNG, JPG, or SVG (or "send DXF as image"), run the script directly with exec: use convert_dxf.py -o with -f png/jpg/svg and output path under an allowed dir; then send the generated file. Do not ask for confirmation; execute and return the file.

Examples

User: "Convert this DXF to PNG so I can send it in T@elegrimm."
Action: Run convert_dxf.py -o /tmp/out.png, then send the PNG to the user.

User: "Export the DXF as SVG."
Action: Run convert_dxf.py -f svg -o /tmp/out.svg, then send or return the SVG path.

User: "Turn the site DXF into a JPG, 1200px wide."
Action: Run with -f jpg -o /tmp/site.jpg --width 1200, then send the JPG.

相关推荐