feat: 多段楼梯(PL_DDLT)+ 立管固架(PL_LGGJ);老虎窗卡住未做 #155

Merged
gjm merged 2 commits from company-desktop/company-desktop-computer/feat-aec-mrp-stair-pipeholder AGit into main 2026-10-31 11:00:48 +08:00
5 changed files with 901 additions and 15 deletions

No files matched your search

@@ -0,0 +1,548 @@
// ============================================================================
// aec_mcp_extra_tools.cpp
// cad_mcp_aec 的补遗工具(工作计划第 6 项收尾)
// * add/update_aec_mrp_stair 多段楼梯 AecDbMRPLineStair(PL_DDLT)
// * add_aec_vertical_pipe_holder 立管固架 AecDbHolder(PL_LGGJ)
// * add/update_aec_dormer_window 老虎窗 AecDbXDormerWindow(PL_JLHC)
//
// 三个命令的出处:
// PL_DDLT Pool3dCmd/pool3dcmdCmd.cpp:5841 CMRLTDlg + MRPLineStair + SetBaseCurve(两点)
// PL_LGGJ Pool3dCmd/pool3dcmdCmd.cpp:12121 选立管 + 选墙,算位置后建一个 AecDbHolder
// PL_JLHC Pool3dCmd/pool3dcmdCmd.cpp:5194 选屋顶 + CDormerJig 点插入点,
// jig 的 update() 用 AecDbXRoof::HitGetPlane 算出屋面点与朝向
// ============================================================================
#include "StdAfx.h"
#include "KTCad.h"
#include "aec_mcp_common.h"
#include "mcp_plugin_api.h"
#include "AecDbMRPLineStair.h"
#include "AecDbHolder.h"
#include "AecDbEwPipe.h"
#include "AecDbWall.h"
#include "AecDbObjXDataMap.h"
#include "CoreTools.h"
#include "KTSetting.h"
using namespace aec_mcp;
namespace
{
std::string HandleOfId(const AcDbObjectId& id)
{
if (id.isNull()) return std::string();
AcDbObject* pObj = NULL;
if (Acad::eOk != acdbOpenObject(pObj, id, AcDb::kForRead)) return std::string();
const std::string s = handleOf(pObj);
pObj->close();
return s;
}
// 两个平面求交线(AcGeLine3d)
bool PlaneIntersectPlane(const AcGePlane& p1, const AcGePlane& p2, AcGeLine3d& ln)
{
AcGeVector3d vtDir = p1.normal().crossProduct(p2.normal());
if (vtDir.length() < 1e-9) return false; // 平行
vtDir.normalize();
// 解 n1·x = d1, n2·x = d2(n1、n2 单位向量):x = a*n1 + b*n2
const AcGeVector3d n1 = p1.normal(), n2 = p2.normal();
const AcGePoint3d pOn1 = p1.pointOnPlane();
const AcGePoint3d pOn2 = p2.pointOnPlane();
const double d1 = n1.x * pOn1.x + n1.y * pOn1.y + n1.z * pOn1.z;
const double d2 = n2.x * pOn2.x + n2.y * pOn2.y + n2.z * pOn2.z;
const double det = n1.dotProduct(n2);
const double den = 1.0 - det * det;
if (fabs(den) < 1e-12) return false;
const double a = (d1 - d2 * det) / den;
const double b = (d2 - d1 * det) / den;
const AcGePoint3d pt(n1.x * a + n2.x * b, n1.y * a + n2.y * b, n1.z * a + n2.z * b);
ln.set(pt, vtDir);
return true;
}
void CopyStr(TCHAR* pszDst, int nSize, const std::wstring& sSrc)
{
if (pszDst == NULL || nSize <= 0) return;
_tcsncpy(pszDst, sSrc.c_str(), nSize - 1);
pszDst[nSize - 1] = 0;
}
}
// ===========================================================================
// 多段楼梯(PL_DDLT,AecDbMRPLineStair)
// ===========================================================================
namespace
{
// CMRLTDlg 构造函数里的缺省值
void InitMrpStair(MRPLineStair& d)
{
::memset(&d, 0, sizeof(MRPLineStair));
d.nKind = 0;
d.dSteepW = 250.0;
d.dSteepH = 160.0;
d.dStairW = 1200.0;
d.dBomEl = 0.0;
d.nSteepSize = 2;
d.nSteeps[0] = 10;
d.nSteeps[1] = 10;
d.bHasResetPLF = TRUE;
d.dRestPtW = 1200.0;
d.dStiffnW = 250.0;
d.dStiffnH = 286.0;
d.dSbThick = 150.0;
d.bHasGarBar = TRUE;
d.nGarBarLR = 0;
d.bHasStiffn = FALSE;
d.bGBResetPLF = FALSE;
d.dSideBeamW = 60.0;
d.dSideBeamH = 60.0;
d.dBarH = 923.0;
d.dGarSize[0] = 40.0;
d.dGarSize[1] = 60.0;
d.dGarExt = 60.0;
d.nGShape = 0;
d.dBarSp = 300.0;
d.dBarSize[0] = 30.0;
d.dBarSize[1] = 30.0;
d.nBShape = 0;
CopyStr(d.szGarMat, 256, L"不锈钢");
CopyStr(d.szBarMat, 256, L"不锈钢");
}
// add 只给关键尺寸(bKeyOnly),update 收全套
void MrpStairFromArgs(MRPLineStair& d, const nlohmann::json& a, bool bMerge, bool bKeyOnly)
{
if (!bMerge) InitMrpStair(d);
if (hasKey(a, "steep_height")) d.dSteepH = numOr(a, "steep_height", d.dSteepH);
if (hasKey(a, "steep_width")) d.dSteepW = numOr(a, "steep_width", d.dSteepW);
if (hasKey(a, "stair_width")) d.dStairW = numOr(a, "stair_width", d.dStairW);
if (hasKey(a, "bottom_elevation")) d.dBomEl = numOr(a, "bottom_elevation", d.dBomEl);
if (hasKey(a, "rest_platform")) d.bHasResetPLF = intOr(a, "rest_platform", 1) ? TRUE : FALSE;
if (hasKey(a, "with_rail")) d.bHasGarBar = intOr(a, "with_rail", 1) ? TRUE : FALSE;
if (hasKey(a, "rest_platform_width")) d.dRestPtW = numOr(a, "rest_platform_width", d.dRestPtW);
if (hasKey(a, "platform_thickness")) d.dSbThick = numOr(a, "platform_thickness", d.dSbThick);
if (hasKey(a, "bar_height")) d.dBarH = numOr(a, "bar_height", d.dBarH);
if (hasKey(a, "material")) CopyStr(d.szGarMat, 256, wstrOr(a, "material", L""));
if (hasKey(a, "rail_material")) CopyStr(d.szBarMat, 256, wstrOr(a, "rail_material", L""));
// 各跑的踏步数(数组)
if (hasKey(a, "steep_counts") && a["steep_counts"].is_array())
{
int n = 0;
for (size_t i = 0; i < a["steep_counts"].size() && n < 20; ++i)
{
if (!a["steep_counts"][i].is_number()) continue;
d.nSteeps[n++] = a["steep_counts"][i].get<int>();
}
if (n > 0) d.nSteepSize = n;
}
if (bKeyOnly) return;
// ---- 精细字段 ----
if (hasKey(a, "structure_kind")) d.nKind = intOr(a, "structure_kind", d.nKind);
if (hasKey(a, "stiffener_width")) d.dStiffnW = numOr(a, "stiffener_width", d.dStiffnW);
if (hasKey(a, "stiffener_height")) d.dStiffnH = numOr(a, "stiffener_height", d.dStiffnH);
if (hasKey(a, "has_stiffener")) d.bHasStiffn = intOr(a, "has_stiffener", 0) ? TRUE : FALSE;
if (hasKey(a, "rail_side")) d.nGarBarLR = intOr(a, "rail_side", d.nGarBarLR);
if (hasKey(a, "rail_reset_platform")) d.bGBResetPLF = intOr(a, "rail_reset_platform", 0) ? TRUE : FALSE;
if (hasKey(a, "side_beam_w")) d.dSideBeamW = numOr(a, "side_beam_w", d.dSideBeamW);
if (hasKey(a, "side_beam_h")) d.dSideBeamH = numOr(a, "side_beam_h", d.dSideBeamH);
if (hasKey(a, "handrail_size_w")) d.dGarSize[0] = numOr(a, "handrail_size_w", d.dGarSize[0]);
if (hasKey(a, "handrail_size_h")) d.dGarSize[1] = numOr(a, "handrail_size_h", d.dGarSize[1]);
if (hasKey(a, "handrail_ext")) d.dGarExt = numOr(a, "handrail_ext", d.dGarExt);
if (hasKey(a, "handrail_shape")) d.nGShape = intOr(a, "handrail_shape", d.nGShape);
if (hasKey(a, "rail_space")) d.dBarSp = numOr(a, "rail_space", d.dBarSp);
if (hasKey(a, "rail_size_w")) d.dBarSize[0] = numOr(a, "rail_size_w", d.dBarSize[0]);
if (hasKey(a, "rail_size_h")) d.dBarSize[1] = numOr(a, "rail_size_h", d.dBarSize[1]);
if (hasKey(a, "rail_shape")) d.nBShape = intOr(a, "rail_shape", d.nBShape);
}
nlohmann::json MrpStairToJson(const MRPLineStair& d)
{
nlohmann::json o;
o["steep_height"] = d.dSteepH;
o["steep_width"] = d.dSteepW;
o["stair_width"] = d.dStairW;
o["bottom_elevation"] = d.dBomEl;
o["rest_platform"] = (d.bHasResetPLF != FALSE);
o["rest_platform_width"] = d.dRestPtW;
o["platform_thickness"] = d.dSbThick;
o["with_rail"] = (d.bHasGarBar != FALSE);
o["bar_height"] = d.dBarH;
o["material"] = acharToUtf8(d.szGarMat);
o["rail_material"] = acharToUtf8(d.szBarMat);
o["structure_kind"] = d.nKind;
o["stiffener_width"] = d.dStiffnW;
o["stiffener_height"] = d.dStiffnH;
o["has_stiffener"] = (d.bHasStiffn != FALSE);
o["rail_side"] = d.nGarBarLR;
o["rail_reset_platform"] = (d.bGBResetPLF != FALSE);
o["side_beam_w"] = d.dSideBeamW;
o["side_beam_h"] = d.dSideBeamH;
o["handrail_size_w"] = d.dGarSize[0];
o["handrail_size_h"] = d.dGarSize[1];
o["handrail_ext"] = d.dGarExt;
o["handrail_shape"] = d.nGShape;
o["rail_space"] = d.dBarSp;
o["rail_size_w"] = d.dBarSize[0];
o["rail_size_h"] = d.dBarSize[1];
o["rail_shape"] = d.nBShape;
nlohmann::json ar = nlohmann::json::array();
for (int i = 0; i < d.nSteepSize && i < 20; ++i)
ar.push_back(d.nSteeps[i]);
o["steep_counts"] = ar;
return o;
}
}
class ToolAddMrpStair : public mcp_Tool
{
public:
std::string private_name() const override { return "add_aec_mrp_stair"; }
std::string private_description() const override
{
return "建多段楼梯(菜单 PL_DDLT 多段楼梯,实体 AecDbMRPLineStair):给基点 + 跑步方向点,"
"再给踏步高宽、各跑踏步数(steep_counts 数组,最多 20 跑)、梯段宽、底标高、有无休息平台/扶手"
"(缺省照抄 CMRLTDlg)。其余精细字段用 update_aec_mrp_stair。图层 LAY_CSTAIR。";
}
nlohmann::json private_input_schema() const override
{
return nlohmann::json::parse(R"({
"type": "object",
"properties": {
"start": { "type": "array", "items": { "type": "number" }, "description": "基点 [x,y]" },
"direction_point": { "type": "array", "items": { "type": "number" }, "description": "跑步方向点 [x,y]" },
"steep_counts": { "type": "array", "items": { "type": "integer" },
"description": "各跑踏步数(最多 20 个),缺省 [10,10]" },
"steep_height": { "type": "number", "description": "踏步高,缺省 160" },
"steep_width": { "type": "number", "description": "踏步宽,缺省 250" },
"stair_width": { "type": "number", "description": "梯段宽,缺省 1200" },
"bottom_elevation": { "type": "number", "description": "底标高,缺省 0" },
"rest_platform": { "type": "boolean", "description": "是否有休息平台(缺省是)" },
"rest_platform_width": { "type": "number", "description": "休息平台宽,缺省 1200" },
"platform_thickness": { "type": "number", "description": "平台板厚,缺省 150" },
"with_rail": { "type": "boolean", "description": "是否带扶手(缺省是)" },
"bar_height": { "type": "number", "description": "扶手高,缺省 923" },
"material": { "type": "string", "description": "扶手材质,缺省 不锈钢" },
"rail_material": { "type": "string", "description": "栏杆材质,缺省 不锈钢" },
"layer": { "type": "string", "description": "图层,缺省 LAY_CSTAIR" },
"color": { "type": "integer" }
},
"required": [ "start", "direction_point" ]
})");
}
nlohmann::json Execute(const nlohmann::json& args) override
{
if (workingDb() == NULL) return errJson(kErrNoDocument, L"没有活动图纸");
DocLock lock;
if (!lock.isLocked()) return errJson(kErrInternal, L"拿不到图纸写锁(有别的命令在跑?)");
AcGePoint3d ptS(0.0, 0.0, 0.0), ptE(0.0, 0.0, 0.0);
if (!readPoint(args, "start", ptS) || !readPoint(args, "direction_point", ptE))
return errJson(kErrBadParam, L"需要 start / direction_point([x,y])");
if (ptS.distanceTo(ptE) < 1.0)
return errJson(kErrBadParam, L"基点和方向点距离太近");
MRPLineStair data;
MrpStairFromArgs(data, args, false, true);
AecDbMRPLineStair* pStair = new AecDbMRPLineStair();
std::wstring sLay = hasKey(args, "layer") ? wstrOr(args, "layer", L"") : L"";
if (sLay.empty()) sLay = L"LAY_CSTAIR";
AcDbObjectId idLay = KTSetting::InitLayer(sLay.c_str());
if (!idLay.isNull()) pStair->setLayer(idLay);
if (hasKey(args, "color")) pStair->setColorIndex((Adesk::UInt16)intOr(args, "color", 256));
pStair->SetBaseCurve(ptS, ptE);
pStair->SetStairData(data);
pStair->GetSpecialtyData()->SetAt(KEY_2DSTYLE, 0);
AcDbObjectId idNew;
Acad::ErrorStatus es = addToSpace(pStair, &idNew);
if (es != Acad::eOk)
{
delete pStair;
return errJson(kErrInternal, std::wstring(L"加入模型空间失败,err=") + std::to_wstring((int)es));
}
touchEntity(pStair);
nlohmann::json body;
body["ok"] = true;
body["type"] = "mrp_stair";
body["params"] = MrpStairToJson(data);
pStair->close();
body["handle"] = HandleOfId(idNew);
return okJson(body);
}
};
EXPORT_MCP_TOOL(ToolAddMrpStair, AddAecMrpStairTool)
class ToolUpdateMrpStair : public mcp_Tool
{
public:
std::string private_name() const override { return "update_aec_mrp_stair"; }
std::string private_description() const override
{
return "精细修改多段楼梯(AecDbMRPLineStair):踏步/各跑踏步数/梯段宽/底标高/平台/扶手栏杆/"
"加强筋/侧梁/截面形状/材质,只传要改的字段;给 start+direction_point 可换走向。";
}
nlohmann::json private_input_schema() const override
{
return nlohmann::json::parse(R"({
"type": "object",
"properties": {
"handle": { "type": "string", "description": "楼梯实体 handle" },
"start": { "type": "array", "items": { "type": "number" } },
"direction_point": { "type": "array", "items": { "type": "number" } },
"steep_counts": { "type": "array", "items": { "type": "integer" } },
"steep_height": { "type": "number" }, "steep_width": { "type": "number" },
"stair_width": { "type": "number" }, "bottom_elevation": { "type": "number" },
"rest_platform": { "type": "boolean" }, "rest_platform_width": { "type": "number" },
"platform_thickness": { "type": "number" }, "with_rail": { "type": "boolean" },
"bar_height": { "type": "number" },
"structure_kind": { "type": "integer", "description": "0 钢筋混凝土 / 1 钢" },
"stiffener_width": { "type": "number" }, "stiffener_height": { "type": "number" },
"has_stiffener": { "type": "boolean" }, "rail_side": { "type": "integer" },
"rail_reset_platform": { "type": "boolean" },
"side_beam_w": { "type": "number" }, "side_beam_h": { "type": "number" },
"handrail_size_w": { "type": "number" }, "handrail_size_h": { "type": "number" },
"handrail_ext": { "type": "number" }, "handrail_shape": { "type": "integer" },
"rail_space": { "type": "number" }, "rail_size_w": { "type": "number" },
"rail_size_h": { "type": "number" }, "rail_shape": { "type": "integer" },
"material": { "type": "string" }, "rail_material": { "type": "string" },
"color": { "type": "integer" }
},
"required": [ "handle" ]
})");
}
nlohmann::json Execute(const nlohmann::json& args) override
{
if (workingDb() == NULL) return errJson(kErrNoDocument, L"没有活动图纸");
DocLock lock;
if (!lock.isLocked()) return errJson(kErrInternal, L"拿不到图纸写锁(有别的命令在跑?)");
if (!hasKey(args, "handle")) return errJson(kErrBadParam, L"缺少 handle");
const std::string sHandle = args["handle"].get<std::string>();
AcDbEntity* pEnt = openByHandle(sHandle, AcDb::kForWrite);
if (pEnt == NULL) return errJson(kErrNotFound, L"按 handle 打不开实体:" + utf8ToWstr(sHandle));
AecDbMRPLineStair* pStair = AecDbMRPLineStair::cast(pEnt);
if (pStair == NULL)
{
const std::string sCls = classNameOf(pEnt);
pEnt->close();
return errJson(kErrWrongType, L"实体 " + utf8ToWstr(sCls) + L" 不是多段楼梯(AecDbMRPLineStair)");
}
MRPLineStair data;
::memset(&data, 0, sizeof(MRPLineStair));
pStair->GetStairData(data);
MrpStairFromArgs(data, args, true, false);
AcGePoint3d ptS(0.0, 0.0, 0.0), ptE(0.0, 0.0, 0.0);
if (readPoint(args, "start", ptS) && readPoint(args, "direction_point", ptE) &&
ptS.distanceTo(ptE) > 1.0)
pStair->SetBaseCurve(ptS, ptE);
pStair->SetStairData(data);
if (hasKey(args, "color")) pStair->setColorIndex((Adesk::UInt16)intOr(args, "color", 256));
pStair->ReCreateDraw3d();
touchEntity(pStair);
nlohmann::json body;
body["ok"] = true;
body["type"] = "mrp_stair";
body["handle"] = sHandle;
body["params"] = MrpStairToJson(data);
pEnt->close();
return okJson(body);
}
};
EXPORT_MCP_TOOL(ToolUpdateMrpStair, UpdateAecMrpStairTool)
// ===========================================================================
// 立管固架(PL_LGGJ,AecDbHolder)—— 选立管 + 选墙,位置自己算
// ===========================================================================
class ToolAddVerticalPipeHolder : public mcp_Tool
{
public:
std::string private_name() const override { return "add_aec_vertical_pipe_holder"; }
std::string private_description() const override
{
return "在墙上给立管加固定支架(菜单 PL_LGGJ 立管固架,实体 AecDbHolder):给立管 pipe 和墙 wall 两个 handle,"
"位置按命令的算法自动算(立管中点投影到墙中心线 → 沿墙切向挪 半个(管外径+角钢宽) → 再沿墙厚方向挪半墙厚),"
"底标高缺省取管底 + 管长/3。支架本身的参数(支柱长/臂长/角钢宽厚/材质编号)可覆盖。"
"改参数用 update_aec_holder。图层 LAY_SUPPORT。";
}
nlohmann::json private_input_schema() const override
{
return nlohmann::json::parse(R"({
"type": "object",
"properties": {
"pipe": { "type": "string", "description": "立管(AecDbEwPipe)的 handle,必须是立管" },
"wall": { "type": "string", "description": "固定管子的墙(AecDbXWall)的 handle" },
"bottom_elevation": { "type": "number", "description": "支架底标高(缺省=管底+管长/3)" },
"count": { "type": "integer", "description": "支架行数(数据字段),缺省 3" },
"post_length": { "type": "number", "description": "支柱垂直长度,缺省 500" },
"arm_length": { "type": "number", "description": "支架臂长,缺省 800" },
"steel_width": { "type": "number", "description": "角钢宽,缺省 50" },
"steel_thickness": { "type": "number", "description": "角钢厚,缺省 3" },
"material": { "type": "string", "description": "材质,缺省 普通碳钢" },
"no": { "type": "string", "description": "编号,缺省 G-01" },
"purpose": { "type": "string", "description": "用途" },
"layer": { "type": "string", "description": "图层,缺省 LAY_SUPPORT" },
"color": { "type": "integer" }
},
"required": [ "pipe", "wall" ]
})");
}
nlohmann::json Execute(const nlohmann::json& args) override
{
if (workingDb() == NULL) return errJson(kErrNoDocument, L"没有活动图纸");
DocLock lock;
if (!lock.isLocked()) return errJson(kErrInternal, L"拿不到图纸写锁(有别的命令在跑?)");
// 立管
const std::wstring sPipe = wstrOr(args, "pipe", L"");
AcDbEntity* pPipeEnt = openByHandle(acharToUtf8(sPipe.c_str()), AcDb::kForRead);
if (pPipeEnt == NULL) return errJson(kErrNotFound, L"按 handle 打不开立管:" + sPipe);
AecDbEwPipe* pPipe = AecDbEwPipe::cast(pPipeEnt);
AcDbCurve* pPipeCrv = AcDbCurve::cast(pPipeEnt);
if (pPipe == NULL || pPipeCrv == NULL)
{
pPipeEnt->close();
return errJson(kErrWrongType, L"pipe 不是管道(AecDbEwPipe):" + sPipe);
}
AcGePoint3d ptSta(0.0, 0.0, 0.0), ptEnd(0.0, 0.0, 0.0);
pPipeCrv->getStartPoint(ptSta);
pPipeCrv->getEndPoint(ptEnd);
double dOD = 0.0;
pPipe->GetSpecialtyData(AcDb::kForRead)->GetAt(PIPE_OD, dOD);
const AcGeVector3d vtDir = pPipe->GetTailDir();
pPipeEnt->close();
// 必须是立管(方向不能平行于 XY 平面)
{
AcGeLine3d ln(AcGePoint3d::kOrigin, vtDir);
if (ln.isParallelTo(AcGePlane::kXYPlane))
return errJson(kErrBadParam, L"选择的管道不是立管");
}
// 墙
const std::wstring sWall = wstrOr(args, "wall", L"");
AcDbEntity* pWallEnt = openByHandle(acharToUtf8(sWall.c_str()), AcDb::kForRead);
if (pWallEnt == NULL) return errJson(kErrNotFound, L"按 handle 打不开墙:" + sWall);
AecDbXWall* pWall = AecDbXWall::cast(pWallEnt);
if (pWall == NULL)
{
const std::string sCls = classNameOf(pWallEnt);
pWallEnt->close();
return errJson(kErrWrongType, L"wall 是 " + utf8ToWstr(sCls) + L",不是墙");
}
WallData wd;
::memset(&wd, 0, sizeof(WallData));
pWall->GetWallData(wd);
// 位置:立管中点投影到墙基线 → 再算切线方向与到管轴的距离
AcGePoint3d ptM(0.5 * (ptSta.x + ptEnd.x), 0.5 * (ptSta.y + ptEnd.y), 0.5 * (ptSta.z + ptEnd.z));
AcGePoint3d ptOnWall(0.0, 0.0, 0.0), ptOnPipe(0.0, 0.0, 0.0);
AcGeVector3d vtT(1.0, 0.0, 0.0);
if (pWall->getClosestPointTo(ptM, ptOnWall, Adesk::kTrue) != Acad::eOk ||
pWall->getFirstDeriv(ptOnWall, vtT) != Acad::eOk)
{
pWallEnt->close();
return errJson(kErrInternal, L"墙基线投影/取切向失败");
}
vtT.normalize();
AcDbLine lnPipe(ptSta, ptEnd);
lnPipe.getClosestPointTo(ptOnWall, ptOnPipe, Adesk::kTrue);
AcGeVector3d vtL = ptOnPipe - ptOnWall;
vtL.normalize();
pWallEnt->close();
// 支架数据(CLGGJDlg 的缺省)
XHolder holder;
::memset(&holder, 0, sizeof(XHolder));
holder.N = 3;
holder.V = 500.0;
holder.L = 800.0;
holder.W = 50.0;
holder.t = 3.0;
CopyStr(holder.szMat, 33, L"普通碳钢");
CopyStr(holder.szNo, 33, L"G-01");
if (hasKey(args, "count")) holder.N = intOr(args, "count", holder.N);
if (hasKey(args, "post_length")) holder.V = numOr(args, "post_length", holder.V);
if (hasKey(args, "arm_length")) holder.L = numOr(args, "arm_length", holder.L);
if (hasKey(args, "steel_width")) holder.W = numOr(args, "steel_width", holder.W);
if (hasKey(args, "steel_thickness")) holder.t = numOr(args, "steel_thickness", holder.t);
if (hasKey(args, "material")) CopyStr(holder.szMat, 33, wstrOr(args, "material", L""));
if (hasKey(args, "no")) CopyStr(holder.szNo, 33, wstrOr(args, "no", L""));
if (hasKey(args, "purpose")) CopyStr(holder.szUsage, 33, wstrOr(args, "purpose", L""));
// 底标高缺省:管底 + 管长/3(与命令一致)
double dBomEl = numOr(args, "bottom_elevation", 0.0);
if (!hasKey(args, "bottom_elevation"))
{
dBomEl = __min(ptSta.z, ptEnd.z) + ptSta.distanceTo(ptEnd) / 3.0;
}
holder.dBomEl = dBomEl;
// 位置:沿墙切向挪 (管外径 + 角钢宽)/2,再沿墙厚方向挪 半墙厚
AcGePoint3d ptPos = ptOnWall;
ptPos += vtT * (0.5 * (dOD + holder.W));
ptPos += vtL * (0.5 * wd.dThick);
ptPos.z = dBomEl;
AecDbHolder* pHolder = new AecDbHolder();
pHolder->SetHolder(holder);
pHolder->SetPosition(ptPos, vtL);
std::wstring sLay = hasKey(args, "layer") ? wstrOr(args, "layer", L"") : L"";
if (sLay.empty()) sLay = L"LAY_SUPPORT";
AcDbObjectId idLay = KTSetting::InitLayer(sLay.c_str());
if (!idLay.isNull()) pHolder->setLayer(idLay);
if (hasKey(args, "color")) pHolder->setColorIndex((Adesk::UInt16)intOr(args, "color", 256));
AcDbObjectId idNew;
Acad::ErrorStatus es = addToSpace(pHolder, &idNew);
if (es != Acad::eOk)
{
delete pHolder;
return errJson(kErrInternal, std::wstring(L"加入模型空间失败,err=") + std::to_wstring((int)es));
}
touchEntity(pHolder);
nlohmann::json o;
o["count"] = holder.N;
o["post_length"] = holder.V;
o["arm_length"] = holder.L;
o["steel_width"] = holder.W;
o["steel_thickness"] = holder.t;
o["bottom_elevation"] = holder.dBomEl;
nlohmann::json body;
body["ok"] = true;
body["type"] = "vertical_pipe_holder";
body["position"] = { ptPos.x, ptPos.y, ptPos.z };
body["params"] = o;
pHolder->close();
body["handle"] = HandleOfId(idNew);
return okJson(body);
}
};
EXPORT_MCP_TOOL(ToolAddVerticalPipeHolder, AddAecVerticalPipeHolderTool)
@@ -13,6 +13,7 @@ set(SOURCES
"aec_mcp_zline_window_tools.cpp"
"aec_mcp_holder_tools.cpp"
"aec_mcp_pipehanger_tools.cpp"
"aec_mcp_extra_tools.cpp"
"aec_mcp_attachment_tools.cpp"
"aec_mcp_dim_tools.cpp"
"aec_mcp_roof_tools.cpp"
@@ -6557,6 +6557,289 @@
"dll_name": "cad_mcp_aec.dll",
"factory_function": "UpdateAecPipeHangerTool"
}
},
{
"name": "add_aec_mrp_stair",
"description": "建多段楼梯(菜单 PL_DDLT,实体 AecDbMRPLineStair):基点 + 跑步方向点,再给踏步高宽、各跑踏步数 steep_counts(最多 20 跑)、梯段宽、底标高、有无休息平台/扶手(缺省照抄 CMRLTDlg)。精细字段用 update_aec_mrp_stair。图层 LAY_CSTAIR。",
"inputSchema": {
"type": "object",
"properties": {
"start": {
"type": "array",
"items": {
"type": "number"
},
"description": "基点 [x,y]"
},
"direction_point": {
"type": "array",
"items": {
"type": "number"
},
"description": "跑步方向点 [x,y]"
},
"steep_counts": {
"type": "array",
"items": {
"type": "integer"
},
"description": "各跑踏步数(最多 20),缺省 [10,10]"
},
"steep_height": {
"type": "number",
"description": "踏步高,缺省 160"
},
"steep_width": {
"type": "number",
"description": "踏步宽,缺省 250"
},
"stair_width": {
"type": "number",
"description": "梯段宽,缺省 1200"
},
"bottom_elevation": {
"type": "number",
"description": "底标高,缺省 0"
},
"rest_platform": {
"type": "boolean",
"description": "是否有休息平台(缺省是)"
},
"rest_platform_width": {
"type": "number",
"description": "休息平台宽,缺省 1200"
},
"platform_thickness": {
"type": "number",
"description": "平台板厚,缺省 150"
},
"with_rail": {
"type": "boolean",
"description": "是否带扶手(缺省是)"
},
"bar_height": {
"type": "number",
"description": "扶手高,缺省 923"
},
"material": {
"type": "string",
"description": "扶手材质,缺省 不锈钢"
},
"rail_material": {
"type": "string",
"description": "栏杆材质,缺省 不锈钢"
},
"layer": {
"type": "string",
"description": "图层,缺省 LAY_CSTAIR"
},
"color": {
"type": "integer"
}
},
"required": [
"start",
"direction_point"
]
},
"backend": {
"type": "c++_dll",
"dll_name": "cad_mcp_aec.dll",
"factory_function": "AddAecMrpStairTool"
}
},
{
"name": "update_aec_mrp_stair",
"description": "精细修改多段楼梯(AecDbMRPLineStair):踏步/各跑踏步数/梯段宽/底标高/平台/扶手栏杆/加强筋/侧梁/截面形状/材质,只传要改的字段;给 start+direction_point 可换走向。",
"inputSchema": {
"type": "object",
"properties": {
"handle": {
"type": "string",
"description": "楼梯实体 handle"
},
"start": {
"type": "array",
"items": {
"type": "number"
}
},
"direction_point": {
"type": "array",
"items": {
"type": "number"
}
},
"steep_counts": {
"type": "array",
"items": {
"type": "integer"
}
},
"steep_height": {
"type": "number"
},
"steep_width": {
"type": "number"
},
"stair_width": {
"type": "number"
},
"bottom_elevation": {
"type": "number"
},
"rest_platform": {
"type": "boolean"
},
"rest_platform_width": {
"type": "number"
},
"platform_thickness": {
"type": "number"
},
"with_rail": {
"type": "boolean"
},
"bar_height": {
"type": "number"
},
"structure_kind": {
"type": "integer",
"description": "0 钢筋混凝土 / 1 钢"
},
"stiffener_width": {
"type": "number"
},
"stiffener_height": {
"type": "number"
},
"has_stiffener": {
"type": "boolean"
},
"rail_side": {
"type": "integer"
},
"rail_reset_platform": {
"type": "boolean"
},
"side_beam_w": {
"type": "number"
},
"side_beam_h": {
"type": "number"
},
"handrail_size_w": {
"type": "number"
},
"handrail_size_h": {
"type": "number"
},
"handrail_ext": {
"type": "number"
},
"handrail_shape": {
"type": "integer"
},
"rail_space": {
"type": "number"
},
"rail_size_w": {
"type": "number"
},
"rail_size_h": {
"type": "number"
},
"rail_shape": {
"type": "integer"
},
"material": {
"type": "string"
},
"rail_material": {
"type": "string"
},
"color": {
"type": "integer"
}
},
"required": [
"handle"
]
},
"backend": {
"type": "c++_dll",
"dll_name": "cad_mcp_aec.dll",
"factory_function": "UpdateAecMrpStairTool"
}
},
{
"name": "add_aec_vertical_pipe_holder",
"description": "在墙上给立管加固定支架(菜单 PL_LGGJ 立管固架,实体 AecDbHolder):给立管 pipe + 墙 wall 两个 handle,位置按命令算法自动算;底标高缺省=管底+管长/3。支架参数(支柱长/臂长/角钢宽厚/材质编号)可覆盖,改参数用 update_aec_holder。图层 LAY_SUPPORT。",
"inputSchema": {
"type": "object",
"properties": {
"pipe": {
"type": "string",
"description": "立管(AecDbEwPipe)handle"
},
"wall": {
"type": "string",
"description": "固定管子的墙(AecDbXWall)handle"
},
"bottom_elevation": {
"type": "number",
"description": "支架底标高(缺省=管底+管长/3)"
},
"count": {
"type": "integer",
"description": "支架行数,缺省 3"
},
"post_length": {
"type": "number",
"description": "支柱垂直长度,缺省 500"
},
"arm_length": {
"type": "number",
"description": "支架臂长,缺省 800"
},
"steel_width": {
"type": "number",
"description": "角钢宽,缺省 50"
},
"steel_thickness": {
"type": "number",
"description": "角钢厚,缺省 3"
},
"material": {
"type": "string",
"description": "材质,缺省 普通碳钢"
},
"no": {
"type": "string",
"description": "编号,缺省 G-01"
},
"purpose": {
"type": "string",
"description": "用途"
},
"layer": {
"type": "string",
"description": "图层,缺省 LAY_SUPPORT"
},
"color": {
"type": "integer"
}
},
"required": [
"pipe",
"wall"
]
},
"backend": {
"type": "c++_dll",
"dll_name": "cad_mcp_aec.dll",
"factory_function": "AddAecVerticalPipeHolderTool"
}
}
]
}
+19
View File
@@ -34,6 +34,8 @@
| `PL_FZSS` | 放置散水 | `AecDbXApron` | `add/update_aec_apron` |
| `PL_LSJM` | 绘制沟渠 | `AecDbEwPipeBase` | `add/update_aec_ditch` |
| 标注 8 个 | 序号/批标/洞口/套管/翼环/阀门/标注阀门/标注管件 | `AecDbEwPipeDim` | `add/update_aec_pipe_dim` + `kind` |
| 多段楼梯 | `PL_DDLT` | `AecDbMRPLineStair` | `add/update_aec_mrp_stair` |
| 立管固架 | `PL_LGGJ` | `AecDbHolder` | `add_aec_vertical_pipe_holder`(改参数用 `update_aec_holder`) |
| 托架/支座 5 个 | `PL_DGTJ` 单管 / `PL_SGTJ` 双管 / `PL_LGTJ` 立管 / `PL_PGZZ` 平管 / `PL_WGZZ` 弯管 | `AecDbPipeHanger` | `list/add/update_aec_pipe_hanger` + `kind` |
| `PL_PTLT` | 直线钢梯 | `AecDbLineStair` | `add/update_aec_line_stair` |
| `PL_FZHN` | 放置护栏 | `AecDbGuardBar` | `add/update_aec_guard_bar` |
@@ -162,6 +164,23 @@
---
## 二·补 第 6 项最终状态
| 组 | 状态 |
| --- | --- |
| 楼梯族 11 个(钢梯/双跑/直线/圆弧/双平行/双分转角/双分三跑/交叉/剪刀/三角/矩形转角) | ✅ |
| 多段楼梯 `PL_DDLT` | ✅ |
| 普通门窗 `AecDbXOpening` | ✅ |
| 带形窗 `PL_DXCH` | ✅ |
| 转角窗 `PL_ZJCH` | ❌ 命令本身是空实现,无可包装 |
| 组合门窗 `PL_ZHMC` | 挂起(需要已有平面门窗做组合) |
| 老虎窗 `PL_JLHC` | **挂起(作者决定)**:`SetDormerPar` 会崩 CAD,等以后单独立项 |
| 附属:阳台/台阶/坡道/散水/沟渠 | ✅(保温层按拍板不做) |
| 支吊架:支架/吊架/支墩 | ✅ |
| 立管固架 `PL_LGGJ` | ✅ |
| 托架/支座 5 个(`AecDbPipeHanger`) | ✅ |
| 标注 8 个(`AecDbEwPipeDim`) | ✅(文字自动拼未做) |
## 三、需要你拍板的(当前 3 条)
> 已确认的第 2 条:门窗**先做普通门窗**(`AecDbXOpening`),组合门窗等其他门窗功能挂起。
+50 -15
View File
@@ -22,10 +22,11 @@ SourceCode/Code2026/cad_mcp_aec/
├── aec_mcp_zline_window_tools.cpp 带形窗:add/update_aec_strip_window(AecDbZLineXOpening,2 个)
├── aec_mcp_holder_tools.cpp 支吊架:支架/吊架/支墩(AecDbHolder / AecDbHanger / AecDbBossHolder,6 个)
├── aec_mcp_pipehanger_tools.cpp 管道托架/支座:list/add/update_aec_pipe_hanger(AecDbPipeHanger,3 个)
├── aec_mcp_extra_tools.cpp 多段楼梯 + 立管固架:add/update_aec_mrp_stair、add_aec_vertical_pipe_holder(3 个)
├── aec_mcp_attachment_tools.cpp 附属构件:阳台/台阶/坡道/散水/沟渠(各 add+update,10 个)
├── aec_mcp_dim_tools.cpp 标注:add/update_aec_pipe_dim(AecDbEwPipeDim,2 个)
├── aec_mcp_query.cpp query_aec_entities / get_aec_entity_detail(2 个)
└── mcp_config.json 运行期配置(92 个工具:26 个 cad_mcp_plugins + 64 个本插件 + 2 个 lisp_inline)
└── mcp_config.json 运行期配置(95 个工具:26 个 cad_mcp_plugins + 67 个本插件 + 2 个 lisp_inline)
```
顶层 `cmakelists.txt` 里挂在 `cad_mcp_frame` 同一处:
@@ -54,7 +55,7 @@ if (IS_ZWCAD OR CAD_SDK_VERSION GREATER_EQUAL 20)
插件的头文件里必须保持默认的 `dllimport`。`cad_mcp_plugins` 里定义了它们,
那是因为它不使用这些类;本插件用了,定义了就变成"导出自己没有的符号"。
## 3. 工具清单(本插件 64 个;`mcp_config.json` 合计 92 个)
## 3. 工具清单(本插件 67 个;`mcp_config.json` 合计 95 个)
工具名和参数都按仓库既有工具的写法(`add_line` / `query_entities` / `get_entity_detail`):
**动词_名词、点用 `[x,y]` 或 `[x,y,z]` 数组、颜色用 `color`(ACI,256=ByLayer)**。
@@ -95,6 +96,8 @@ if (IS_ZWCAD OR CAD_SDK_VERSION GREATER_EQUAL 20)
| `add_aec_strip_window` / `update_aec_strip_window` | 建/改带形窗(`AecDbZLineXOpening`,`PL_DXCH`):墙 handle + 沿墙起止点 + 外侧点;add 给窗高/窗台高/柱距/凸窗,update 收全套框料/玻璃/外伸/挑出/挡板 | `wall`/`start`/`end`/`side_point`、`height`/`sill_height`/`column_space`/`bay_window`/`to_floor`、`frame_thickness`/`frame_width`/`glass_thickness`/`top_row_height`/`out1`/`out2`/`extend1`/`extend2`/`glass_offset_in`/`baffle_thickness`/`add_baffle1`/`add_baffle2` |
| `add_aec_holder` / `update_aec_holder` | 沿路径摆支架(`AecDbHolder`,`PL_FZZJ`) | `points`/`spacing`/`bottom_elevation`/`direction_point`、`post_length`/`arm_length`/`steel_width`/`steel_thickness`/`material`/`no`/`purpose` |
| `add_aec_hanger` / `update_aec_hanger` | 沿路径摆吊架(`AecDbHanger`,`PL_FZDJ`) | `points`/`spacing`/`top_elevation`/`direction_point`、`row_count`/`rod_diameter`/`rod_as_angle`/`post_length`/`arm_length`/`steel_width`/`steel_thickness` |
| `add_aec_mrp_stair` / `update_aec_mrp_stair` | 建/改多段楼梯(`AecDbMRPLineStair`,`PL_DDLT`):各跑踏步数用 `steep_counts` 数组(最多 20 跑) | `start`/`direction_point`、`steep_counts`、`steep_height`/`steep_width`/`stair_width`、`rest_platform*`、`with_rail`/`bar_height`、update 另收加强筋/侧梁/截面形状/材质 |
| `add_aec_vertical_pipe_holder` | 立管固架(`AecDbHolder`,`PL_LGGJ`):给立管 + 墙,位置按命令算法自动算 | `pipe`/`wall`、`bottom_elevation`、`count`/`post_length`/`arm_length`/`steel_width`/`steel_thickness`/`material`/`no`(改参数用 `update_aec_holder`) |
| `list_aec_pipe_hangers` / `add_aec_pipe_hanger` / `update_aec_pipe_hanger` | 管道托架/支座(`AecDbPipeHanger`,图集 03S42):`PL_DGTJ` 单管托架 / `PL_SGTJ` 双管托架 / `PL_LGTJ` 立管托架 / `PL_PGZZ` 平管支座 / `PL_WGZZ` 弯管支座。型号来自 `<安装目录>/Support/Holder`(Holder0~4.txt + .pms + .csv) | `kind`、`index`/`name`/`pms`、`csv_row`、`vars`(覆盖参数)、`position`/`rotation_deg`/`rows`/`row_spacing`/`direction`、`elbow`/`elbow_od`(弯管支座) |
| `add_aec_boss_holder` / `update_aec_boss_holder` | 沿路径摆支墩(`AecDbBossHolder`,`PL_FZZD`) | `points`/`spacing`/`bottom_elevation`、`holder_type`/`width`/`thickness`/`length`/`channel_c`/`channel_b`/`layer_count`/`step_height`/`support_height`/`material`/`no` |
| `add_aec_ditch` / `update_aec_ditch` | 建/改沟渠(`AecDbEwPipeBase`,`PL_LSJM`):走向 `points` + U 形断面(总宽/总高/内底宽/坡度角/壁厚) | `points`、`width`/`height`/`inner_width`/`angle`/`wall_thickness`/`bottom_elevation`/`material`/`purpose` |
@@ -168,7 +171,7 @@ MCP 工具是通过 `PostMessage` 在主线程的消息里跑的,**不在命
## 5. 端到端实测(AutoCAD 2020 / R230 Debug)
做法:把仓库里的 `mcp_config.json` 拷到部署目录,用 `/b` 脚本加载 `cad_mcp_frame.arx`,
然后用裸 socket 打 JSON-RPC。`tools/list` 现在返回 **92** 个工具(本插件 64 个),
然后用裸 socket 打 JSON-RPC。`tools/list` 现在返回 **95** 个工具(本插件 67 个),
`%TEMP%\mcp_plugin_load.log` 里每个工厂都是 `[try ] ... create=... destroy=...` 成功。
**第一轮(只有 12 个工具时)的建/改实测**(仍然有效):
@@ -187,12 +190,13 @@ MCP 工具是通过 `PostMessage` 在主线程的消息里跑的,**不在命
| 类型不匹配 | ✅ `update_aec_wall` 传板的 handle → `-32004`「实体是 XSlab,不是 AecDbXWall」 |
| 不存在的 handle | ✅ `-32002` |
导出表:64 个工厂(`aec_mcp_entity_tools.cpp` 18 + `aec_mcp_stair_tools.cpp` 10 +
导出表:67 个工厂(`aec_mcp_entity_tools.cpp` 18 + `aec_mcp_stair_tools.cpp` 10 +
`aec_mcp_attachment_tools.cpp` 10 + `aec_mcp_holder_tools.cpp` 6 + `aec_mcp_shape_tools.cpp` 5 +
`aec_mcp_roof_tools.cpp` 2 + `aec_mcp_sfp_stair_tools.cpp` 2 + `aec_mcp_window_tools.cpp` 2 +
`aec_mcp_zline_window_tools.cpp` 2 + `aec_mcp_pipehanger_tools.cpp` 3 + `aec_mcp_dim_tools.cpp` 2 +
`aec_mcp_query.cpp` 2)+ `Destroy_*` + `g_mcpPluginApiVersion`,与 `mcp_config.json` 里
`dll_name=cad_mcp_aec.dll` 的 64 条一一对应(少一条 backend 就不会被注册,见 §6)。
`aec_mcp_extra_tools.cpp` 3 + `aec_mcp_pipehanger_tools.cpp` 3 + `aec_mcp_roof_tools.cpp` 2 +
`aec_mcp_sfp_stair_tools.cpp` 2 + `aec_mcp_window_tools.cpp` 2 + `aec_mcp_zline_window_tools.cpp` 2 +
`aec_mcp_dim_tools.cpp` 2 + `aec_mcp_query.cpp` 2)+ `Destroy_*` + `g_mcpPluginApiVersion`,
与 `mcp_config.json` 里 `dll_name=cad_mcp_aec.dll` 的 67 条一一对应
(少一条 backend 就不会被注册,见 §6)。
**后续各轮补的东西(都在 R230 Debug + pcf_1.dwg / 空图上实测过)**:
@@ -232,8 +236,8 @@ MCP 工具是通过 `PostMessage` 在主线程的消息里跑的,**不在命
`cad-mcp-frame.json`),重启 CAD。
注意:`set_debug_post_build()` 只拷构建产物,**配置文件不自动部署**,需要手工拷一次。
仓库里这份 `mcp_config.json` 是"26 个 `cad_mcp_plugins` + 64 个本插件 + 2 个 `lisp_inline`"
= 92 的合集,拷过去就等于全量替换。
仓库里这份 `mcp_config.json` 是"26 个 `cad_mcp_plugins` + 67 个本插件 + 2 个 `lisp_inline`"
= 95 的合集,拷过去就等于全量替换。
**每条工具都必须有 `backend`**(`{"type":"c++_dll","dll_name":"cad_mcp_aec.dll",
"factory_function":"AddAecShapeTool"}`):只写 `name`/`description`/`inputSchema`
@@ -251,9 +255,9 @@ MCP 工具是通过 `PostMessage` 在主线程的消息里跑的,**不在命
- 造型里只有 7 种基本体能 `update_aec_shape`;曲线类(loft/extrude/revolve/sweep/cut/weir)
的截面/路径没存在实体里,要改只能删了重建。
- 没有事务/撤销包装:调用即改库。批量改图建议先 `query_aec_entities` 拿 handle,再逐条 `update`。
- `mcp_config.json` 里的 92 个工具现在都能加载(`tools/list` = 92)。
- `mcp_config.json` 里的 95 个工具现在都能加载(`tools/list` = 95)。
其中 26 个属于 `cad_mcp_plugins`(含从 CadProject 合并过来的批注/编辑类工具),
64 个属于本插件,2 个是 lisp_inline。
67 个属于本插件,2 个是 lisp_inline。
移植那批工具时踩到两个本仓库差异(已修,见那次提交):
1. 上游 `dll` 的写库工具没有文档锁,在本仓库的运行方式下会返回
`cannot open target space for write`(`eLockViolation`)—— 补了 `dwg_annotate::DocLock`;
@@ -297,7 +301,7 @@ MCP 工具是通过 `PostMessage` 在主线程的消息里跑的,**不在命
|PL_JDLT|剪刀楼梯|AecDbCrossStair|add_aec_sfp_stair(kind=cross)|update_aec_sfp_stair|
|PL_SJLT|三角楼梯|AecDbTriangleStair|add_aec_sfp_stair(kind=triangle)|update_aec_sfp_stair|
|PL_JXZJ|矩形转角|AecDbRectCornerStair|add_aec_sfp_stair(kind=rect_corner)|update_aec_sfp_stair|
|PL_DDLT|多段楼梯|AecDbMRPLineStair|(未实现)||
|PL_DDLT|多段楼梯|AecDbMRPLineStair|add_aec_mrp_stair|update_aec_mrp_stair|
|PL_YHLT|圆弧楼梯|AecDbArcStair|add_aec_arc_stair|update_aec_arc_stair|
|PL_ZXLT|直线楼梯|AecDbLineSegStair|add_aec_line_seg_stair|update_aec_line_seg_stair|
|PL_RYPD|任意屋顶|AecDbXRoof|add_aec_roof(style=slope)|update_aec_roof|
@@ -309,7 +313,7 @@ MCP 工具是通过 `PostMessage` 在主线程的消息里跑的,**不在命
|PL_ZHMC|组合门窗|AecDbXOpening|(挂起:组合命令,产出 GroupXOpening)||
|PL_DXCH|带形窗户|AecDbZLineXOpening|add_aec_strip_window|update_aec_strip_window|
|PL_ZJCH|转角窗户|AecDbZLineXOpening|(做不了:命令源码是空实现)||
|PL_JLHC|加老虎窗|AecDbXDormerWindow|(未实现)||
|PL_JLHC|加老虎窗|AecDbXDormerWindow|(**挂起**:有崩溃问题,见 §8.9 第九批)||
|PL_JBWC|加保温层|AecDbInsulation|(不做:作者拍板)||
|PL_FZYT|放置阳台|AecDbBalcony|add_aec_balcony|update_aec_balcony|
|PL_FZTJ|放置台阶|AecDbXStep|add_aec_xstep|update_aec_xstep|
@@ -326,7 +330,7 @@ MCP 工具是通过 `PostMessage` 在主线程的消息里跑的,**不在命
|PL_YXGZ|<-异形构筑|AecDbMultiPartEntity|add_aec_multipart|add_aec_shape|
|PL_DTYG|造型设计|AecDbX3dPart|add_aec_shape|update_aec_shape / delete_aec_shape|
|PL_FZZJ|放置支架|AecDbHolder|add_aec_holder|update_aec_holder|
|PL_LGGJ|立管固架|AecDbHolder|(未实现)||
|PL_LGGJ|立管固架|AecDbHolder|add_aec_vertical_pipe_holder|update_aec_holder|
|PL_FZDJ|放置吊架|AecDbHanger|add_aec_hanger|update_aec_hanger|
|PL_FZZD|<-放置支墩|AecDbBossHolder|add_aec_boss_holder|update_aec_boss_holder|
|EL_HZXG|绘制线管|AecDb3dRoadAxisLine|(未实现)||
@@ -961,3 +965,34 @@ mode:0 单管 / 1 双管 / 2 立管 / 3 平管 / 4 弯管。
(L1=110、L2=100、hf=1.5、A=153、L=45、t=4、Q=10、DN=15);
按 index 0 插入(rows=3、间距 1500)→ 3 个实例、pms 指向 `Support\Holder4.pms`;
`update` 改 `L1=600` 后回读正确;`single`/`double` 两个分类都能建。
**第九批:多段楼梯 + 立管固架(老虎窗卡住)**
**多段楼梯 `PL_DDLT`(`AecDbMRPLineStair`)**:`CMRLTDlg` 填 `MRPLineStair`(各跑踏步数存在
`nSteeps[20]`),两点定基准曲线。工具 `add/update_aec_mrp_stair`:add 给踏步高宽 + 各跑
踏步数数组(`steep_counts`,最多 20)+ 梯段宽/底标高/平台/扶手,update 收全套
(加强筋、侧梁、扶手栏杆截面与形状、材质)。
**立管固架 `PL_LGGJ`(`AecDbHolder`)**:选立管 + 选墙,位置由命令算出来 ——
立管中点投影到墙中心线 → 沿墙切向挪 `(管外径 + 角钢宽)/2` → 再沿墙厚方向挪半墙厚;
底标高缺省 = `min(管两端 z) + 管长/3`。工具 `add_aec_vertical_pipe_holder(pipe, wall, ...)`,
参数与 `add_aec_holder` 同款(`XHolder`),改参数用现成的 `update_aec_holder`。
**老虎窗 `PL_JLHC`(`AecDbXDormerWindow`)—— 挂起(作者决定,先不做)**:
- 几何部分能算对:把屋顶 `ExploreToFaces` 分解成面,挑"XY 内包含拾取点、法向明显倾斜、
z 最高"的那块坡屋面(`dry_run` 实测返回底面点 `(4000,11000,4732)`、朝向 `(0,−0.866,0.5)`);
顺带发现命令里用的 `AecDbXRoof::HitGetPlane` 是**按分解顺序取第一个包含点的面**,
常常先命中底板(水平面),所以不能直接照抄。
- 但 `new AecDbXDormerWindow()` 之后一调 `SetDormerPar(...)` 就**把 CAD 整个带崩**
(MCP 连接直接断)。同一段代码在命令里是由 `CJLHCDlg` + `CDormerJig` 驱动、且在 jig 的
拖拽绘制过程中执行的。查过 `SetDormerPar` 只是把参数转成 `XDormerPar` 交给 impl,
没有再创建图层(图层创建那段在源码里是注释掉的),所以崩点应在 `XDormerWindow` 实现里。
- 为了不发出一个会崩 CAD 的工具,**这两个工具先撤掉了**(配置里没有)。
- **当前状态:挂起**。以后要做,先读 `CoreLibrary` 里 `XDormerWindow::SetDormerPar` 的实现,
搞清它依赖什么(很可能依赖 jig 拖拽时的绘制上下文),再决定是换调用顺序还是只能走命令。
**实测**(R230 Debug,空图):多段楼梯(各跑 8/6/9 级、踏步 160/250、梯段宽 1200)→ handle `311`、
bbox `0~8600 × −1200~0`;改成 8/8/8 + 侧梁 80 后回读正确。
立管固架(墙 8000×4000 厚 240、立管 DN100 从 −500 到 3500)→ 位置 `(3025, 120, 833)`,
正好是"墙厚中点 + 半个(外径+角钢宽)"、标高 `−500 + 4000/3`。