Occt logo

Occt

Community
znlgis
occt

Use when building CAD/CAM/CAE features on OCCT 8.0.1 — TopoDS_Shape B-Rep modeling, BRepAlgoAPI/BOPAlgo booleans, BRepFilletAPI fillets, STEPControl_Reader/Writer, IGES exchange, BRepMesh_IncrementalMesh, or PythonOCC/opencascade.js; also when a boolean/fillet returns an empty shape, TopoDS_Shape copies land in the wrong place (reference semantics, use BRepBuilderAPI_Copy), or STEP loses non-ASCII attributes. OCCT: LGPL geometry kernel behind FreeCAD and KiCad.

Overview

Publisherznlgis
Repositoryopengis-skills
Skill nameocct
Stars
76
Forks
12
Bundled files
Instructions only
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by znlgis on GitHub. Read the source before you install it.

Installation

Install the Occt AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/znlgis/opengis-skills/tree/main/cad/occt
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/znlgis/opengis-skills.git /tmp/opengis-skills
mkdir -p .claude/skills
cp -r /tmp/opengis-skills/cad/occt .claude/skills/occt
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Occt in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Occt on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Occt is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

项目地址: https://github.com/Open-Cascade-SAS/OCCT

官网: https://dev.opencascade.org/

官方文档: https://dev.opencascade.org/doc/refman/html/

教程: https://dev.opencascade.org/doc/overview/html/

许可证: LGPL-2.1(带例外条款)

最新稳定版: 8.0.1(2026-07-30 发布,截至 2026-10,见 OCCT Releases)

概述

OCCT 提供:

  • 几何与拓扑:gp_* 几何基元、Geom_* 解析曲线/曲面、TopoDS_Shape(Vertex/Edge/Wire/Face/Shell/Solid/Compound)
  • 建模算法:拉伸/旋转/扫掠/放样/圆角/倒角/抽壳/布尔(BOPAlgo)
  • STEP / IGES / STL / OBJ / glTF / VRML / BREP 数据交换
  • 显示:基于 OpenGL(OCAF + AIS 应用框架)
  • 网格:BRepMesh / Triangulation
  • OCAF:CAD 数据应用框架(属性、版本、引用)
  • 跨语言绑定:OCC.js(WebAssembly)、PythonOCC、occt-rs

安装

bash
# Linux
sudo apt install libocct-foundation-dev libocct-modeling-data-dev \
    libocct-modeling-algorithms-dev libocct-data-exchange-dev \
    libocct-visualization-dev occt-misc

# macOS
brew install opencascade

# Conda(含 PythonOCC)
conda install -c conda-forge pythonocc-core

# 源码:CMake 构建(CMake ≥ 3.10;C++ 标准缺省 C++17,可用 -DBUILD_CPP_STANDARD=C++20 调高;
# VTK 默认关闭,需 -DUSE_VTK=ON 开启)

验证安装(头文件与库是否就位):

bash
ls /usr/include/opencascade/Standard_Version.hxx     # Linux 发行版包
grep -m1 OCC_VERSION_STRING /usr/include/opencascade/Standard_Version.hxx
brew --prefix opencascade                            # macOS Homebrew 安装前缀
python -c "import OCC; print(OCC.__file__)"           # pythonocc-core 可导入即装好;其内置 OCCT 版本随发行包,见 conda 包说明

pythonocc-core 的版本号与 OCCT 版本号不同步(PyPI 上最新为 0.16),升级前先确认该发行包内置的 OCCT 版本,再决定用哪套 API。

版本提示: OCCT 8.0 起有重大变更:Standard_Failure 改为继承 std::exception;Raise()/Throw()/Instance() 静态助手被移除(改用 throw 关键字);Standard_Mutex 等退役,改用 std::mutex/std::lock_guard。从 7.x 升级需留意这些破坏性变更。最新版本请参见 OCCT Releases。


核心 API:包与命名空间

包内容
gp_*数学几何基元(Pnt、Vec、Dir、Ax2、Trsf)
Geom_*参数曲线/曲面
TopoDS_*拓扑(Vertex/Edge/Wire/Face/Shell/Solid/Compound)
BRep*拓扑 + 几何接口(BRepBuilderAPI_、BRepPrimAPI_、BRepAlgoAPI_*)
BOPAlgo_*高级布尔运算
STEPControl_* / IGESControl_*数据交换
AIS_* / V3d_*显示
TDocStd_* / TDF_*OCAF 数据框架

C++ 入门:构造立方体并布尔差集

cpp
#include <BRepPrimAPI_MakeBox.hxx>
#include <BRepPrimAPI_MakeCylinder.hxx>
#include <BRepAlgoAPI_Cut.hxx>
#include <BRepFilletAPI_MakeFillet.hxx>
#include <STEPControl_Writer.hxx>
#include <TopExp_Explorer.hxx>
#include <gp_Ax2.hxx>

