feat: cad_mcp_aec 增加爬梯工具,query 支持 climb_stair

第 4 项(按 sys/*.mnu 扩工具)的第一步:从菜单命令里筛出一类参数清晰的实体先做通。

- 新增 add_aec_climb_stair / update_aec_climb_stair(AecDbClimbStair,对应菜单命令
  PL_ZXPT 直爬梯、PL_YHZT 圆护爬梯)。建模序列照抄 pool3dcmdCmd.cpp:5742 的命令实现:
  SetSection(踏管直径) -> SetBaseCurve(底->顶) -> SetClimbStairData(参数体),
  再写专业数据 2dStyle / 朝向(KEY_MAJBR)。工具直接收两个端点,不需要复现
  "放置点+朝向"那套偏移算法。
  参数:start/end、width、cage_diameter、height、bottom_elevation、type(0/1)、
  bar_diameter、step_height、step_spacing、wall_distance、facing、material、layer。
- query_aec_entities / get_aec_entity_detail 支持 climb_stair(读 GetClimbStairData)。
- mcp_config.json 增加这两个工具(40 -> 42),query 的 type 枚举补 climb_stair。

实测(AutoCAD 2020 / R230 Debug):
- tools/list = 42;add_aec_climb_stair 建出 handle 3A0(宽 450 / 护笼 700 / 高 3000);
- get_aec_entity_detail 读回 type=0/width=450/cage=700/height=3000/bar=20/step=300;
- update 改 width=600、step_height=250 后读回一致;query type=climb_stair 命中 1 条。
This commit is contained in:
company-desktop committed 2026-10-29 23:56:19 +08:00
1 parent caafe7c2b5
commit 25e09eec58
3 files changed
+1326 -934

No files matched your search

File diff suppressed because it is too large. Load diff
@@ -17,6 +17,7 @@
#include "AecDbSlab.h"
#include "AecDbColumn.h"
#include "AecDbBeam.h"
#include "AecDbClimbStair.h"
#include "AecDbObjXDataMap.h"
using namespace aec_mcp;
@@ -29,6 +30,7 @@ const char* kTypeWall = "wall";
const char* kTypeSlab = "slab";
const char* kTypeColumn = "column";
const char* kTypeBeam = "beam";
const char* kTypeClimb = "climb_stair";
// 实体 -> 五个受支持类型之一;不是这几类返回空串
std::string supportedTypeOf(AcDbEntity* pEnt)
@@ -41,6 +43,7 @@ std::string supportedTypeOf(AcDbEntity* pEnt)
if (AecDbXSlab::cast(pEnt)) return kTypeSlab;
if (AecDbColumn::cast(pEnt)) return kTypeColumn;
if (AecDbBeam::cast(pEnt)) return kTypeBeam;
if (AecDbClimbStair::cast(pEnt)) return kTypeClimb;
return std::string();
}
@@ -141,6 +144,26 @@ nlohmann::json paramsOf(AcDbEntity* pEnt, const std::string& sType)
p["width"] = rc.y;
p["rotation_deg"] = pCol->GetRotation() * 180.0 / PI;
}
else if (sType == kTypeClimb)
{
AecDbClimbStair* pStair = AecDbClimbStair::cast(pEnt);
ClimbStair data;
::memset(&data, 0, sizeof(ClimbStair));
if (pStair != NULL)
{
pStair->GetClimbStairData(data);
p["type"] = data.nType;
p["cage_diameter"] = data.dD;
p["width"] = data.dW;
p["height"] = data.dH;
p["bottom_elevation"] = data.dBomEl;
p["step_height"] = data.dSteepH;
p["step_spacing"] = data.dSegSp;
p["wall_distance"] = data.dSpWall;
p["bar_diameter"] = data.dd;
p["material"] = acharToUtf8(data.m_sMaterial);
}
}
else if (sType == kTypeBeam)
{
AecDbBeam* pBeam = AecDbBeam::cast(pEnt);
@@ -203,7 +226,7 @@ public:
return nlohmann::json::parse(R"({
"type": "object",
"properties": {
"type": { "type": "string", "enum": [ "all", "pipe", "wall", "slab", "column", "beam" ],
"type": { "type": "string", "enum": [ "all", "pipe", "wall", "slab", "column", "beam", "climb_stair" ],
"description": "要列出的类型,缺省 all" },
"space": { "type": "string", "description": "空间名:Model 或布局名,缺省 Model" },
"limit": { "type": "integer", "description": "最多返回多少条,缺省 200,上限 1000" },
+161 -2
View File
@@ -1123,7 +1123,7 @@
},
{
"name": "query_aec_entities",
"description": "列出本插件支持的 Envi3D 自定义实体(管道/墙/板/柱/梁),分页返回 total/returned/offset/items,每项含 handle、类型、图层、起终点、包围盒。改图之前先用它拿 handle。",
"description": "列出本插件支持的 Envi3D 自定义实体(管道/墙/板/柱/梁/爬梯),分页返回 total/returned/offset/items,每项含 handle、类型、图层、起终点、包围盒。改图之前先用它拿 handle。",
"inputSchema": {
"type": "object",
"properties": {
@@ -1135,7 +1135,8 @@
"wall",
"slab",
"column",
"beam"
"beam",
"climb_stair"
],
"description": "要列出的类型,缺省 all"
},
@@ -1734,6 +1735,164 @@
"dll_name": "cad_mcp_aec.dll",
"factory_function": "UpdateAecBeamTool"
}
},
{
"name": "add_aec_climb_stair",
"description": "新建爬梯(AecDbClimbStair,对应菜单命令 直爬梯/圆护爬梯)。给梯段底部点与顶部点,以及梯宽、护笼直径、总高;其余按对话框缺省。尺寸用图纸单位。",
"inputSchema": {
"type": "object",
"properties": {
"start": {
"type": "array",
"items": {
"type": "number"
},
"description": "梯段底部点 [x,y] 或 [x,y,z]"
},
"end": {
"type": "array",
"items": {
"type": "number"
},
"description": "梯段顶部点"
},
"width": {
"type": "number",
"description": "梯宽(缺省 450)"
},
"cage_diameter": {
"type": "number",
"description": "护笼总直径(缺省 700)"
},
"height": {
"type": "number",
"description": "总高,不给则用 end.z-start.z"
},
"bottom_elevation": {
"type": "number",
"description": "底标高,缺省 0"
},
"type": {
"type": "integer",
"description": "0=圆护直梯(缺省)1=圆护凸爬"
},
"bar_diameter": {
"type": "number",
"description": "踏管直径(缺省 20)"
},
"step_height": {
"type": "number",
"description": "踏步高(缺省 300)"
},
"step_spacing": {
"type": "number",
"description": "踏棍间距(缺省 300)"
},
"wall_distance": {
"type": "number",
"description": "距墙距离(缺省 180)"
},
"facing": {
"type": "array",
"items": {
"type": "number"
},
"description": "人面对的方向 [x,y],缺省 +Y"
},
"material": {
"type": "string",
"description": "材质"
},
"layer": {
"type": "string",
"description": "图层,缺省 LAY_CSTAIR"
},
"space": {
"type": "string",
"description": "空间:Model 或布局名,缺省 Model"
}
},
"required": [
"start",
"end"
]
},
"backend": {
"type": "c++_dll",
"dll_name": "cad_mcp_aec.dll",
"factory_function": "AddAecClimbStairTool"
}
},
{
"name": "update_aec_climb_stair",
"description": "修改已有爬梯:只传要改的字段(端点、梯宽、护笼直径、总高、踏步、材质…)。",
"inputSchema": {
"type": "object",
"properties": {
"handle": {
"type": "string"
},
"start": {
"type": "array",
"items": {
"type": "number"
},
"description": "新起点(可选)"
},
"end": {
"type": "array",
"items": {
"type": "number"
},
"description": "新终点(可选)"
},
"width": {
"type": "number"
},
"cage_diameter": {
"type": "number"
},
"height": {
"type": "number"
},
"bottom_elevation": {
"type": "number"
},
"type": {
"type": "integer"
},
"bar_diameter": {
"type": "number"
},
"step_height": {
"type": "number"
},
"step_spacing": {
"type": "number"
},
"wall_distance": {
"type": "number"
},
"facing": {
"type": "array",
"items": {
"type": "number"
},
"description": "新朝向(可选)"
},
"material": {
"type": "string"
}
},
"required": [
"handle"
]
},
"backend": {
"type": "c++_dll",
"dll_name": "cad_mcp_aec.dll",
"factory_function": "UpdateAecClimbStairTool"
}
}
]
}