Browse by type
![]()
# JellyCAD
开源可编程 CAD 软件
现代开源可编程 CAD 软件专为程序员、机器人开发者和参数化建模爱好者设计

在 mockway_robotics 机械臂项目中,使用 JellyCAD 通过 Lua 脚本快速构建机械臂的基础结构。
JellyCAD 专为机器人开发者设计,提供完整的机器人建模与仿真工作流:
Lua 脚本建模示例

相比传统 CAD 软件手动建模后再转换为 URDF,JellyCAD 提供:
✅ 一键导出完整的 ROS 功能包结构 ✅ 自动计算惯性张量和质心位置 ✅ 支持复杂装配体的层级关系 ✅ 代码化建模便于参数化和批量生成
ROS2 + RViz 可视化

MuJoCo 物理仿真

详见示例 6 了解如何使用 JellyCAD 构建 6 自由度机械臂并导出 URDF。
JellyCAD 集成了大模型对话功能,帮助您更高效地编写 Lua 脚本:

使用方法:
Ctrl+Enter 发送,AI 将生成相应的 Lua 代码功能特点: - ✅ 支持多家主流 AI 服务商 - ✅ 代码流式生成,实时反馈 - ✅ 智能理解 JellyCAD API - ✅ 支持代码修改和优化 - ✅ 自动保存配置信息
📖 完整安装指南请参考:安装教程
使用 vcpkg 安装所需的第三方库:
vcpkg install qtbase lua sol2 opencascade
# 克隆仓库
git clone https://github.com/Jelatine/JellyCAD.git
cd JellyCAD
# 创建构建目录
mkdir build
cd build
# 配置 CMake(替换 your_vcpkg_dir 为实际路径)
cmake .. -DCMAKE_TOOLCHAIN_FILE=(your_vcpkg_dir)/scripts/buildsystems/vcpkg.cmake
# 构建项目
cmake --build .
Ubuntu 24 Emoji 显示问题
sudo apt install fonts-noto-color-emoji
运行 Lua 脚本文件:
./JellyCAD -f file.lua
执行 Lua 脚本字符串:
./JellyCAD -c "print('Hello, World!')"
./JellyCAD -c "box.new():export_stl('box.stl')"
| 操作 | 功能 |
|---|---|
| 左键拖拽 | 平移视图 |
| 右键拖拽 | 旋转视图 |
| 滚轮 | 缩放视图 |
| 快捷键 | 功能 |
|---|---|
Ctrl+N |
新建文件 |
Ctrl+S |
保存文件 |
Ctrl+F |
编辑器搜索 |
Ctrl+/ |
注释/取消注释 |
F5 |
运行当前脚本 |
| 函数 | 功能 |
|---|---|
show(shape) |
在 3D 界面显示单个或多个模型 |
所有形状类均继承自 shape 基类:
box.new(width, height, depth) - 长方体cylinder.new(radius, height) - 圆柱体cone.new(radius1, radius2, height) - 圆锥体sphere.new(radius) - 球体torus.new(majorRadius, minorRadius) - 圆环体wedge.new(dx, dy, dz, ltx) - 楔形体vertex - 顶点edge - 边缘(子类型: line、circle、ellipse、hyperbola、parabola、bezier 、bspline )wire - 线(子类型:polygon)face - 面(子类型:plane、cylindrical、conical)text - 文本s = shape.new('model.stl') -- 导入 STL 或 STEP 文件
| 方法 | 功能 |
|---|---|
copy() |
返回形状的副本 |
type() |
返回形状类型字符串 |
color(color) |
设置颜色 |
transparency(value) |
设置透明度 |
| 方法 | 功能 |
|---|---|
fuse(shape) |
融合操作(并集) |
cut(shape) |
剪切操作(差集) |
common(shape) |
相交操作(交集) |
| 方法 | 功能 |
|---|---|
fillet(radius, options) |
圆角 |
chamfer(distance, options) |
倒角 |
| 方法 | 功能 |
|---|---|
pos(x, y, z) |
绝对位置 |
x(val)/y(val)/z(val)/rx(val)/ry(val)/rz(val) |
绝对位置/姿态 |
rot(rx, ry, rz) |
绝对姿态 |
move(move_type, x, y, z) |
相对平移和旋转,move_type 为 'pos' 或 'rot' |
prism(dx, dy, dz) |
拉伸操作(edge→face、face→solid、wire→shell) |
revol(pos, dir, angle) |
旋转体生成操作 |
scale(factor) |
按比例缩放 |
| 方法 | 功能 |
|---|---|
export_stl(filename, options) |
导出 STL 格式文件 |
export_step(filename) |
导出 STEP 格式文件 |
export_iges(filename) |
导出 IGES 格式文件 |
axes.new(pose, length) - 坐标系(用于定义关节位姿)link.new(name, shape) - 机器人连杆joint.new(name, axes, type, limits) - 机器人关节| 方法 | 功能 |
|---|---|
axes:copy() |
返回坐标系副本 |
axes:move(x, y, z, rx, ry, rz) |
沿自身坐标系进行平移及RPY姿态变换 |
axes:mdh(alpha, a, d, theta) |
沿自身坐标系进行 MDH 位姿变换 |
axes:sdh(alpha, a, d, theta) |
沿自身坐标系进行 SDH 位姿变换 |
joint:next(link) |
设置下一个连杆, 返回连杆对象 |
link:add(joint) |
添加关节, 返回关节对象 |
link:export(options) |
导出 URDF/Mujoco 格式文件 |
详细的 API 参考请参考 JellyCAD 帮助文档。
print("Hello, World!");
b = box.new(0.1, 1, 1); -- create a box with dimensions 0.1 x 1 x 1
b:pos(2, 2, 0); -- translate the box by 2 units in the x, y
b:rot(0, 0, -30); -- rotate the box by -30 degrees around the z axis
-- create a cylinder with radius 1, height 1, color lightblue, position {2, -2, 0}, rotate 20 degrees around the x axis
c = cylinder.new(1, 1):color("lightblue"):rx(20):pos(2, -2, 0);
-- create a cone with radius 1, height 0.2, color gray, position {-2, 2, 0}, roll 90 degrees(RPY)
n = cone.new(1, 0.2, 2):color("#808080"):rot(90, 0, 0):pos(-2, 2, 0);
s = sphere.new(0.5); -- create a sphere with radius 0.5
s:pos(-2, -2, 0.5):rot(0, 0, 0); -- set the position and rotation of the sphere
s:color("red"); -- set the color of the sphere to red
show({b,c,n,s}); -- display the objects

