Measurements & AnalysisChinese & English

Mesh to CAD (STEP)

Mesh to CAD (STEP) - convert a scene mesh into a CAD solid/shell and write STEP / IGES / BREP。

Updated 2026-07-07User manual

Mesh to CAD (STEP) 插件用户手册

Mesh to CAD (STEP) - User Manual

Dragonfly Prototype Apps · Mesh to CAD (STEP)...

版本 Version 1.0 · 2026-07-04


第一部分 中文手册

目录

1. 简介

2. 适用场景

3. 安装与启用

4. 运行环境与首次配置

5. 界面说明

6. 使用步骤

6.1 标准转换(OpenCASCADE 后端)

6.2 Point2CAD 转换(实验性,可选)

7. 参数说明

8. 输出结果

9. 常见问题与故障排除

10. 注意事项与已知限制

11. 参考资料

1. 简介

Mesh to CAD (STEP) 插件把 Dragonfly 场景中的网格(mesh)对象转换成 CAD 实体或壳体,并导出为 STEP / IGES / BREP 格式的 CAD 文件。您只需选择一个 mesh、一个转换后端、输出格式和输出文件,点击 Convert 即可:水密(watertight)网格会转换为实体(solid),非水密网格则转换为壳体(shell)。转换完成后面板会报告写出的文件(实体/壳体、文件大小),并提供 Open output folder 按钮直接打开输出文件夹。

插件提供三种转换后端:

  • OpenCASCADE - faceted solid(逐面实体,精确几何):每个三角面片变成一张平面 CAD 面,缝合成壳体;水密网格进一步生成实体。几何精确、始终可用,许可宽松(LGPL)。
  • OpenCASCADE - convex hull solid(凸包实体,简化):取网格的凸包生成一个干净的简化实体。
  • Point2CAD - 自动参数化 B-rep(实验性):基于深度学习的逆向工程(自动拟合曲面+边+角点)。许可为 CC-BY-NC 4.0(仅限非商业/研究用途),需要自备 GPU 环境和已分割的点云,尚待实机验证。

底层引擎与许可:OpenCASCADE 后端通过 cadquery-ocp(OpenCASCADE Technology 的 Python 绑定,LGPL)实现 CAD 内核与 STEP/IGES/BREP 写出;网格加载与凸包计算用 trimesh(MIT);数值计算用 numpy / scipy(BSD)。这些库均为宽松许可,可放心用于商业场景。Point2CAD 是唯一的例外——它是 CC-BY-NC 4.0 非商业许可,且为可选、实验性功能。

架构说明:所有转换都在插件专属的独立 Python 虚拟环境(venv)中以子进程方式运行,通过 JSON 文件通信,绝不在 Dragonfly 自身的 Python 里执行——即使转换出错也不会影响 Dragonfly 的稳定性。

2. 适用场景

  • CT / 照片重建 / 分割结果进入 CAD 流程:把 CT 重建、摄影测量(photogrammetry)或图像分割得到的 mesh 导出为 STEP,在 FreeCAD、SolidWorks 等 CAD 软件中打开。
  • 计量与装配参考:将实测得到的几何体作为 CAD 装配中的参考件或计量对象。
  • 逆向工程:从扫描数据重建可编辑的 CAD 模型的第一步。
  • 长期存档:STEP / IGES 是中性 CAD 交换格式,适合跨软件、跨年代存档。
  • 需要“干净参数化 CAD”时:可尝试实验性的 Point2CAD 后端(注意其非商业许可限制,见第 4、10 节)。

3. 安装与启用

本插件随 Prototype Labs & Apps 完整安装包(Full Package) 分发,属于其中的 Prototype Apps 插件之一。安装步骤:

1. 把安装包 zip 解压到任意较短路径(例如桌面或 C:\PL\)。

2. 双击 `Install_FullPackage.bat` 启动安装器。

3. 在弹出的对话框中选择核心安装模式(Fresh 全新安装 / Compatible 兼容安装——只影响 Prototype Labs 核心的 blocks 和 recipes,不影响任何插件的环境和设置)。

4. 在 Prototype Apps 列表中勾选 Mesh to CAD (STEP)...。注意:所有插件默认不勾选,必须手动勾选才会安装。

5. 点击 Install,等待控制台完成。

6. 完全重启 Dragonfly(彻底退出后重新打开)。