TopoDS_Shape box = BRepPrimAPI_MakeBox(100, 60, 30).Shape();

gp_Ax2 ax(gp_Pnt(50,30,0), gp_Dir(0,0,1));
TopoDS_Shape cyl = BRepPrimAPI_MakeCylinder(ax, 10, 50).Shape();

TopoDS_Shape result = BRepAlgoAPI_Cut(box, cyl).Shape();

// 圆角
BRepFilletAPI_MakeFillet fil(result);
for (TopExp_Explorer ex(result, TopAbs_EDGE); ex.More(); ex.Next())
    fil.Add(2.0, TopoDS::Edge(ex.Current()));
result = fil.Shape();

// STEP 导出
STEPControl_Writer w;
w.Transfer(result, STEPControl_AsIs);
w.Write("out.step");

PythonOCC

python
from OCC.Core.BRepPrimAPI import BRepPrimAPI_MakeBox, BRepPrimAPI_MakeCylinder
from OCC.Core.BRepAlgoAPI import BRepAlgoAPI_Cut
from OCC.Core.gp import gp_Ax2, gp_Pnt, gp_Dir
from OCC.Core.STEPControl import STEPControl_Writer, STEPControl_AsIs

box = BRepPrimAPI_MakeBox(100, 60, 30).Shape()
ax  = gp_Ax2(gp_Pnt(50,30,0), gp_Dir(0,0,1))
cyl = BRepPrimAPI_MakeCylinder(ax, 10, 50).Shape()
res = BRepAlgoAPI_Cut(box, cyl).Shape()

w = STEPControl_Writer()
w.Transfer(res, STEPControl_AsIs)
w.Write("out.step")

草图 → 拉伸(Wire → Face → Prism)

cpp
#include <BRepBuilderAPI_MakePolygon.hxx>
#include <BRepBuilderAPI_MakeFace.hxx>
#include <BRepPrimAPI_MakePrism.hxx>

BRepBuilderAPI_MakePolygon poly;
poly.Add(gp_Pnt(0,0,0));
poly.Add(gp_Pnt(50,0,0));
poly.Add(gp_Pnt(50,30,0));
poly.Add(gp_Pnt(0,30,0));
poly.Close();

TopoDS_Face face = BRepBuilderAPI_MakeFace(poly.Wire()).Face();
TopoDS_Shape solid = BRepPrimAPI_MakePrism(face, gp_Vec(0,0,20)).Shape();

数据交换

cpp
// STEP 读取
#include <STEPControl_Reader.hxx>
STEPControl_Reader r;
r.ReadFile("input.step");
r.TransferRoots();
TopoDS_Shape s = r.OneShape();

// IGES
#include <IGESControl_Reader.hxx>
IGESControl_Reader ir; ir.ReadFile("a.iges"); ir.TransferRoots();

// STL 写入
#include <StlAPI_Writer.hxx>
#include <BRepMesh_IncrementalMesh.hxx>
BRepMesh_IncrementalMesh(shape, 0.1);   // 网格化容差
StlAPI_Writer sw; sw.Write(shape, "out.stl");

// glTF
#include <RWGltf_CafWriter.hxx>

网格化

cpp
#include <BRepMesh_IncrementalMesh.hxx>
#include <TopLoc_Location.hxx>
#include <BRep_Tool.hxx>
#include <Poly_Triangulation.hxx>

BRepMesh_IncrementalMesh(shape, 0.1, false, 0.5);

for (TopExp_Explorer ex(shape, TopAbs_FACE); ex.More(); ex.Next()) {
    TopLoc_Location loc;
    auto tri = BRep_Tool::Triangulation(TopoDS::Face(ex.Current()), loc);
    if (tri.IsNull()) continue;
    for (int i = 1; i <= tri->NbTriangles(); ++i) {
        Standard_Integer n1, n2, n3;
        tri->Triangle(i).Get(n1, n2, n3);
        gp_Pnt p1 = tri->Node(n1).Transformed(loc);
        // ...
    }
}

opencascade.js(Web / WebAssembly)

javascript
import opencascade from 'opencascade.js';
const oc = await opencascade();
const box = new oc.BRepPrimAPI_MakeBox_2(100, 60, 30).Shape();

opencascade.js 的类名带 _N 后缀表示重载变体(如 BRepPrimAPI_MakeBox_2 对应三边长的构造),具体后缀以你绑定到的 opencascade.js 版本生成的 *.d.ts 为准——照着改前先在生成目录里搜类名。


典型工作流

