01 / 概要
草图图元的作用与适用范围
定义二维草图中的具名几何实体。它是非空扁平对象;供实体特征使用时,图元必须能恢复为闭合轮廓。
二维点使用有限数值数组 [x, y] 表示;草图图元名称在当前 sketch 中必须唯一。
图元自身不包含 operation;该字段位于外层建模步骤。
02 / 基础结构
字段结构
{
Sketch(非空对象)
├─ line_<unique_name>?: Line
├─ circle_<unique_name>?: Circle
├─ arc_<unique_name>?: Arc
├─ ellipse_<unique_name>?: Ellipse
├─ elliptical_arc_<unique_name>?: EllipticalArc
└─ nurbs_<unique_name>?: Nurbs
约束:上述图元字段至少出现一个;同一前缀可以用不同名称出现多次。line_<x>对象由 start 和 end 两个二维端点定义。
circle_<x>对象由 center 和正 radius 定义圆心与半径。
ellipse_<x>对象包含 center、正 major、正 minor 和 angle。
arc_<x>对象包含 start、middle 和 end 三个点。
elliptical_arc_<x>对象包含端点、椭圆参数以及必填的 large_arc、sweep 布尔值。
nurbs_<x>对象包含 degree、periodic、controls;可选 weights 和 knots,存在时必须与曲线定义一致。
03 / 详细分析
线段(line_)
line_<unique_name>
├─ start: point2
└─ end: point2start是线段起点,[x, y]。
end是线段终点,[x, y]。
线段对象不含 operation;使用该草图的外层特征步骤必须另行指定 operation。
JSON 示例
{
"line_1": {
"start": [0.0, 0.0],
"end": [20.0, 0.0]
}
}04 / 详细分析
圆(circle_)
circle_<unique_name>
├─ center: point2
└─ radius: numbercenter是圆心,[x, y]。
radius是正半径。
圆对象不含 operation;operation 属于外层特征步骤。
JSON 示例
{
"circle_1": {
"center": [5.0, 5.0],
"radius": 2.0
}
}05 / 详细分析
圆弧(arc_)
圆弧由依次位于弧上的起点、中间点和终点确定;三个点必须能确定预期的非退化圆弧。
arc_<unique_name>
├─ start: point2
├─ middle: point2
└─ end: point2start是圆弧起点。
middle是位于预期弧段内部的中间点。
end是圆弧终点。
圆弧对象不含 operation;operation 属于外层特征步骤。
JSON 示例
{
"arc_1": {
"start": [0.0, 0.0],
"middle": [5.0, 5.0],
"end": [10.0, 0.0]
}
}06 / 详细分析
椭圆(ellipse_)
ellipse_<unique_name>
├─ center: point2
├─ major: number
├─ minor: number
└─ angle: numbercenter是椭圆中心。
major是正的长轴半径。
minor是正的短轴半径。
angle是椭圆方向角,单位为度。
椭圆对象不含 operation;operation 属于外层特征步骤。
JSON 示例
{
"ellipse_1": {
"center": [0.0, 0.0],
"major": 10.0,
"minor": 5.0,
"angle": 30.0
}
}07 / 详细分析
椭圆弧(elliptical_arc_)
elliptical_arc_<unique_name>
├─ start: point2
├─ end: point2
├─ major: number
├─ minor: number
├─ angle: number
├─ large_arc: boolean
└─ sweep: booleanstart是椭圆弧起点。
end是椭圆弧终点。
major是正的长轴半径。
minor是正的短轴半径。
angle是椭圆方向角,单位为度。
large_arc是大弧选择标志。
sweep是扫掠方向选择标志。
椭圆弧对象不含 operation;operation 属于外层特征步骤。
JSON 示例
{
"elliptical_arc_1": {
"start": [10.0, 0.0],
"end": [-10.0, 0.0],
"major": 10.0,
"minor": 5.0,
"angle": 0.0,
"large_arc": false,
"sweep": true
}
}08 / 详细分析
NURBS 曲线(nurbs_)
nurbs_<unique_name>
├─ degree: integer
├─ periodic: boolean
├─ controls: point2[]
├─ weights?: number[]
└─ knots?: number[]degree是曲线次数;控制点数量必须足以支持该次数。
periodic是是否为周期曲线。
controls是按曲线定义顺序排列的控制点数组。
weights否权重数组;存在时必须与控制点数量一致并符合曲线定义。
knots否节点向量;存在时长度和取值必须符合次数、控制点与周期性定义。
NURBS 对象不含 operation;operation 属于外层特征步骤。
JSON 示例
{
"nurbs_1": {
"degree": 3,
"periodic": false,
"controls": [[0.0, 0.0], [3.0, 5.0], [7.0, 5.0], [10.0, 0.0]],
"weights": [1.0, 1.0, 1.0, 1.0],
"knots": [0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0]
}
}09 / 样例数据
完整结构化 JSON 样例
{
"sketch": {
"line_1": {"start": [0.0, 0.0], "end": [40.0, 0.0]},
"circle_1": {"center": [20.0, 20.0], "radius": 10.0},
"ellipse_1": {
"center": [60.0, 20.0],
"major": 20.0,
"minor": 10.0,
"angle": 30.0
},
"arc_1": {
"start": [0.0, 30.0],
"middle": [10.0, 45.0],
"end": [20.0, 30.0]
},
"elliptical_arc_1": {
"start": [30.0, 30.0],
"end": [60.0, 30.0],
"major": 20.0,
"minor": 10.0,
"angle": 0.0,
"large_arc": false,
"sweep": true
},
"nurbs_1": {
"degree": 3,
"periodic": false,
"controls": [[0.0, 60.0], [10.0, 75.0], [20.0, 75.0], [30.0, 60.0]],
"weights": [1.0, 1.0, 1.0, 1.0],
"knots": [0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0]
}
}
}