重启后,菜单项出现在 Prototype Apps ▸ Mesh to CAD (STEP)...(位于 Measurements & Analysis 分组)。点击后打开一个浮动、可停靠的面板。

以后修改启用状态:在 Dragonfly 中打开 Developer ▸ Prototype Labs... ▸ Menu Item Manager,底部的 "Prototype Apps (Full Package)" 列表里每个应用一个勾选框:勾选=部署,取消=移除菜单项,重启 Dragonfly 生效。停用不会删除插件已搭建的环境,重新启用后立即可用。也可以随时重跑安装器(%LOCALAPPDATA%\DragonflyPrototypeLabs\FullPackage\installer\Install_FullPackage.bat),上次的选择就是默认值。

菜单只在 Dragonfly 启动时扫描——每次修改勾选后都需要重启一次 Dragonfly 才能生效。

4. 运行环境与首次配置

首次使用前,需在面板里点击一次 Setup Environment。它做的事情是:

1. 在 `%LOCALAPPDATA%\DragonflyPrototypeLabs\MeshToCAD\venv` 这个刻意选择的短路径下创建一个 Python 虚拟环境(venv)。为什么必须是短路径:OpenCASCADE 的 DLL 文件名很长,如果 venv 装在很深的目录下,完整路径会超过 Windows 的 MAX_PATH(260 字符)限制导致 DLL 加载失败。若 venv 路径超过 90 字符,安装脚本会给出警告。

2. 默认用 Dragonfly 自带的 Python 作为基础解释器创建 venv(也可在 Base Python 框中指定其他 Python)。

3. 联网从 PyPI 安装 cadquery-ocp(OpenCASCADE 绑定,体积较大)、trimesh、numpy、scipy。

4. 安装完成后自动做一次导入自检(numpy / trimesh / scipy / OCP 的 STEP 写出器),并记录 venv 的 Python 路径,状态栏显示 Ready。

  • 联网:仅环境搭建时需要一次;之后转换全程离线。
  • GPU:OpenCASCADE 两个后端不需要 GPU。
  • WSL:不需要。
  • 耗时:面板为环境搭建设置了 30 分钟超时;正常网络下远快于此。
  • 环境复用:再次点击 Setup Environment 时,若检测到已有可用的 venv 会直接复用,不会重复下载。

失败时的替代方案:如果用 Dragonfly 自带 Python 建 venv 失败(例如缺少 venv 模块或 pip 不可用),在面板的 Base Python 框中填入本机另一个 CPython 3.9–3.12(x86-64)的 python.exe 完整路径(cadquery-ocp 只为这些版本提供 wheel),再点 Setup Environment。留空则自动探测:优先 Dragonfly 自带 Python,其次 py 启动器、PATH 中的 python、常见安装位置。

Point2CAD 后端不使用上述 venv,需要自备其 GPU 环境:克隆 https://github.com/prs-eth/point2cad ,设置环境变量 MESH2CAD_P2C_DIR(指向克隆目录)和 MESH2CAD_P2C_PY(指向其 Python),并注意其 CC-BY-NC 4.0 非商业许可。商业/稳健用途请使用 OpenCASCADE 后端。

5. 界面说明

面板自上而下由以下部分组成(与软件实际界面一一对应):

控件

类型

说明

标题栏

文字

Mesh to CAD (STEP) - convert a scene mesh into a CAD solid/shell and write STEP / IGES / BREP。

Mesh + Refresh

下拉框+按钮

列出场景中的所有 mesh 对象,每项显示“名称 (顶点数 v / 面数 f)”。点 Refresh 重新扫描场景。

Backend

下拉框

三个转换后端(见第 1 节)。切换到 Point2CAD 时,下方警告栏会显示非商业许可与实验性提示。

Format

下拉框

STEP (.step) / IGES (.igs) / BREP (.brep)。切换格式时输出文件的扩展名自动同步。

Output file + Browse...

文本框+按钮

输出 CAD 文件的完整路径。Browse... 打开保存对话框,默认起始位置为 %LOCALAPPDATA%\DragonflyPrototypeLabs\MeshToCAD\output\model.step。

警告栏

文字(橙色加粗)

显示当前后端的说明与许可;选 Point2CAD 时显示非商业/实验性警告。

Base Python

文本框

位于 Environment (conversion venv) 组。留空 = 用 Dragonfly 自带 Python 建环境;也可填其他 Python 路径。

Status

文字

环境状态:Ready (<venv 路径>) 或 Not set up - click 'Setup Environment'.