工作流一:从草图到 STEP 的完整零件建模(C++)

  1. 使用 BRepBuilderAPI_MakePolygon 构建闭合多段线 → BRepBuilderAPI_MakeFace 生成面
  2. BRepPrimAPI_MakePrism(face, gp_Vec(0,0,h)) 将面拉伸为实体
  3. 对实体边应用 BRepFilletAPI_MakeFillet 添加圆角
  4. 使用 BRepAlgoAPI_Cut 等布尔操作减出孔/槽特征
  5. STEPControl_Writer 导出为 STEP 用于下游 CAM/装配
  6. 若需网格输出,BRepMesh_IncrementalMesh(shape, tolerance) → StlAPI_Writer 输出 STL

工作流二:导入 STEP 并提取几何信息

  1. STEPControl_Reader 读取 STEP 文件 → TransferRoots() → OneShape() 获取根形状
  2. ShapeFix_Shape 修复拓扑(缝合、容差统一)
  3. TopExp_Explorer 遍历 Face → BRep_Tool::Triangulation() 获取三角网格
  4. 对每个三角形遍历节点坐标,导出到自定义数据格式或渲染引擎

性能与稳定性

  1. 小数容差一致:使用 BRep_Builder.UpdateVertex(_, tol),避免布尔失败
  2. ShapeFix_Shape:导入外部 STEP 后修复
  3. BRepBuilderAPI_Sewing:缝合多张面成 Shell
  4. 使用 BOPAlgo_BOP 替代旧 BRepAlgoAPI 处理多输入并行布尔
  5. 共享内核:OSD_Parallel 启用多线程网格化
  6. Precision::Confusion() / Precision::Angular() 统一容差

常见问题

问题解决
布尔运算失败ShapeFix_Shape 修复输入;调整容差
STEP 里的中文文字/属性丢失STEP 的非 ASCII 文本走转义序列与字符集声明,读写两端口径不一致就丢字。先用 Interface_Static::Names() 列出当前版本可用的 STEP/XCAF 参数再按名设置,不要凭记忆写参数名;模型侧要保证文字实体带可用的字体子集,否则改由 XCAF 属性层携带文本
拷贝 Shape 后位置错乱注意 TopoDS_Shape 是引用,深拷贝用 BRepBuilderAPI_Copy
显示无图AIS 上下文未启动 OpenGL;检查 OCC.Display.SimpleGui
圆角/倒角偶发失败或结果吞掉相邻面半径超过局部几何可承受范围;先用 BRepOffsetAPI_MakeOffset/分析边长,再分批改半径,并保证相交的圆角顺序稳定
大装配加载慢、内存高用 XCAFDoc 装配结构 + 按需 TransferRoots,避免 OneShape() 合并成单一 Shape;配合 BRepTools::Clean 与三角网缓存
PythonOCC 与 C++ 行为不一致版本口径不同:PythonOCC 的发行版(社区构建/OCC 官方 pip 包)滞后于 OCCT C++ 版本;先打印 OCCT.Version_SimpleVersion() 再决定 API 分支

AI 使用建议

  • 推荐工作流模式:AI 助手应根据语言偏好选择 OCCT 接口——C++ 直接使用原生 API,Python 使用 PythonOCC,Web 使用 OCCT.js。建模流程遵循「构造拓扑 → 布尔/修饰 → 数据交换」的工业模式,STEP 导入后务必用 ShapeFix_Shape 修复。
  • 关键注意事项:① 布尔运算失败时用 ShapeFix_Shape 修复输入并统一容差(Precision::Confusion());② TopoDS_Shape 是引用语义,深拷贝用 BRepBuilderAPI_Copy;③ 多线程网格化用 OSD_Parallel 启用,布尔运算非线程安全;④ 外部 STEP/IGES 导入后建议走修复流程。
  • 常用代码模式:C++:BRepPrimAPI_MakeBox(gp_Pnt(0,0,0), 100, 60, 30).Shape() → BRepAlgoAPI_Cut(box, cyl).Shape() → STEPControl_Writer 导出。PythonOCC:BRepPrimAPI_MakeBox(100,60,30).Shape() → BRepAlgoAPI_Cut(box, cyl).Shape()。

相关技能


参考资源

Frequently asked questions

What does the Occt AI skill do?

Use when building CAD/CAM/CAE features on OCCT 8.0.1 — TopoDS_Shape B-Rep modeling, BRepAlgoAPI/BOPAlgo booleans, BRepFilletAPI fillets, STEPControl_Reader/Writer, IGES exchange, BRepMesh_IncrementalMesh, or PythonOCC/opencascade.js; also when a boolean/fillet returns an empty shape, TopoDS_Shape copies land in the wrong place (reference semantics, use BRepBuilderAPI_Copy), or STEP loses non-ASCII attributes. OCCT: LGPL geometry kernel behind FreeCAD and KiCad.

Why use Occt on TypingMind?

Because you install it once and use it with any model. Occt is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Occt in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/znlgis/opengis-skills/tree/main/cad/occt. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Occt?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Occt?

As many as you like. As long as a model supports skills, you can use Occt with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Occt AI skill free?

Yes. It is published on GitHub by znlgis under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