JSON 契约¶
机器可读 Schema:schema.json。
数据契约。十九行响应足以描述一棵有序、参数化的特征树。
信封与特征树¶
信封¶
响应可以是单个特征:
{
"feature_type": "extrude",
"name": "Cylinder",
"params": {
"plane": "前视基准面",
"shape": "circle",
"diameter": 50,
"depth": 100
}
}
也可以是有序的多特征模型:
{
"model_name": "Mounting plate",
"features": [
{
"feature_type": "extrude",
"name": "Base",
"params": {
"plane": "前视基准面",
"shape": "rectangle",
"length": 200,
"width": 100,
"depth": 20
}
},
{
"feature_type": "cut",
"name": "Hole 1",
"params": {
"plane": "前视基准面",
"shape": "circle",
"diameter": 10,
"depth": 20,
"through_all": true,
"center_x": 90,
"center_y": 40
}
}
]
}
这里只展示四个孔中的一个;完整响应会重复 cut 特征,填入其余三个角的坐标。
特征类型¶
| 类型 | 用途 | 关键参数 |
|---|---|---|
extrude |
创建基体或添加材料。 | plane、shape、depth;可选 end_condition(blind 或 mid_plane)、depth2、plane_offset、seed |
cut / hole |
从当前实体移除材料。 | plane、shape、depth,除非 through_all / through_next;可选 end_condition、depth2、plane_offset、seed、thread、hole_style、fit |
revolve |
让偏离旋转轴的轮廓绕轴旋转。 | plane、shape、轮廓尺寸,以及偏离轴的 center_x 或 center_y |
fillet |
对选中的边倒圆。 | radius;可选 edges |
chamfer |
对选中的边等距倒角。 | distance;可选 edges |
linear_pattern |
沿指定方向重复当前实体。 | direction、count、spacing;可选 count2、spacing2、seed、flip |
circular_pattern |
绕指定轴重复当前实体。 | axis、count、angle;可选 equal_spacing、seed、flip |
mirror |
按基准面镜像当前实体。 | plane;可选 seed、merge |
shell |
按壁厚抽壳。 | thickness;可选 remove_faces、outward |
draft |
对选定面施加拔模角。 | angle;可选 faces、neutral_plane、propagation |
sweep |
沿路径扫掠圆形轮廓。 | diameter、path_length;可选 path_plane、path_shape |
loft |
在两个截面之间放样。 | height、profile1、profile2;可选 plane |
rib |
由开放草图生成筋。 | thickness、length;可选 plane、center_x、center_y、draft_angle、two_sided |
counterbore |
生成沉孔。 | hole_diameter、counterbore_diameter(更大)、counterbore_depth;通孔 depth 或 through_all |
countersink |
生成埋头孔。 | hole_diameter、countersink_diameter(更大)、可选 countersink_angle;通孔 depth 或 through_all |
hole_array |
生成一排相同的孔。 | diameter(或 thread)、count、spacing;可选 hole_style、fit、direction、angle;通孔 depth 或 through_all |
sketch |
绘制自由草图,供后续拉伸/切除引用。 | plane、segments;可选 plane_offset、closed |
note |
添加工程图注释,仅工程图。 | text;可选 x、y、height |
insert_component |
插入零件或子装配,仅装配体。 | path(.sldprt 或 .sldasm);可选 x、y、z、fixed |
drawing_view |
在工程图插入模型视图,仅工程图。 | model_path(.sldprt 或 .sldasm);可选 view、x、y、scale |
base_flange |
创建钣金基体法兰,仅零件。 | plane、shape、形状尺寸、thickness;可选 radius、plane_offset、center_x、center_y、reverse |
edit_dimension |
修改已存在的驱动尺寸。 | dimension(上下文中的精确 full_name)、value(毫米);可选 target |
配置(configurations)¶
零件族请求可以在 features 旁增加顶层 configurations 数组:
{
"features": [
{
"feature_type": "extrude",
"name": "Base",
"params": {
"plane": "前视基准面",
"shape": "rectangle",
"length": 100,
"width": 60,
"depth": 20
}
}
],
"configurations": [
{ "name": "L80", "overrides": { "Base.length": 80 } },
{ "name": "W40", "overrides": { "Base.width": 40 } }
]
}
name唯一,最多 128 个字符;一次最多 20 个配置。overrides将"特征名.参数"映射到毫米值;被引用特征必须有name。- 支持的角色:
extrude矩形length/width、extrude圆diameter、cut/hole圆diameter。 - 客户端在基础特征树建好后逐个创建配置、激活、只在该配置内改尺寸、重建,最后切回基础配置。
- 回滚会删除本次创建的配置,以及特征和尺寸修改。
特征模式¶
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
feature_type |
string | 是 | 特征类型表中的任一类型 |
name |
string | 否 | 用于日志和配置覆盖键的可读名称 |
configurations |
array | 否 | features 的顶层同级字段;尺寸驱动配置 |
configurations[].name |
string | 是 | 唯一配置名,最多 128 个字符 |
configurations[].overrides |
object | 是 | Feature.parameter 到毫米值,不能为空 |
params.model_path |
string | 仅 drawing_view |
.sldprt 或 .sldasm 的完整路径 |
params.view |
string | 否 | 视图方向:front(默认)、back、left、right、top、bottom、isometric、trimetric、dimetric、current |
params.scale |
number | 否 | 工程图视图比例 0.01–100;省略时使用图纸比例 |
params.plane |
string | 草图特征必填 | 请求的基准面;支持前视、上视、右视 |
params.shape |
string | 草图特征必填 | circle、rectangle、polygon、ellipse 或 slot |
params.depth |
number | blind / mid_plane 必填;through_all / through_next 可省略 |
深度,毫米 |
params.through_all |
boolean | 否 | end_condition=through_all 的旧版快捷字段;为 true 时双向切除 |
params.end_condition |
string | 否 | extrude 支持 blind(默认)或 mid_plane;切除还支持 through_all 或 through_next |
params.depth2 |
number | 否 | 双向盲特征的第二方向深度;不能与 mid_plane 同时使用 |
params.plane_offset |
number | 否 | 沿基准面法向的偏移,毫米,可正可负 |
params.seed |
string | 否 | 引用 sketch 特征的名称;使用时省略 plane 与 shape |
params.thread |
string | 否 | 标准米制螺纹:M3–M24;替代 diameter |
params.hole_style |
string | 否 | clearance(默认)或 tapped(底孔) |
params.fit |
string | 否 | 间隙孔配合:close、normal(默认)、loose |
params.segments |
array | 仅 sketch |
线段、圆弧、圆或折线,毫米 |
params.closed |
boolean | 否 | 自动闭合自由草图轮廓 |
params.edges |
string | 否 | 圆角/倒角边筛选:all(默认)、axis_x、axis_y、axis_z 或 circular |
params.center_x |
number | 多孔切除、旋转轮廓 | 草图中心在第一个草图轴上的坐标,毫米 |
params.center_y |
number | 多孔切除、旋转轮廓 | 草图中心在第二个草图轴上的坐标,毫米 |
params.thickness |
number | 仅 base_flange |
钣金厚度,毫米;抽壳使用自己的 thickness |
params.radius |
number | 仅圆角 | 圆角半径或钣金折弯半径,毫米 |
params.reverse |
boolean | 否 | 钣金基体法兰反向加厚 |
params.distance |
number | 仅倒角 | 等距倒角距离,毫米;作用于选中的边 |
params.angle |
number | 否 | 旋转角度,度;默认 360 |
params.axis |
string | 否 | 旋转轴,x 或 y;默认 y |
params.draft_angle |
number | 否 | 拉伸/切除的拔模角度,度 |
params.dimension |
string | 仅 edit_dimension |
context.features[].dimensions 中的精确 full_name |
params.value |
number | 仅 edit_dimension |
新尺寸值,毫米 |
params.target |
string | 否 | 所属特征名,仅用于说明 |
草图形状参数¶
| 形状 | 必填字段 | 说明 |
|---|---|---|
circle |
diameter |
毫米 |
rectangle |
length、width |
以 center_x、center_y 为中心 |
polygon |
diameter、sides |
sides 限制在 3–100 |
ellipse |
major_axis、minor_axis |
毫米 |
slot |
length、width |
直槽口;宽度即两端圆弧直径 |
补充特征参数:
revolve: 轮廓必须偏离旋转轴。把center_x或center_y设为非零值,可选axis为x或y,angle为 1 到 360 度。end_condition/depth2:blind使用depth;mid_plane关于草图面对称;切除还支持through_all和through_next,两者忽略depth;提供depth2时盲特征变为双向特征。单实体上through_next无法解析下一面时,会退化为完全贯穿切除。plane_offset: 在基准面法向创建平行偏移面并在其上草图;extrude与cut/hole均支持,正负偏移沿基准面法向。fillet: 必填radius;对选中的边应用等半径圆角。edges默认all;axis_x、axis_y、axis_z按模型轴向选边,circular选择圆形边。chamfer: 必填distance;使用同样的edges筛选对选中的边应用等距倒角。draft_angle:extrude和cut可选,单位为度,范围 -89 到 89。edit_dimension: 修改已存在的驱动尺寸。dimension必须是context.features[].dimensions中的精确full_name;客户端负责解析、重建并记录旧值,以便回滚恢复。不要用它表示新特征。sketch: 用segments(line、arc、circle或polyline)绘制自由轮廓。给草图设置name;extrude/cut用seed引用它并省略plane/shape。closed会自动补上闭合线段。thread/hole_style/fit: 标准米制孔。间隙孔按 ISO 273(fit选择 close/normal/loose);tapped使用常用粗牙底孔直径。暂不生成装饰螺纹,只切出正确的孔几何。configurations: 尺寸驱动零件族。每项命名一个 SolidWorks 配置,并按"特征名.参数"覆盖轮廓尺寸;仅支持extrude矩形length/width、extrude圆diameter、cut/hole圆diameter。配置在基础树之后创建,回滚会删除。drawing_view: 在当前工程图插入已保存模型的视图。model_path必须是存在的.sldprt或.sldasm;view选择标准方向。客户端会打开模型读取其本地化标准视图名,因此兼容中文、英文和法文 SolidWorks。工程图视图暂不参与模型特征回滚。base_flange: 用与拉伸相同的闭合轮廓创建钣金基体法兰。thickness必填;radius默认等于厚度。SolidWorks 同时生成钣金与平板型式特征。边线法兰与焊件尚未实现。linear_pattern/circular_pattern/mirror/shell/draft: 作用于当前实体。seed可引用同一响应中前面特征的name,客户端会映射到 SolidWorks 实际生成的特征名。sweep: 使用diameter指定的圆形轮廓,路径画在path_plane上;path_shape为line或arc,path_length单位为毫米。loft: 两个截面分别位于plane与相距height毫米的偏移面上;profile1、profile2使用与草图特征相同的形状字段。rib:length是所选基准面上草图线段的长度;direction为该平面内的x或y,默认y;two_sided默认true。线段必须横跨型腔,两端接触已有壁面。
关系型与高级特征¶
| 类型 | 必填参数 | 可选参数 |
|---|---|---|
linear_pattern |
direction、count、spacing |
seed、count2、spacing2、flip |
circular_pattern |
axis、count、angle |
seed、equal_spacing、flip |
mirror |
plane |
seed、merge |
shell |
thickness |
remove_faces、outward |
draft |
angle |
faces、neutral_plane、propagation |
sweep |
diameter、path_length |
path_plane、path_shape、path_center_x、path_center_y |
loft |
height、profile1、profile2 |
plane |
rib |
thickness、length |
plane、center_x、center_y、direction、draft_angle、two_sided |
seed 匹配同一响应中前面特征的 name,客户端会映射到 SolidWorks 实际生成的特征名。sweep 使用圆形轮廓,path_shape 为 line 或 arc。loft 会在 plane 的 height 毫米偏移处自动创建基准面。rib 的草图线段必须横跨型腔,两端接触已有壁面。
{
"features": [
{ "feature_type": "extrude", "name": "Base", "params": { "plane": "前视基准面", "shape": "rectangle", "length": 120, "width": 80, "depth": 12 } },
{ "feature_type": "extrude", "name": "Boss", "params": { "plane": "前视基准面", "shape": "circle", "diameter": 16, "depth": 10, "center_x": -30, "center_y": 0 } },
{ "feature_type": "mirror", "name": "Boss mirror", "params": { "seed": "Boss", "plane": "right" } }
]
}
坐标与单位¶
- 前视基准面: 草图轴为 X、Y;
center_x对应 X,center_y对应 Y。 - 上视基准面: 草图轴为 X、Z;
center_y对应 Z,且必须落在基体厚度内。 - 右视基准面: 草图轴为 Y、Z;
center_x对应 Y,center_y对应 Z。 - 多特征模型: 先读取基体的
length、width、depth,再计算后续坐标。不要把多个相同特征堆在(0, 0)。 - 单位: JSON 中所有尺寸均为毫米;建模器在 COM 边界转换为米。
实现说明¶
当前 release 建模器会把草图绘制到请求的基准面,并能在中文、英文、法文界面中解析前视、上视、右视。对于四角孔,当用户用中文或英文明确要求“四角”“4个”“四个”“4通孔”或“four corners”时,客户端还会在前视 X/Y 坐标中按 ±(length / 2 − 10) 与 ±(width / 2 − 10) 自动分配孔位。