print("Fillet OR Chamfer");
b1 = box.new(1, 1, 1):color('red3'):pos(2, 2, 0);
b1:fillet(0.2, { type = 'line', first = { 2, 2, 1 }, last = { 3, 2, 1 }, tol = 1e-4 }); -- 圆角 r=0.2 指定边缘始末点,容差1e-4
b2 = box.new(1, 1, 1):color('green3'):pos(2, -2, 0);
b2:fillet(0.2, { max = { 3, 3, 3 } }); -- 圆角 r=0.2 边缘始末点同时小于 3,3,3
c = cylinder.new(0.5, 1):color('gray'):pos(-2, -2, 0);
c:fillet(0.2, { type = 'circle' }); -- 圆角 r=0.2 限制条件为边缘类型是圆形
b3 = box.new(1, 1, 1):color('lightblue');
b3:chamfer(0.3, { min = { 0.5, -1, 0.5 }, max = { 9, 9, 9 } }); -- 倒角 r=0.3 边缘始末点同时大于 0.5,-1,0.5 且小于 9,9,9
show({ b1, b2, b3, c });

print('Polygon Prism')
points={{0,0,0},{0,1,0},{0.5,1,0},{0.5,1.5,0},{1.5,1.5,0},{1.5,1,0},{2,1,0},{2,0,0}};
p = polygon.new(points);
p:color("#FFF")
show(p);
f = face.new(p);
f:prism(0, 0, 1);
show(f);
print("Boolean Operation");
c=cylinder.new(10,10);
c:cut(cylinder.new(8,10):pos(0,0,1));
c:move('pos',20,20,0);
show(c);
s=sphere.new(10);
b=box.new(10,10,10);
s:common(b);
s:move('pos',-20,20,0);
show(s);
c1=cone.new(10,5,20):color('green4');
s1=sphere.new(10);
c1:fuse(s1);
c1:move('pos',-20,-20,0);
show(c1);

print("Export");
cylinder.new(10, 10):export_stl('cylinder.stl', { type = 'ascii', radian = 0.05 })
sphere.new(10):export_step('sphere.step');
cone.new(10, 5, 20):color('green4'):export_iges('cone.iges')
本项目采用 MIT 许可证 - 详见 LICENSE 文件
$ claude mcp add JellyCAD \
-- python -m otcore.mcp_server <graph>