Setup Environment

按钮

一次性搭建转换环境(见第 4 节)。运行中按钮置灰。

Convert

按钮(蓝色)

执行转换:导出所选 mesh → 在 venv 中转换 → 写出 CAD 文件。

结果栏 + Open output folder

文字+按钮

显示转换摘要与输出路径;成功后 Open output folder 变为可用,点击在资源管理器中打开输出文件夹。

日志区

只读文本框

实时显示环境搭建与转换的进度、百分比和错误信息。

面板会自动记住 Output file 与 Base Python 的设置(保存在插件目录下的配置文件里),下次打开时自动恢复;插件代码升级时该配置也会被保留。

6. 使用步骤

前提:场景中已有一个 mesh 对象(例如由 CT 分割、等值面提取或照片重建得到),且该对象包含三角面(纯点云会被拒绝)。

6.1 标准转换(OpenCASCADE 后端)

1. 打开 Prototype Apps ▸ Mesh to CAD (STEP)...。

2. 首次使用:点击 Setup Environment,等日志出现 Setup complete.、状态栏变为 Ready(见第 4 节)。

3. 在 Mesh 下拉框中选择要转换的网格(若为空点 Refresh)。

4. 在 Backend 中选择 OpenCASCADE - faceted solid(精确、推荐)或 OpenCASCADE - convex hull solid(简化)。

5. 在 Format 中选择 STEP / IGES / BREP。

6. 点 Browse... 指定输出文件(或直接在文本框输入完整路径)。

7. 点击 Convert。日志区显示进度(Loading mesh → Converting → 完成)。

8. 成功后结果栏显示类似 Wrote solid STEP (12000 faces, 3456789 bytes) 的摘要与输出路径;点 Open output folder 打开输出文件夹,用 FreeCAD / SolidWorks 等打开写出的文件验证。

转换过程:插件先在 Dragonfly 内部读取所选 mesh 的顶点和面(四边形及以上多边形会自动三角化),导出到一个临时任务文件夹的 mesh.npz;然后在 venv 中启动转换子进程,逐面构建 CAD 面并缝合。水密网格 → 实体(solid);非水密网格 → 壳体(shell)。单次转换超时上限为 1 小时。

6.2 Point2CAD 转换(实验性,可选)

Point2CAD 许可为 CC-BY-NC 4.0,禁止商业使用,且为实验性功能、尚待实机验证。以下步骤仅供研究用户参考。

1. 自行克隆 https://github.com/prs-eth/point2cad 并按其说明搭好 GPU 环境。

2. 设置环境变量 MESH2CAD_P2C_DIR(克隆目录)和 MESH2CAD_P2C_PY(该环境的 Python 路径),然后启动 Dragonfly。

3. 在 Backend 中选择 Point2CAD - automatic parametric B-rep (EXPERIMENTAL),其余步骤同 6.1。

4. 插件会从 mesh 表面采样 20000 个点写成 point2cad_input.xyzc,交给 Point2CAD 处理;产物(.step/.stp/.ply/.obj 等)写入输出文件所在文件夹。

重要限制:Point2CAD 期望的输入是已分割的点云(每点带表面标签);本插件目前把所有采样点标为同一标签(视作单一曲面),只能作为流程验证,真实效果需要上游提供分割结果。未配置环境变量时,转换会直接返回说明性提示而不会报错崩溃。

7. 参数说明

参数

默认值

说明

Mesh

(场景第一个 mesh)

要转换的网格对象;下拉项显示顶点/面数量。点 Refresh 重新扫描。

Backend

OpenCASCADE - faceted solid (exact geometry)

转换后端;另有 convex hull(简化)与 Point2CAD(实验性、非商业)。

Format

STEP (.step)

输出格式;可选 IGES (.igs)、BREP (.brep)。切换时输出文件扩展名自动同步。

Output file

(记住上次的路径)

输出 CAD 文件完整路径;Browse 默认建议 %LOCALAPPDATA%\DragonflyPrototypeLabs\MeshToCAD\output\model.step。

Base Python

(空 = Dragonfly 自带 Python)

仅用于 Setup Environment 建 venv 的基础解释器;需要 CPython 3.9-3.12 x86-64。

以下为转换内核的内置默认值(当前版本不在界面上开放调节):

内部参数

默认值

说明

缝合容差 sew_tol

1e-6

OpenCASCADE 把逐面几何缝合成壳体时使用的容差。

