- 支持
Windows
和Linux
系统 - 通过
lua
脚本语言构造三维模型 - 可导出
STL
,STEP
,IGES
格式的文件
-
Windows 11 23H2
- CMake 3.24.0-rc1
- Visual Studio 17 2022
- vcpkg(2024-10-18)
- qt5 5.15.15
- opencascade 7.8.1
- sol2 3.3.1
- lua 5.4.7
-
Ubuntu 22.04.5 LTS(WSL)
- CMake 3.31.0
- c++ (Ubuntu 11.4.0-1ubuntu1~22.04)
- vcpkg(2022.02.02-8233-g813a241fb)[qt5,lua,sol2,opencascade]
依赖包安装
vcpkg install qt5
vcpkg install lua
vcpkg install sol2
vcpkg install opencascade
生成程序
cd (your_workspace)/JellyCAD
mkdir build
cd build
cmake .. . -DCMAKE_TOOLCHAIN_FILE=(your_vcpkg_dir)/scripts/buildsystems/vcpkg.cmake
cmake --build
jellycad -f file.lua
- 鼠标左键平移
- 鼠标右键旋转
- 鼠标滚轮缩放
- 新建:Ctrl+N
- 打开:Ctrl+O
- 保存:Ctrl+S
Lua 5.4 Reference Manual - contents
show
在3D界面显示单个或多个模型,export_stl
/export_step
/export_iges
分别导出对应格式的文件
以下8个形状均继承shape
基类
box
/cylinder
/cone
/sphere
创建类型SOLID
的三维模型edge
创建边缘,支持lin
(line),圆弧circ
(circle),elips
(ellipse),hypr
(hyperbola),parab
(parabola)类型的边缘wire
创建线,polygon
创建多边形的线face
创建面
基类shape
实现的方法:
构造函数可导入step
和stl
文件,如s=shape.new('flank.stl');
type
返回形状类型,格式为字符串fuse
融合cut
剪切common
共有部分fillet
圆角chamfer
倒角translate
相对平移rotate
相对旋转locate
位置和姿态定位color
设置颜色transparency
设置透明度prism
拉伸操作- 拉伸形状变换:
edge->face,face->solid,wire->shell
- 拉伸形状变换:
例1:绘制实体,设置位姿和颜色
print("Hello, World!");
b = box.new(0.1, 1, 1); -- create a box with dimensions 0.1 x 1 x 1
b:translate(2, 2, 0); -- translate the box by 2 units in the x, y
b:rotate(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", pos = { 2, -2, 0 }, rx = 20 });
-- 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", pos = { -2, 2, 0 }, rot = { 90, 0, 0 } });
s = sphere.new(0.5); -- create a sphere with radius 0.5
s:locate({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
例2:圆角和倒角
print("Fillet OR Chamfer");
b1=box.new(1,1,1,{color='red3',x=2,y=2});
b1:fillet(0.2,{dir='z'}); -- 圆角 r=0.2 限制条件为边缘与基坐标系的Z重合
b2=box.new(1,1,1,{color='green3',x=2,y=-2});
b2:fillet(0.2,{max={3,3,3}}); -- 圆角 r=0.2 边缘始末点同时小于 3,3,3
c=cylinder.new(0.5,1,{color='gray',x=-2,y=-2});
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});
例3:拉伸多边形
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);
例4:布尔操作
print("Boolean Operation");
c=cylinder.new(10,10);
c:cut(cylinder.new(8,10,{pos={0,0,1}}));
c:translate(20,20,0);
show(c);
s=sphere.new(10);
b=box.new(10,10,10);
s:common(b);
s:translate(-20,20,0);
show(s);
c1=cone.new(10,5,20,{color='green4'});
s1=sphere.new(10,{color='red'});
c1:fuse(s1);
c1:translate(-20,-20,0);
show(c1);
例5:导出文件
print("Export");
c=cylinder.new(10,10);
s=sphere.new(10);
c=cone.new(10,5,20,{color='green4'});
export_stl(c,'cylinder.stl',{type='ascii',radius=0.05});
export_step(s,'sphere.step');
export_iges(c,'cone.iges');
run ./JellyCAD -f scripts/5export.lua
Jelatine([email protected])
判断Edge/Wire是直线还是圆弧(wire:BRepAdaptor_CompCurve,Edge:BRepAdaptor_Curve)
fougue/mayo: 3D CAD viewer and converter based on Qt + OpenCascade