← 返回规范概览HISTCAD JSON · V0.1

COMMON DATA

草图图元

定义二维草图中的具名几何实体。它是非空扁平对象;供实体特征使用时,图元必须能恢复为闭合轮廓。

分类
公共数据结构
序号
02
标识
sketch

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: point2
字段必选说明
start

线段起点,[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: number
字段必选说明
center

圆心,[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: point2
字段必选说明
start

圆弧起点。

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: number
字段必选说明
center

椭圆中心。

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: boolean
字段必选说明
start

椭圆弧起点。

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]
    }
  }
}