尝试成实体 make_solid

开启

缝合出闭合壳体后尝试生成实体;失败则保留壳体。

Point2CAD 采样点数 n_sample

20000

从 mesh 表面采样送入 Point2CAD 的点数。

环境搭建超时

30 分钟

Setup Environment 的时间上限。

转换超时

1 小时

单次 Convert 的时间上限。

8. 输出结果

本插件的输出是磁盘上的 CAD 文件,不在 Dragonfly 场景中创建新对象:

  • CAD 文件:写到您指定的 Output file 路径,格式为 STEP(.step)、IGES(.igs)或 BREP(.brep)。水密网格输出为实体,否则为壳体。
  • 结果摘要:结果栏显示 Wrote <solid|shell> <格式> (<面数> faces, <字节数> bytes),并附输出路径。
  • Open output folder 按钮:成功后可点击,在 Windows 资源管理器中直接打开输出文件所在文件夹。
  • 任务文件夹:每次转换在系统临时目录创建一个 mesh2cad_ 开头的任务文件夹,内含导出的 mesh.npz、config.json、status.json、results.json,供排查问题时查看。

如何查看结果:用任意支持 STEP/IGES/BREP 的 CAD 软件打开输出文件,例如 FreeCAD(免费)或 SolidWorks。逐面实体后端的输出是“面片化 BREP”——每个三角面是一张独立平面 CAD 面,几何与原网格完全一致,但不是光滑参数曲面。

9. 常见问题与故障排除

问:Setup Environment 失败,日志提示 requirements install failed / cadquery-ocp needs a matching wheel?

答:cadquery-ocp 只为 CPython 3.9–3.12(x86-64)提供预编译 wheel。若 Dragonfly 自带的 Python 不满足,请在 Base Python 框中填入一个满足条件的 python.exe 完整路径后重试。另请确认此时网络可访问 PyPI。

问:转换时 OpenCASCADE 的 DLL 加载失败,或日志出现路径过长(MAX_PATH)警告?

答:这正是插件把 venv 固定建在短路径 %LOCALAPPDATA%\DragonflyPrototypeLabs\MeshToCAD\venv 的原因。请不要手动把 venv 移到深层目录;若安装时日志提示“venv path is long (>90 chars)”,请检查 %LOCALAPPDATA% 是否被重定向到了很深的路径。

问:Mesh 下拉框是空的?

答:点 Refresh 重新扫描;确认场景中确实存在 mesh 对象(本插件枚举的是网格类对象,Channel/ROI 不会出现在列表中)。若日志显示 No meshes found in the scene.,请先在 Dragonfly 中生成网格(如从 ROI 提取等值面)。

问:报错 “this object has no faces (it is a point cloud)”?

答:所选对象只有顶点、没有三角面(是点云)。Mesh to CAD 需要三角网格,请先把点云重建成 mesh 再转换。

问:为什么结果是 shell(壳体)而不是 solid(实体)?

答:只有水密(闭合、无孔洞)的网格才会缝合成实体;有孔洞或开边界的网格只能成为壳体。可先在 Dragonfly 中修补网格,或改用 convex hull 后端得到一个必然闭合的简化实体。

问:选 Point2CAD 后提示 “Point2CAD not configured”?

答:这是预期行为——Point2CAD 需要您自行克隆 https://github.com/prs-eth/point2cad 并设置 MESH2CAD_P2C_DIR 与 MESH2CAD_P2C_PY 环境变量(见 6.2 节)。同时请再次确认您的用途符合其 CC-BY-NC 非商业许可。

问:STEP 文件很大 / 在 CAD 软件里打开很慢?

答:逐面实体后端把每个三角面写成一张 CAD 面,文件大小和打开耗时随三角面数增长。可先在 Dragonfly 中对网格降采样/简化后再转换,或改用 convex hull 后端(若能接受简化外形)。

10. 注意事项与已知限制

  • 面片化输出:OpenCASCADE 逐面后端产出的是面片化 BREP(每三角面一张平面),不是光滑 NURBS 参数曲面;需要参数化曲面时目前只能尝试实验性的 Point2CAD。
  • 凸包后端会丢失凹陷:convex hull 只保留凸包外形,所有凹陷、孔洞、内部结构都会消失。
  • Point2CAD:CC-BY-NC 4.0,禁止商业使用;实验性、尚待实机验证;需要自备 GPU 环境和已分割点云——插件当前送入的是未分割(单标签)的采样点云,仅够流程验证。
  • 多边形面自动三角化:非三角形面(四边形等)在导出时按扇形展开为三角形。
  • 超时:环境搭建 30 分钟、单次转换 1 小时;特别巨大的网格可能超时。
  • 菜单变更需重启:启用/停用插件后必须完全重启 Dragonfly。
  • 磁盘位置:venv 和默认输出目录都在 %LOCALAPPDATA%\DragonflyPrototypeLabs\MeshToCAD\ 下;卸载 Full Package 不会删除该环境(卸载结束时会列出路径供手动清理)。

11. 参考资料

  • OCP(cadquery-ocp,OpenCASCADE Technology 的 Python 绑定,LGPL):https://github.com/CadQuery/OCP
  • trimesh(MIT,网格加载与凸包):https://trimsh.org
  • Point2CAD(CVPR 2024,CC-BY-NC 4.0):https://github.com/prs-eth/point2cad
  • STEP / IGES:中性 CAD 数据交换格式,绝大多数 CAD 软件(FreeCAD、SolidWorks 等)均可导入。


Part II English Manual

Contents

1. Overview

2. Use Cases

3. Installation and Enabling

4. Runtime Environment and First-Time Setup

5. User Interface

6. Step-by-Step Usage

6.1 Standard conversion (OpenCASCADE backends)

6.2 Point2CAD conversion (experimental, optional)

7. Parameters

8. Output

9. FAQ and Troubleshooting

10. Notes and Known Limitations

11. References

1. Overview

The Mesh to CAD (STEP) plugin converts a mesh object in the Dragonfly scene into a CAD solid or shell and writes it as a STEP / IGES / BREP CAD file. Pick a mesh, a conversion backend, an output format and an output file, then click Convert: a watertight mesh becomes a solid, otherwise a shell. When done, the panel reports the written file (solid/shell, size) and offers an Open output folder button.

Three conversion backends are available:

  • OpenCASCADE - faceted solid (exact geometry): every triangle becomes a planar CAD face, sewn into a shell; a watertight mesh further becomes a solid. Exact geometry, always available, permissively licensed (LGPL).
  • OpenCASCADE - convex hull solid (simplified): the mesh's convex hull as a clean, simplified solid.
  • Point2CAD - automatic parametric B-rep (EXPERIMENTAL): deep-learning reverse engineering (fits surfaces + edges + corners). Licensed CC-BY-NC 4.0 (NON-COMMERCIAL / research only), needs your own GPU environment and a segmented point cloud; live verification is still pending.

Engines and licensing: the OpenCASCADE backends use cadquery-ocp (Python bindings for OpenCASCADE Technology, LGPL) as the CAD kernel and STEP/IGES/BREP writer; trimesh (MIT) for mesh handling and convex hulls; numpy / scipy (BSD) for numerics. All of these are permissive and safe for commercial use. Point2CAD is the one exception - CC-BY-NC 4.0, non-commercial, and an optional experimental feature.

Architecture: all conversions run as a subprocess in the plugin's own dedicated Python virtual environment (venv) with JSON-file IPC - never inside Dragonfly's Python. Even a failed conversion cannot destabilize Dragonfly.

2. Use Cases

  • Bring CT / photogrammetry / segmentation meshes into a CAD workflow: export meshes obtained from CT reconstruction, photogrammetry or image segmentation as STEP and open them in FreeCAD, SolidWorks, etc.
  • Metrology and assembly reference: use as-measured geometry as a reference part in a CAD assembly or for metrology.
  • Reverse engineering: the first step from scan data toward an editable CAD model.
  • Long-term archival: STEP / IGES are neutral CAD exchange formats, well suited for cross-software, long-term archiving.
  • When clean parametric CAD is needed: try the experimental Point2CAD backend (mind its non-commercial license; see sections 4 and 10).

3. Installation and Enabling

This plugin ships with the Prototype Labs & Apps Full Package as one of its Prototype Apps. To install:

1. Unzip the package anywhere with a short path (Desktop or C:\PL\ is fine).

2. Double-click `Install_FullPackage.bat`.

3. In the dialog, pick the core install mode (Fresh / Compatible - this only affects the Prototype Labs CORE blocks & recipes, never any plugin's environment or settings).

4. Tick Mesh to CAD (STEP)... in the Prototype Apps list. Note: all plugins are unticked by default - you must tick it explicitly.

5. Click Install and wait for the console to finish.

6. Fully restart Dragonfly (quit completely, then reopen).

After the restart, the menu entry appears under Prototype Apps ▸ Mesh to CAD (STEP)... (in the Measurements & Analysis group). Clicking it opens a floating, dockable panel.

Changing your choice later: inside Dragonfly, open Developer ▸ Prototype Labs... ▸ Menu Item Manager - the "Prototype Apps (Full Package)" list at the bottom has a checkbox per app: tick = deploy, untick = remove the menu entry; restart Dragonfly to apply. Disabling never deletes a plugin's environment - re-enabling is instant. Alternatively, re-run the installer any time (%LOCALAPPDATA%\DragonflyPrototypeLabs\FullPackage\installer\Install_FullPackage.bat); your previous choices are the new defaults.

Menus are discovered only at Dragonfly startup - every enable/disable change needs one full restart.

4. Runtime Environment and First-Time Setup

Before the first conversion, click Setup Environment once in the panel. It does the following:

1. Creates a Python virtual environment (venv) at the deliberately SHORT path `%LOCALAPPDATA%\DragonflyPrototypeLabs\MeshToCAD\venv`. Why short: OpenCASCADE's DLLs have long file names - installed under a deep folder, the full path would exceed the Windows MAX_PATH (260 characters) limit and the DLLs would fail to load. The setup script warns if the venv path exceeds 90 characters.

2. Uses Dragonfly's own Python as the base interpreter by default (you may point Base Python elsewhere).

3. Pip-installs cadquery-ocp (the OpenCASCADE bindings - a large download), trimesh, numpy and scipy from PyPI over the internet.

4. Runs an import smoke test (numpy / trimesh / scipy / OCP's STEP writer), records the venv's Python path, and the Status line turns Ready.

  • Internet: needed once, for the environment build only; conversions afterwards are fully offline.
  • GPU: the two OpenCASCADE backends need no GPU.
  • WSL: not needed.
  • Duration: the panel allows up to 30 minutes for the setup; a normal connection finishes far sooner.
  • Reuse: clicking Setup Environment again reuses an existing working venv instead of re-downloading.

If the setup fails: e.g. the base Python lacks the venv module or a usable pip - enter the full path of another CPython 3.9-3.12 (x86-64) python.exe in the Base Python field (cadquery-ocp only ships wheels for those versions) and click Setup Environment again. Left blank, the plugin auto-detects: Dragonfly's own Python first, then the py launcher, pythons on PATH, and common install locations.

The Point2CAD backend does NOT use this venv. It requires your OWN GPU environment: clone https://github.com/prs-eth/point2cad , set the environment variables MESH2CAD_P2C_DIR (the cloned folder) and MESH2CAD_P2C_PY (its python), and mind its CC-BY-NC 4.0 non-commercial license. For commercial/robust use, pick an OpenCASCADE backend.

5. User Interface

From top to bottom the panel consists of (matching the actual software exactly):

Control

Type

Description

Header

label

Mesh to CAD (STEP) - convert a scene mesh into a CAD solid/shell and write STEP / IGES / BREP.

Mesh + Refresh

dropdown + button

Lists all mesh objects in the scene as "title (vertices v / faces f)". Refresh re-scans the scene.

Backend

dropdown

The three conversion backends (see section 1). Selecting Point2CAD shows the non-commercial / experimental warning below.

Format

dropdown

STEP (.step) / IGES (.igs) / BREP (.brep). Changing the format re-syncs the output file's extension.

Output file + Browse...

text field + button

Full path of the output CAD file. Browse... opens a save dialog starting at %LOCALAPPDATA%\DragonflyPrototypeLabs\MeshToCAD\output\model.step by default.

Warning bar

label (orange, bold)

Shows the current backend's note and license; for Point2CAD, the non-commercial / experimental warning.

Base Python

text field

In the Environment (conversion venv) group. Blank = build the env from Dragonfly's own Python; or enter a python path.

Status

label

Environment state: Ready (<venv dir>) or Not set up - click 'Setup Environment'.

Setup Environment

button

One-time environment build (see section 4). Disabled while a job is running.

Convert

button (blue)

Runs the conversion: export the selected mesh, convert in the venv, write the CAD file.

Result line + Open output folder

label + button

Shows the conversion summary and output path; Open output folder becomes enabled on success and opens the folder in Explorer.

Log area

read-only text box

Live progress (percentages), messages and errors for setup and conversion.

The panel remembers Output file and Base Python (stored in a config file next to the plugin code) and restores them next time; plugin code updates preserve this config.

6. Step-by-Step Usage

Prerequisite: the scene contains a mesh object (e.g. from CT segmentation, isosurface extraction or photogrammetry) that has triangle faces (a pure point cloud is rejected).

6.1 Standard conversion (OpenCASCADE backends)

1. Open Prototype Apps ▸ Mesh to CAD (STEP)....

2. First use: click Setup Environment and wait for Setup complete. in the log; the Status line turns Ready (see section 4).

3. Pick the mesh in the Mesh dropdown (click Refresh if it is empty).

4. Pick the Backend: OpenCASCADE - faceted solid (exact, recommended) or OpenCASCADE - convex hull solid (simplified).

5. Pick the Format: STEP / IGES / BREP.

6. Click Browse... to choose the output file (or type a full path).

7. Click Convert. The log shows the progress (Loading mesh, Converting, done).

8. On success the result line shows a summary like Wrote solid STEP (12000 faces, 3456789 bytes) plus the output path; click Open output folder and verify the file in FreeCAD / SolidWorks etc.

What happens under the hood: the plugin reads the selected mesh's vertices and faces inside Dragonfly (polygons with more than 3 edges are fan-triangulated), exports them to mesh.npz in a temporary job folder, then launches the conversion subprocess in the venv, which builds one CAD face per triangle and sews them together. Watertight mesh becomes a solid; otherwise a shell. A single conversion may run for up to 1 hour before timing out.

6.2 Point2CAD conversion (experimental, optional)

Point2CAD is licensed CC-BY-NC 4.0 - commercial use is NOT permitted - and is experimental with live verification pending. The steps below are for research users only.

1. Clone https://github.com/prs-eth/point2cad yourself and set up its GPU environment per its instructions.

2. Set the environment variables MESH2CAD_P2C_DIR (the cloned folder) and MESH2CAD_P2C_PY (that environment's python), then start Dragonfly.

3. Select Point2CAD - automatic parametric B-rep (EXPERIMENTAL) as the Backend; the remaining steps match 6.1.

4. The plugin samples 20000 points from the mesh surface into point2cad_input.xyzc and hands it to Point2CAD; its products (.step/.stp/.ply/.obj) are written into the output file's folder.

Important limitation: Point2CAD expects a segmented point cloud (a surface label per point); the plugin currently labels all sampled points identically (a single surface), which is adequate only as a pipeline smoke test - real results need an upstream segmentation. If the environment variables are not set, the conversion returns an explanatory notice instead of crashing.

7. Parameters

Parameter

Default

Description

Mesh

(first mesh in the scene)

The mesh to convert; entries show vertex/face counts. Refresh re-scans.

Backend

OpenCASCADE - faceted solid (exact geometry)

Conversion backend; alternatives: convex hull (simplified) and Point2CAD (experimental, non-commercial).

Format

STEP (.step)

Output format; also IGES (.igs) and BREP (.brep). Switching re-syncs the output file extension.

Output file

(remembered from last time)

Full output path; Browse suggests %LOCALAPPDATA%\DragonflyPrototypeLabs\MeshToCAD\output\model.step.

Base Python

(blank = Dragonfly's own Python)

Base interpreter used only by Setup Environment; needs CPython 3.9-3.12 x86-64.

The following built-in defaults of the conversion core are not exposed in the UI in this version:

Internal parameter

Default

Description

Sewing tolerance sew_tol

1e-6

Tolerance used by OpenCASCADE when sewing the per-triangle faces into a shell.

Try to make a solid make_solid

on

After sewing a closed shell, attempt to build a solid; falls back to the shell on failure.

Point2CAD sample count n_sample

20000

Number of surface points sampled from the mesh for Point2CAD.

Environment setup timeout

30 minutes

Upper limit for Setup Environment.

Conversion timeout

1 hour

Upper limit for a single Convert run.

8. Output

The plugin's output is a CAD file on disk - it does not create a new object in the Dragonfly scene:

  • The CAD file: written to the Output file path you chose, as STEP (.step), IGES (.igs) or BREP (.brep). A watertight mesh yields a solid, otherwise a shell.
  • Result summary: the result line reads Wrote <solid|shell> <FORMAT> (<n> faces, <n> bytes) plus the output path.
  • Open output folder: enabled on success; opens the output file's folder in Windows Explorer.
  • Job folder: each conversion creates a temporary job folder (name starting with mesh2cad_) in the system temp directory, containing the exported mesh.npz, config.json, status.json and results.json - useful when troubleshooting.

Viewing the result: open the file in any CAD application that reads STEP/IGES/BREP, e.g. FreeCAD (free) or SolidWorks. The faceted-solid backend produces a "faceted BREP" - one planar CAD face per triangle - geometrically identical to the mesh, but not a smooth parametric surface.

9. FAQ and Troubleshooting

Q: Setup Environment fails with "requirements install failed / cadquery-ocp needs a matching wheel"?

A: cadquery-ocp ships pre-built wheels only for CPython 3.9-3.12 (x86-64). If Dragonfly's own Python does not qualify, enter the full path of a qualifying python.exe in the Base Python field and retry. Also make sure PyPI is reachable at that moment.

Q: OpenCASCADE DLLs fail to load, or the log warns the path is too long (MAX_PATH)?

A: This is exactly why the plugin pins the venv to the short path %LOCALAPPDATA%\DragonflyPrototypeLabs\MeshToCAD\venv. Do not move the venv to a deep folder; if the setup log warns "venv path is long (>90 chars)", check whether %LOCALAPPDATA% is redirected to a deep location.

Q: The Mesh dropdown is empty?

A: Click Refresh and confirm the scene actually contains a mesh object (the plugin enumerates mesh-type objects; Channels/ROIs never appear here). If the log says No meshes found in the scene., create a mesh first (e.g. extract an isosurface from an ROI).

Q: Error "this object has no faces (it is a point cloud)"?

A: The selected object has vertices but no triangle faces (it is a point cloud). Mesh to CAD needs a triangle mesh - reconstruct a mesh from the point cloud first.

Q: Why is my result a shell instead of a solid?

A: Only a watertight (closed, hole-free) mesh sews into a solid; meshes with holes or open borders remain shells. Repair the mesh in Dragonfly first, or use the convex hull backend for a guaranteed-closed simplified solid.

Q: Point2CAD says "Point2CAD not configured"?

A: Expected - Point2CAD requires you to clone https://github.com/prs-eth/point2cad yourself and set the MESH2CAD_P2C_DIR and MESH2CAD_P2C_PY environment variables (see 6.2). Also re-check that your use complies with its CC-BY-NC non-commercial license.

Q: The STEP file is huge / very slow to open in CAD software?

A: The faceted backend writes one CAD face per triangle, so file size and load time grow with the triangle count. Decimate/simplify the mesh in Dragonfly before converting, or use the convex hull backend if a simplified shape is acceptable.

10. Notes and Known Limitations

  • Faceted output: the OpenCASCADE faceted backend produces a faceted BREP (one planar face per triangle), not smooth NURBS parametric surfaces; for parametric surfaces the only current option is the experimental Point2CAD.
  • Convex hull loses concavities: the convex hull backend keeps only the convex outer shape - all concavities, holes and internal structure disappear.
  • Point2CAD: CC-BY-NC 4.0, commercial use prohibited; experimental and live-verify pending; needs your own GPU environment and a segmented point cloud - the plugin currently feeds an unsegmented (single-label) sampled cloud, adequate only as a smoke test.
  • Polygon faces are triangulated: non-triangular faces (quads etc.) are fan-triangulated on export.
  • Timeouts: 30 minutes for the environment setup, 1 hour per conversion; extremely large meshes may time out.
  • Menu changes need a restart: after enabling/disabling the plugin, fully restart Dragonfly.
  • Disk locations: the venv and the default output folder live under %LOCALAPPDATA%\DragonflyPrototypeLabs\MeshToCAD\; uninstalling the Full Package keeps this environment (its path is listed at the end of the uninstall for manual cleanup).

11. References

  • OCP (cadquery-ocp, Python bindings for OpenCASCADE Technology, LGPL): https://github.com/CadQuery/OCP
  • trimesh (MIT, mesh handling and convex hulls): https://trimsh.org
  • Point2CAD (CVPR 2024, CC-BY-NC 4.0): https://github.com/prs-eth/point2cad
  • STEP / IGES: neutral CAD data-exchange formats, importable by virtually every CAD application (FreeCAD, SolidWorks, ...).
You’ve reached the end of this manual.Explore the library →