docs: 第6项第六批(沟渠/标注/楼梯精细 update) #152

Merged
gjm merged 2 commits from company-desktop/company-desktop-computer/feat-aec-ditch-dim-stair-fine AGit into main 2026-10-31 09:57:04 +08:00
7 changed files with 1159 additions and 41 deletions

No files matched your search

@@ -25,6 +25,7 @@
#include "AecDbXApron.h"
#include "AecDbWall.h"
#include "AecDbObjXDataMap.h"
#include "CoreTools.h"
#include "KTSetting.h"
using namespace aec_mcp;
@@ -1049,3 +1050,317 @@ public:
}
};
EXPORT_MCP_TOOL(ToolUpdateApron, UpdateAecApronTool)
// ===========================================================================
// 沟渠(PL_LSJM,AecDbEwPipeBase)—— U 形断面 + 路径
// ===========================================================================
namespace
{
// 断面几何照搬 CHZGQDlg::GetSection():U 形槽,9 点闭合
// W 总宽 / H 总高 / V 内底宽 / angle 侧壁坡度角(度) / T 壁厚;断面中心在原点
AcDbRegion* BuildDitchRegion(double dW, double dH, double dV, double dAngDeg, double dT,
AcGePoint3d& ptCen, std::wstring& err)
{
if (dW <= 0.0 || dH <= 0.0 || dV <= 0.0 || dT <= 0.0)
{
err = L"沟渠需要 width / height / inner_width / wall_thickness,且都 > 0";
return NULL;
}
if (dV >= dW || dT >= dH)
{
err = L"内底宽要小于总宽、壁厚要小于总高";
return NULL;
}
AcGePoint3d ptGe[9];
ptGe[0].set(-0.5 * dW, 0.0, 0.0);
ptGe[1] = ptGe[0];
ptGe[1].y += dH;
ptGe[3].set(-0.5 * dV, dT, 0.0);
const double dA = dAngDeg * PI / 180.0;
const double dX = (dH - dT) * tan(dA);
ptGe[2] = ptGe[3];
ptGe[2].y += (dH - dT);
ptGe[2].x -= dX;
ptGe[4] = ptGe[3];
ptGe[4].x += dV;
ptGe[5] = ptGe[4];
ptGe[5].x += dX;
ptGe[5].y += (dH - dT);
ptGe[6].set(0.5 * dW, dH, 0.0);
ptGe[7].set(0.5 * dW, 0.0, 0.0);
ptGe[8] = ptGe[0];
AcDbVoidPtrArray lnPtrs;
for (int i = 0; i < 8; ++i)
lnPtrs.append(new AcDbLine(ptGe[i], ptGe[i + 1]));
AcDbRegion* pReg = CoreTools::createRegion(lnPtrs);
for (int i = 0; i < lnPtrs.length(); ++i)
delete (AcDbLine*)lnPtrs[i];
ptCen.set(0.0, 0.0, 0.0);
if (pReg == NULL && err.empty()) err = L"沟渠断面(U 形区域)生成失败";
return pReg;
}
AcDbPolyline* DitchPathOf(const nlohmann::json& a, double dElev, std::wstring& err)
{
if (!hasKey(a, "points") || !a["points"].is_array() || a["points"].size() < 2)
{
err = L"需要 points:[[x,y],...](沟渠走向,至少 2 点)";
return NULL;
}
AcDbPolyline* pPl = new AcDbPolyline((int)a["points"].size());
int nIdx = 0;
for (size_t i = 0; i < a["points"].size(); ++i)
{
const nlohmann::json& pt = a["points"][i];
if (!pt.is_array() || pt.size() < 2) continue;
pPl->addVertexAt(nIdx++, AcGePoint2d(pt[0].get<double>(), pt[1].get<double>()), 0.0, 0.0, 0.0);
}
if (nIdx < 2) { delete pPl; err = L"points 有效点少于 2 个"; return NULL; }
pPl->setElevation(dElev);
return pPl;
}
// 断面参数除了进区域,还要写进专业数据(命令里是分开写的两份)
void SetDitchXData(AecDbEwPipeBase* pPipe, const nlohmann::json& a)
{
if (hasKey(a, "width")) pPipe->GetSpecialtyData()->SetAt(KEY_W, numOr(a, "width", 0.0));
if (hasKey(a, "height")) pPipe->GetSpecialtyData()->SetAt(KEY_H, numOr(a, "height", 0.0));
if (hasKey(a, "inner_width")) pPipe->GetSpecialtyData()->SetAt(KEY_V, numOr(a, "inner_width", 0.0));
if (hasKey(a, "angle")) pPipe->GetSpecialtyData()->SetAt(KEY_Angle, numOr(a, "angle", 0.0));
if (hasKey(a, "wall_thickness")) pPipe->GetSpecialtyData()->SetAt(KEY_T, numOr(a, "wall_thickness", 0.0));
if (hasKey(a, "material")) pPipe->GetSpecialtyData()->SetAt(KEY_MATERIAL, wstrOr(a, "material", L"").c_str());
if (hasKey(a, "purpose")) pPipe->GetSpecialtyData()->SetAt(KEY_PURPOSE, wstrOr(a, "purpose", L"").c_str());
}
}
class ToolAddDitch : public mcp_Tool
{
public:
std::string private_name() const override { return "add_aec_ditch"; }
std::string private_description() const override
{
return "绘制沟渠(菜单 PL_LSJM 绘制沟渠,实体 AecDbEwPipeBase):给走向 points + U 形断面尺寸"
"(总宽/总高/内底宽/侧壁坡度角/壁厚,缺省照抄 CHZGQDlg:800/800/700/0°/10)+ 底标高、材质、用途。"
"断面按命令的 GetSection 现算成面域再沿路径扫。";
}
nlohmann::json private_input_schema() const override
{
return nlohmann::json::parse(R"({
"type": "object",
"properties": {
"points": { "type": "array", "items": { "type": "array", "items": { "type": "number" } },
"description": "沟渠走向 [[x,y],...](至少 2 点)" },
"width": { "type": "number", "description": "总宽,缺省 800" },
"height": { "type": "number", "description": "总高,缺省 800" },
"inner_width": { "type": "number", "description": "内底宽,缺省 700" },
"angle": { "type": "number", "description": "侧壁坡度角(度),缺省 0" },
"wall_thickness": { "type": "number", "description": "壁厚,缺省 10" },
"bottom_elevation": { "type": "number", "description": "底标高,缺省 0" },
"material": { "type": "string", "description": "材质,缺省 素砼" },
"purpose": { "type": "string", "description": "用途,缺省 进水渠" },
"color": { "type": "integer" }
},
"required": [ "points" ]
})");
}
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 double dW = numOr(args, "width", 800.0);
const double dH = numOr(args, "height", 800.0);
const double dV = numOr(args, "inner_width", 700.0);
const double dAng = numOr(args, "angle", 0.0);
const double dT = numOr(args, "wall_thickness", 10.0);
const double dEl = numOr(args, "bottom_elevation", 0.0);
std::wstring err;
AcGePoint3d ptCen(0.0, 0.0, 0.0);
AcDbRegion* pReg = BuildDitchRegion(dW, dH, dV, dAng, dT, ptCen, err);
if (pReg == NULL) return errJson(kErrBadParam, err);
AcDbPolyline* pPath = DitchPathOf(args, dEl, err);
if (pPath == NULL) { delete pReg; return errJson(kErrBadParam, err); }
AecDbEwPipeBase* pPipe = new AecDbEwPipeBase();
pPipe->SetSection(pReg, ptCen);
pPipe->SetBaseCurve(pPath);
delete pPath;
delete pReg;
pPipe->GetSpecialtyData()->SetAt(KEY_NAME, _T("沟渠"));
pPipe->GetSpecialtyData()->SetAt(KEY_2DSTYLE, 2);
pPipe->GetSpecialtyData()->SetAt(KEY_CENNODRAW, TRUE);
pPipe->GetSpecialtyData()->SetAt(KEY_BOMEL, dEl); // 底标高也记下来,update 要读
SetDitchXData(pPipe, args); // 没传的用缺省(与命令一致)
if (!hasKey(args, "material")) pPipe->GetSpecialtyData()->SetAt(KEY_MATERIAL, _T("素砼"));
if (!hasKey(args, "purpose")) pPipe->GetSpecialtyData()->SetAt(KEY_PURPOSE, _T("进水渠"));
AcDbObjectId idNew;
Acad::ErrorStatus es = addToSpace(pPipe, &idNew);
if (es != Acad::eOk)
{
delete pPipe;
return errJson(kErrInternal, std::wstring(L"加入模型空间失败,err=") + std::to_wstring((int)es));
}
touchEntity(pPipe);
nlohmann::json o;
o["points"] = args.contains("points") ? args["points"] : nlohmann::json::array();
o["width"] = dW;
o["height"] = dH;
o["inner_width"] = dV;
o["angle"] = dAng;
o["wall_thickness"] = dT;
o["bottom_elevation"] = dEl;
nlohmann::json body;
body["ok"] = true;
body["type"] = "ditch";
body["params"] = o;
pPipe->close();
body["handle"] = HandleOfId(idNew);
return okJson(body);
}
};
EXPORT_MCP_TOOL(ToolAddDitch, AddAecDitchTool)
class ToolUpdateDitch : public mcp_Tool
{
public:
std::string private_name() const override { return "update_aec_ditch"; }
std::string private_description() const override
{
return "改沟渠(AecDbEwPipeBase):总宽/总高/内底宽/坡度角/壁厚/底标高/材质/用途,只传要改的字段;"
"给 points 可以换走向。改断面会重建面域。";
}
nlohmann::json private_input_schema() const override
{
return nlohmann::json::parse(R"({
"type": "object",
"properties": {
"handle": { "type": "string", "description": "沟渠实体 handle" },
"points": { "type": "array", "items": { "type": "array", "items": { "type": "number" } } },
"width": { "type": "number" }, "height": { "type": "number" },
"inner_width": { "type": "number" }, "angle": { "type": "number" },
"wall_thickness": { "type": "number" }, "bottom_elevation": { "type": "number" },
"material": { "type": "string" }, "purpose": { "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));
AecDbEwPipeBase* pPipe = AecDbEwPipeBase::cast(pEnt);
if (pPipe == NULL)
{
const std::string sCls = classNameOf(pEnt);
pEnt->close();
return errJson(kErrWrongType, L"实体 " + utf8ToWstr(sCls) + L" 不是沟渠(AecDbEwPipeBase)");
}
// 读现有断面尺寸(专业数据里存着)
const AecDbObjXDataMap* pX = pPipe->GetSpecialtyData(AcDb::kForRead);
double dW = 0.0, dH = 0.0, dV = 0.0, dAng = 0.0, dT = 0.0, dEl = 0.0;
if (pX != NULL)
{
pX->GetAt(KEY_W, dW);
pX->GetAt(KEY_H, dH);
pX->GetAt(KEY_V, dV);
pX->GetAt(KEY_Angle, dAng);
pX->GetAt(KEY_T, dT);
pX->GetAt(KEY_BOMEL, dEl);
}
dW = numOr(args, "width", dW);
dH = numOr(args, "height", dH);
dV = numOr(args, "inner_width", dV);
dAng = numOr(args, "angle", dAng);
dT = numOr(args, "wall_thickness", dT);
dEl = numOr(args, "bottom_elevation", dEl);
std::wstring err;
AcGePoint3d ptCen(0.0, 0.0, 0.0);
AcDbRegion* pReg = BuildDitchRegion(dW, dH, dV, dAng, dT, ptCen, err);
if (pReg == NULL)
{
pEnt->close();
return errJson(kErrBadParam, err);
}
pPipe->SetSection(pReg, ptCen);
delete pReg;
if (hasKey(args, "points"))
{
AcDbPolyline* pPath = DitchPathOf(args, dEl, err);
if (pPath == NULL)
{
pEnt->close();
return errJson(kErrBadParam, err);
}
pPipe->SetBaseCurve(pPath);
delete pPath;
}
else if (hasKey(args, "bottom_elevation"))
{
// 只改底标高:把路径整体抬到新标高
AcDbCurve* pCrv = AcDbCurve::cast(pEnt);
AcDbPolyline* pOld = (pCrv != NULL) ? AcDbPolyline::cast(pCrv->clone()) : NULL;
if (pOld != NULL)
{
pOld->setElevation(dEl);
pPipe->SetBaseCurve(pOld);
delete pOld;
}
}
SetDitchXData(pPipe, args);
pPipe->GetSpecialtyData()->SetAt(KEY_BOMEL, dEl);
if (hasKey(args, "color")) pPipe->setColorIndex((Adesk::UInt16)intOr(args, "color", 256));
pPipe->ReCreateDraw3d();
touchEntity(pPipe);
nlohmann::json o;
o["width"] = dW;
o["height"] = dH;
o["inner_width"] = dV;
o["angle"] = dAng;
o["wall_thickness"] = dT;
o["bottom_elevation"] = dEl;
nlohmann::json body;
body["ok"] = true;
body["type"] = "ditch";
body["handle"] = sHandle;
body["params"] = o;
pEnt->close();
return okJson(body);
}
};
EXPORT_MCP_TOOL(ToolUpdateDitch, UpdateAecDitchTool)
@@ -0,0 +1,301 @@
// ============================================================================
// aec_mcp_dim_tools.cpp
// cad_mcp_aec 的标注工具(工作计划第 6 项)
// * add_aec_pipe_dim / update_aec_pipe_dim —— AecDbEwPipeDim(纯 2D,没有 3D 显示)
//
// 8 个标注命令(PL_XHBZ 序号 / PL_XHPB 序号批标 / PL_DKBZ 洞口 / PL_TGBZ 套管 /
// PL_YHBZ 翼环 / PL_FMBZ 阀门 / IS_BZFM 标注阀门 / IS_GZGJ 标注管件)用的都是同一个类,
// 创建序列也一致(见 PipelineCmd/command.cpp PL_XHBZCmdFnc):
// new AecDbEwPipeDim
// AddAecDbWEntity(被标注实体) // 关联
// SetDimStyle(n) / SetDimDir(0) / SetDimTextUporDownFlag(1)
// setLayer(LAY_PP3D_DIM) + SetTextStyleId + SetTextLayerId
// SetPScale(getPScale()) / SetTextHeight(3.0) / SetTextWidthScale(0.75)
// AddDimText(上文字, 下文字)
// AppendPoint(引出起点) / AppendPoint(文字位置)
// 入库
// 差别只在 SetDimStyle 的取值和文字怎么拼(命令是按被标注实体的专业数据拼的)。
// 工具这版:样式/方向/上下标记/字高/字宽比/图层都可给,文字由调用方直接传
// (`text` 上、`text_down` 下)——自动拼文字没做,命令里那套按实体数据拼的逻辑要逐类搬。
// ============================================================================
#include "StdAfx.h"
#include "KTCad.h"
#include "aec_mcp_common.h"
#include "mcp_plugin_api.h"
#include "AecDbObjXDataMap.h"
#include "AecDbEwPipeDim.h"
#include "AecDbObjXDataMap.h"
#include "CoreTools.h"
#include "KTCadUtility.h"
#include "KTSetting.h"
using namespace aec_mcp;
namespace
{
const TCHAR* kDimLayer = _T("LAY_PP3D_DIM"); // PipelineTools::gLayer_Pipe_Dim
const TCHAR* kDimTextStyle = _T("Pipe_Dim"); // PipelineTools::gTextStyle_Pipe_Dim
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;
}
// 8 个命令各自的 dim style(命令里写死的取值,没给的用 3=序号标注)
int StyleOfKind(const std::wstring& sKind)
{
if (sKind == L"seq") return 3; // PL_XHBZ 序号标注
if (sKind == L"seq_batch") return 3; // PL_XHPB 序号批标
if (sKind == L"opening") return 3; // PL_DKBZ 洞口
if (sKind == L"casing") return 3; // PL_TGBZ 套管
if (sKind == L"ring") return 3; // PL_YHBZ 翼环
if (sKind == L"valve") return 3; // PL_FMBZ 阀门
if (sKind == L"iso_valve") return 3; // IS_BZFM
if (sKind == L"iso_fitting") return 3; // IS_GZGJ
return 3;
}
void AppendPoints(AecDbEwPipeDim* pDim, const nlohmann::json& a, bool& bOk)
{
bOk = false;
if (!hasKey(a, "points") || !a["points"].is_array() || a["points"].size() < 2)
return;
for (size_t i = 0; i < a["points"].size() && i < 2; ++i)
{
const nlohmann::json& pt = a["points"][i];
AcGePoint3d ptOn(0.0, 0.0, 0.0);
if (!pointOf(pt, ptOn)) return;
pDim->AppendPoint(ptOn);
}
bOk = true;
}
}
// ---------------------------------------------------------------------------
// add_aec_pipe_dim —— 管线标注(8 个标注命令共用)
// ---------------------------------------------------------------------------
class ToolAddPipeDim : public mcp_Tool
{
public:
std::string private_name() const override { return "add_aec_pipe_dim"; }
std::string private_description() const override
{
return "建管线标注(`AecDbEwPipeDim`,纯 2D 无 3D 显示)。覆盖 8 个标注命令:\n"
" seq=PL_XHBZ 序号 / seq_batch=PL_XHPB 序号批标 / opening=PL_DKBZ 洞口 / casing=PL_TGBZ 套管 /\n"
" ring=PL_YHBZ 翼环 / valve=PL_FMBZ 阀门 / iso_valve=IS_BZFM 标注阀门 / iso_fitting=IS_GZGJ 标注管件\n"
"给被标注实体的 handle、引出起点+文字位置两个点、上/下文字,样式/方向/字高/字宽比可选。\n"
"注意:命令里文字是按被标注实体的专业数据自动拼的(如\"预留D300洞口\"),"
"这版需要调用方自己把 text 传进来。";
}
nlohmann::json private_input_schema() const override
{
return nlohmann::json::parse(R"({
"type": "object",
"properties": {
"target": { "type": "string", "description": "被标注实体的 handle(管/洞/套管/管件…)" },
"kind": { "type": "string",
"enum": [ "seq", "seq_batch", "opening", "casing", "ring", "valve", "iso_valve", "iso_fitting" ],
"description": "标注种类(决定 dim style 与语义),缺省 seq" },
"points": { "type": "array", "items": { "type": "array", "items": { "type": "number" } },
"description": "两个点:[[引出起点],[文字位置]]" },
"text": { "type": "string", "description": "上排文字(序号/洞洞尺寸等)" },
"text_down": { "type": "string", "description": "下排文字(如中心标高)" },
"dim_style": { "type": "integer", "description": "标注样式编号,缺省按 kind" },
"dim_dir": { "type": "integer", "description": "标注方向,缺省 0" },
"text_up_down": { "type": "integer", "description": "上下标记:1 上 / -1 下,缺省 1" },
"text_height": { "type": "number", "description": "字高,缺省 3.0(命令里 2.5×dimscale)" },
"text_width_scale": { "type": "number", "description": "字宽比,缺省 0.75" },
"p_scale": { "type": "number", "description": "出图比例,缺省 100" },
"layer": { "type": "string", "description": "图层,缺省 LAY_PP3D_DIM" },
"text_style": { "type": "string", "description": "文字样式,缺省 Pipe_Dim" },
"color": { "type": "integer" }
},
"required": [ "target", "points", "text" ]
})");
}
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, "target")) return errJson(kErrBadParam, L"缺少 target(被标注实体的 handle)");
const std::string sTarget = args["target"].get<std::string>();
AcDbEntity* pTarget = openByHandle(sTarget, AcDb::kForRead);
if (pTarget == NULL) return errJson(kErrNotFound, L"按 handle 打不开被标注实体:" + utf8ToWstr(sTarget));
const AcDbObjectId idTarget = pTarget->objectId();
pTarget->close();
AecDbEwPipeDim* pDim = new AecDbEwPipeDim();
std::wstring sLay = hasKey(args, "layer") ? wstrOr(args, "layer", L"") : L"";
if (sLay.empty()) sLay = kDimLayer;
AcDbObjectId idLay = KTSetting::InitLayer(sLay.c_str());
std::wstring sTxtStyle = hasKey(args, "text_style") ? wstrOr(args, "text_style", L"") : L"";
if (sTxtStyle.empty()) sTxtStyle = kDimTextStyle;
AcDbObjectId idTSty = CKTCadUtility::InitTextStyle(sTxtStyle.c_str());
pDim->AddAecDbWEntity(idTarget);
pDim->SetDimStyle((short)(hasKey(args, "dim_style")
? intOr(args, "dim_style", 3)
: StyleOfKind(wstrOr(args, "kind", L"seq"))));
pDim->SetDimDir((short)intOr(args, "dim_dir", 0));
pDim->SetDimTextUporDownFlag((short)intOr(args, "text_up_down", 1));
if (!idLay.isNull()) pDim->setLayer(idLay);
if (!idTSty.isNull())
{
pDim->SetTextStyleId(idTSty);
pDim->SetTextLayerId(idLay);
}
pDim->SetPScale(numOr(args, "p_scale", 100.0));
pDim->SetTextHeight(numOr(args, "text_height", 3.0));
pDim->SetTextWidthScale(numOr(args, "text_width_scale", 0.75));
if (hasKey(args, "color")) pDim->setColorIndex((Adesk::UInt16)intOr(args, "color", 256));
const std::wstring sUp = wstrOr(args, "text", L"");
const std::wstring sDown = hasKey(args, "text_down") ? wstrOr(args, "text_down", L"") : std::wstring();
pDim->AddDimText(sUp.c_str(), sDown.empty() ? NULL : sDown.c_str());
bool bPointsOk = false;
AppendPoints(pDim, args, bPointsOk);
if (!bPointsOk)
{
delete pDim;
return errJson(kErrBadParam, L"points 要给两个点:[[引出起点],[文字位置]]");
}
AcDbObjectId idNew;
Acad::ErrorStatus es = addToSpace(pDim, &idNew);
if (es != Acad::eOk)
{
delete pDim;
return errJson(kErrInternal, std::wstring(L"加入模型空间失败,err=") + std::to_wstring((int)es));
}
touchEntity(pDim);
nlohmann::json o;
o["target"] = sTarget;
o["kind"] = acharToUtf8(wstrOr(args, "kind", L"seq").c_str());
o["text"] = acharToUtf8(sUp.c_str());
o["text_down"] = acharToUtf8(sDown.c_str());
o["dim_style"] = (int)pDim->GetDimStyle();
o["dim_dir"] = (int)pDim->GetDimDir();
o["text_height"] = pDim->GetTextHeight();
o["text_width_scale"] = pDim->GetTextWidthScale();
nlohmann::json body;
body["ok"] = true;
body["type"] = "pipe_dim";
body["params"] = o;
pDim->close();
body["handle"] = HandleOfId(idNew);
return okJson(body);
}
};
EXPORT_MCP_TOOL(ToolAddPipeDim, AddAecPipeDimTool)
// ---------------------------------------------------------------------------
// update_aec_pipe_dim —— 改标注文字/样式/字高
// ---------------------------------------------------------------------------
class ToolUpdatePipeDim : public mcp_Tool
{
public:
std::string private_name() const override { return "update_aec_pipe_dim"; }
std::string private_description() const override
{
return "改管线标注(AecDbEwPipeDim):上/下文字、样式、方向、上下标记、字高、字宽比、出图比例,"
"只传要改的字段。位置点(引出点/文字点)目前不能改,要挪就删了重建。";
}
nlohmann::json private_input_schema() const override
{
return nlohmann::json::parse(R"({
"type": "object",
"properties": {
"handle": { "type": "string", "description": "标注实体 handle" },
"text": { "type": "string", "description": "新上排文字" },
"text_down": { "type": "string", "description": "新下排文字" },
"dim_style": { "type": "integer" }, "dim_dir": { "type": "integer" },
"text_up_down": { "type": "integer" },
"text_height": { "type": "number" }, "text_width_scale": { "type": "number" },
"p_scale": { "type": "number" },
"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));
AecDbEwPipeDim* pDim = AecDbEwPipeDim::cast(pEnt);
if (pDim == NULL)
{
const std::string sCls = classNameOf(pEnt);
pEnt->close();
return errJson(kErrWrongType, L"实体 " + utf8ToWstr(sCls) + L" 不是管线标注(AecDbEwPipeDim)");
}
if (hasKey(args, "dim_style")) pDim->SetDimStyle((short)intOr(args, "dim_style", 3));
if (hasKey(args, "dim_dir")) pDim->SetDimDir((short)intOr(args, "dim_dir", 0));
if (hasKey(args, "text_up_down")) pDim->SetDimTextUporDownFlag((short)intOr(args, "text_up_down", 1));
if (hasKey(args, "text_height")) pDim->SetTextHeight(numOr(args, "text_height", 3.0));
if (hasKey(args, "text_width_scale")) pDim->SetTextWidthScale(numOr(args, "text_width_scale", 0.75));
if (hasKey(args, "p_scale")) pDim->SetPScale(numOr(args, "p_scale", 100.0));
if (hasKey(args, "color")) pDim->setColorIndex((Adesk::UInt16)intOr(args, "color", 256));
if (hasKey(args, "text") || hasKey(args, "text_down"))
{
// 文字整组换掉:先清上/下,再写新的
CString sUpOld, sDownOld;
pDim->GetDimText(0, sUpOld, sDownOld);
CString sUp = hasKey(args, "text") ? CString(wstrOr(args, "text", L"").c_str()) : sUpOld;
CString sDown = hasKey(args, "text_down") ? CString(wstrOr(args, "text_down", L"").c_str()) : sDownOld;
pDim->RemoveAll(1);
pDim->RemoveAll(-1);
pDim->AddDimText((LPCTSTR)sUp, sDown.IsEmpty() ? NULL : (LPCTSTR)sDown);
}
pDim->UpdateFromParam();
pDim->ReCreateDraw3d();
touchEntity(pDim);
CString sUp, sDown;
pDim->GetDimText(0, sUp, sDown);
nlohmann::json o;
o["text"] = acharToUtf8((LPCTSTR)sUp);
o["text_down"] = acharToUtf8((LPCTSTR)sDown);
o["dim_style"] = (int)pDim->GetDimStyle();
o["dim_dir"] = (int)pDim->GetDimDir();
o["text_height"] = pDim->GetTextHeight();
o["text_width_scale"] = pDim->GetTextWidthScale();
nlohmann::json body;
body["ok"] = true;
body["type"] = "pipe_dim";
body["handle"] = sHandle;
body["params"] = o;
pEnt->close();
return okJson(body);
}
};
EXPORT_MCP_TOOL(ToolUpdatePipeDim, UpdateAecPipeDimTool)
@@ -201,6 +201,16 @@ namespace
if (hasKey(a, "bottom_elevation")) data.dBomEl = numOr(a, "bottom_elevation", data.dBomEl);
if (hasKey(a, "top_elevation")) data.dTopEl = numOr(a, "top_elevation", data.dTopEl);
if (hasKey(a, "with_rail")) data.bGuardBar = intOr(a, "with_rail", 0) ? TRUE : FALSE;
// ---- 精细字段(对话框里其余那些,出图会用到)----
if (hasKey(a, "steep_count")) data.nSteepS = intOr(a, "steep_count", data.nSteepS);
if (hasKey(a, "symbol")) data.nSymbol = intOr(a, "symbol", data.nSymbol);
if (hasKey(a, "in_slab_3d")) data.bShowInSlab3d = intOr(a, "in_slab_3d", 0) ? TRUE : FALSE;
if (hasKey(a, "left_beam")) data.bLBeam = intOr(a, "left_beam", 1) ? TRUE : FALSE;
if (hasKey(a, "right_beam")) data.bRBeam = intOr(a, "right_beam", 1) ? TRUE : FALSE;
if (hasKey(a, "slope")) data.bSlope = intOr(a, "slope", 0) ? TRUE : FALSE;
if (hasKey(a, "nonslip")) data.bNonslip = intOr(a, "nonslip", 0) ? TRUE : FALSE;
if (hasKey(a, "slope_base")) data.bSlopeBase = intOr(a, "slope_base", 0) ? TRUE : FALSE;
if (hasKey(a, "bottom_at_start")) data.bBomSta = intOr(a, "bottom_at_start", 1) ? TRUE : FALSE;
if (hasKey(a, "material")) CopyStr(data.m_sMaterial, 256, wstrOr(a, "material", L""));
if (hasKey(a, "factory")) CopyStr(data.m_sFactory, 256, wstrOr(a, "factory", L""));
if (hasKey(a, "no")) CopyStr(data.m_sNo, 256, wstrOr(a, "no", L""));
@@ -258,6 +268,20 @@ namespace
if (hasKey(a, "bar_space")) data.dBarSp = numOr(a, "bar_space", data.dBarSp);
if (hasKey(a, "material")) CopyStr(data.szGarMat, 256, wstrOr(a, "material", L""));
if (hasKey(a, "rail_material")) CopyStr(data.szBarMat, 256, wstrOr(a, "rail_material", L""));
// ---- 精细字段(CDPLTDlg 里其余那些)----
if (hasKey(a, "flight_count")) data.nZs = intOr(a, "flight_count", data.nZs);
if (hasKey(a, "stiffener_width")) data.dStiffnW = numOr(a, "stiffener_width", data.dStiffnW);
if (hasKey(a, "stiffener_height")) data.dStiffnH = numOr(a, "stiffener_height", data.dStiffnH);
if (hasKey(a, "handrail_size_w")) data.dGarSize[0] = numOr(a, "handrail_size_w", data.dGarSize[0]);
if (hasKey(a, "handrail_size_h")) data.dGarSize[1] = numOr(a, "handrail_size_h", data.dGarSize[1]);
if (hasKey(a, "handrail_ext")) data.dGarExt = numOr(a, "handrail_ext", data.dGarExt);
if (hasKey(a, "handrail_ext_z")) data.dZGarExt = numOr(a, "handrail_ext_z", data.dZGarExt);
if (hasKey(a, "handrail_shape")) data.nGShape = intOr(a, "handrail_shape", data.nGShape);
if (hasKey(a, "rail_size_w")) data.dBarSize[0] = numOr(a, "rail_size_w", data.dBarSize[0]);
if (hasKey(a, "rail_size_h")) data.dBarSize[1] = numOr(a, "rail_size_h", data.dBarSize[1]);
if (hasKey(a, "rail_shape")) data.nBShape = intOr(a, "rail_shape", data.nBShape);
if (hasKey(a, "side_beam_w")) data.dSideBeamW = numOr(a, "side_beam_w", data.dSideBeamW);
if (hasKey(a, "side_beam_h")) data.dSideBeamH = numOr(a, "side_beam_h", data.dSideBeamH);
}
nlohmann::json ZStairToJson(const ZLineStair& d)
@@ -278,6 +302,19 @@ namespace
o["bar_space"] = d.dBarSp;
o["material"] = acharToUtf8(d.szGarMat);
o["rail_material"] = acharToUtf8(d.szBarMat);
o["flight_count"] = d.nZs;
o["stiffener_width"] = d.dStiffnW;
o["stiffener_height"] = d.dStiffnH;
o["handrail_size_w"] = d.dGarSize[0];
o["handrail_size_h"] = d.dGarSize[1];
o["handrail_ext"] = d.dGarExt;
o["handrail_ext_z"] = d.dZGarExt;
o["handrail_shape"] = d.nGShape;
o["rail_size_w"] = d.dBarSize[0];
o["rail_size_h"] = d.dBarSize[1];
o["rail_shape"] = d.nBShape;
o["side_beam_w"] = d.dSideBeamW;
o["side_beam_h"] = d.dSideBeamH;
return o;
}
@@ -294,6 +331,14 @@ namespace
o["steep_count"] = data.nSteepS;
o["side_width"] = data.dSideW;
o["side_thickness"] = data.dSidet;
o["symbol"] = data.nSymbol;
o["in_slab_3d"] = (data.bShowInSlab3d != FALSE);
o["left_beam"] = (data.bLBeam != FALSE);
o["right_beam"] = (data.bRBeam != FALSE);
o["slope"] = (data.bSlope != FALSE);
o["nonslip"] = (data.bNonslip != FALSE);
o["slope_base"] = (data.bSlopeBase != FALSE);
o["with_rail"] = (data.bGuardBar != FALSE);
}
// ---------------------------------------------------------------------------
@@ -482,18 +527,15 @@ public:
body["handle"] = sHandle;
body["start"] = PointJson(ptS);
body["end"] = PointJson(ptE);
// 注意:材质/厂家/编号在 LineStair 自己的成员里,不在 bar 里
// (GetLineStairData 只回填 bar 的直径/间距那些)
body["params"] = GuardBarToJson(data.bar);
body["params"]["material"] = acharToUtf8(data.m_sMaterial);
body["params"]["factory"] = acharToUtf8(data.m_sFactory);
body["params"]["no"] = acharToUtf8(data.m_sNo);
body["params"]["width"] = data.dW;
body["params"]["steep_height"] = data.dSteepH;
body["params"]["steep_width"] = data.dSteepW;
body["params"]["steep_thickness"] = data.dSteept;
body["params"]["side_width"] = data.dSideW;
body["params"]["side_thickness"] = data.dSidet;
// 材质/厂家/编号在 LineStair 自己的成员里,不在 bar 里;统一用 LineStairToJson 组装
body["params"] = nlohmann::json::object();
body["params"]["diameter"] = data.bar.dD;
body["params"]["bar_thickness"] = data.bar.dt;
body["params"]["bottom_elevation"] = data.bar.dBomEl;
body["params"]["top_height"] = data.bar.dH;
body["params"]["first_height"] = data.bar.dH1;
body["params"]["post_space"] = data.bar.dP;
LineStairToJson(body["params"], data);
return okJson(body);
}
};
@@ -11,6 +11,7 @@ set(SOURCES
"aec_mcp_sfp_stair_tools.cpp"
"aec_mcp_window_tools.cpp"
"aec_mcp_attachment_tools.cpp"
"aec_mcp_dim_tools.cpp"
"aec_mcp_roof_tools.cpp"
"aec_mcp_query.cpp"
"StdAfx.cpp"
+428 -4
View File
@@ -3146,7 +3146,7 @@
},
{
"name": "update_aec_line_stair",
"description": "改直线钢梯:起终点、梯宽/踏步/梯梁/栏管尺寸、材质编号,只传要改的字段。改尺寸会重建几何;不传 start/end 就保持原来的走向。",
"description": "改直线钢梯:起终点、梯宽/踏步/梯梁/栏管尺寸、材质编号,只传要改的字段。改尺寸会重建几何;不传 start/end 就保持原来的走向。另外还暴露了对话框里的精细字段(踏步数/编号/边梁/起坡/防滑/楼板 3D、加强筋、扶手与栏杆截面、侧梁等),按总原则 update 要能调到出图精度。",
"inputSchema": {
"type": "object",
"properties": {
@@ -3240,6 +3240,42 @@
"no": {
"type": "string",
"description": "编号"
},
"steep_count": {
"type": "integer",
"description": "踏步数(直线楼梯用)"
},
"symbol": {
"type": "integer",
"description": "符号/编号方式"
},
"in_slab_3d": {
"type": "boolean",
"description": "是否画进楼板 3D"
},
"left_beam": {
"type": "boolean",
"description": "左边梁"
},
"right_beam": {
"type": "boolean",
"description": "右边梁"
},
"slope": {
"type": "boolean",
"description": "是否起坡"
},
"nonslip": {
"type": "boolean",
"description": "防滑条"
},
"slope_base": {
"type": "boolean",
"description": "坡底是否斜面"
},
"bottom_at_start": {
"type": "boolean",
"description": "起点是否为底标"
}
},
"required": [
@@ -3524,7 +3560,7 @@
},
{
"name": "update_aec_z_stair",
"description": "改双跑楼梯:踏步/梯段宽/梯井/平台/扶手栏杆尺寸,只传要改的字段;给 start+direction_point 可以换位置和走向。",
"description": "改双跑楼梯:踏步/梯段宽/梯井/平台/扶手栏杆尺寸,只传要改的字段;给 start+direction_point 可以换位置和走向。另外还暴露了对话框里的精细字段(踏步数/编号/边梁/起坡/防滑/楼板 3D、加强筋、扶手与栏杆截面、侧梁等),按总原则 update 要能调到出图精度。",
"inputSchema": {
"type": "object",
"properties": {
@@ -3606,6 +3642,58 @@
"rail_material": {
"type": "string",
"description": "栏杆材质"
},
"flight_count": {
"type": "integer",
"description": "梯段数"
},
"stiffener_width": {
"type": "number",
"description": "加强筋宽"
},
"stiffener_height": {
"type": "number",
"description": "加强筋高"
},
"handrail_size_w": {
"type": "number",
"description": "扶手截面宽"
},
"handrail_size_h": {
"type": "number",
"description": "扶手截面高"
},
"handrail_ext": {
"type": "number",
"description": "转角扶手伸出"
},
"handrail_ext_z": {
"type": "number",
"description": "层间扶手伸出"
},
"handrail_shape": {
"type": "integer",
"description": "扶手截面形状 0=矩形 1=圆"
},
"rail_size_w": {
"type": "number",
"description": "栏杆截面宽"
},
"rail_size_h": {
"type": "number",
"description": "栏杆截面高"
},
"rail_shape": {
"type": "integer",
"description": "栏杆截面形状 0=矩形 1=圆"
},
"side_beam_w": {
"type": "number",
"description": "侧梁宽"
},
"side_beam_h": {
"type": "number",
"description": "侧梁高"
}
},
"required": [
@@ -3712,7 +3800,7 @@
},
{
"name": "update_aec_line_seg_stair",
"description": "改直线楼梯(AecDbLineSegStair):踏步/梯宽/梯梁/材质,只传要改的字段;给 start+direction_point 可以换位置和走向。",
"description": "改直线楼梯(AecDbLineSegStair):踏步/梯宽/梯梁/材质,只传要改的字段;给 start+direction_point 可以换位置和走向。另外还暴露了对话框里的精细字段(踏步数/编号/边梁/起坡/防滑/楼板 3D、加强筋、扶手与栏杆截面、侧梁等),按总原则 update 要能调到出图精度。",
"inputSchema": {
"type": "object",
"properties": {
@@ -3773,6 +3861,34 @@
},
"color": {
"type": "integer"
},
"symbol": {
"type": "integer",
"description": "符号/编号方式"
},
"left_beam": {
"type": "boolean",
"description": "左边梁"
},
"right_beam": {
"type": "boolean",
"description": "右边梁"
},
"slope": {
"type": "boolean",
"description": "是否起坡"
},
"nonslip": {
"type": "boolean",
"description": "防滑条"
},
"slope_base": {
"type": "boolean",
"description": "坡底是否斜面"
},
"bottom_at_start": {
"type": "boolean",
"description": "起点是否为底标"
}
},
"required": [
@@ -3893,7 +4009,7 @@
},
{
"name": "update_aec_arc_stair",
"description": "改圆弧楼梯(AecDbArcStair):踏步/梯宽/梯梁/扶手/材质,只传要改的字段;给 curve 可以换中心线圆弧。",
"description": "改圆弧楼梯(AecDbArcStair):踏步/梯宽/梯梁/扶手/材质,只传要改的字段;给 curve 可以换中心线圆弧。另外还暴露了对话框里的精细字段(踏步数/编号/边梁/起坡/防滑/楼板 3D、加强筋、扶手与栏杆截面、侧梁等),按总原则 update 要能调到出图精度。",
"inputSchema": {
"type": "object",
"properties": {
@@ -3952,6 +4068,42 @@
},
"color": {
"type": "integer"
},
"steep_count": {
"type": "integer",
"description": "踏步数(直线楼梯用)"
},
"symbol": {
"type": "integer",
"description": "符号/编号方式"
},
"in_slab_3d": {
"type": "boolean",
"description": "是否画进楼板 3D"
},
"left_beam": {
"type": "boolean",
"description": "左边梁"
},
"right_beam": {
"type": "boolean",
"description": "右边梁"
},
"slope": {
"type": "boolean",
"description": "是否起坡"
},
"nonslip": {
"type": "boolean",
"description": "防滑条"
},
"slope_base": {
"type": "boolean",
"description": "坡底是否斜面"
},
"bottom_at_start": {
"type": "boolean",
"description": "起点是否为底标"
}
},
"required": [
@@ -5375,6 +5527,278 @@
"dll_name": "cad_mcp_aec.dll",
"factory_function": "UpdateAecApronTool"
}
},
{
"name": "add_aec_ditch",
"description": "绘制沟渠(菜单 PL_LSJM,实体 AecDbEwPipeBase):给走向 points + U 形断面尺寸(总宽/总高/内底宽/侧壁坡度角/壁厚,缺省 800/800/700/0/10)+ 底标高、材质、用途。断面按命令 CHZGQDlg::GetSection 的算法现算成面域再沿路径扫。",
"inputSchema": {
"type": "object",
"properties": {
"color": {
"type": "integer"
},
"points": {
"type": "array",
"items": {
"type": "array",
"items": {
"type": "number"
}
},
"description": "沟渠走向 [[x,y],...](至少 2 点)"
},
"width": {
"type": "number",
"description": "总宽,缺省 800"
},
"height": {
"type": "number",
"description": "总高,缺省 800"
},
"inner_width": {
"type": "number",
"description": "内底宽,缺省 700"
},
"angle": {
"type": "number",
"description": "侧壁坡度角(度),缺省 0"
},
"wall_thickness": {
"type": "number",
"description": "壁厚,缺省 10"
},
"bottom_elevation": {
"type": "number",
"description": "底标高,缺省 0"
},
"material": {
"type": "string",
"description": "材质,缺省 素砼"
},
"purpose": {
"type": "string",
"description": "用途,缺省 进水渠"
}
},
"required": [
"points"
]
},
"backend": {
"type": "c++_dll",
"dll_name": "cad_mcp_aec.dll",
"factory_function": "AddAecDitchTool"
}
},
{
"name": "update_aec_ditch",
"description": "改沟渠(AecDbEwPipeBase):总宽/总高/内底宽/坡度角/壁厚/底标高/材质/用途,只传要改的字段;给 points 可以换走向;改断面会重建面域。",
"inputSchema": {
"type": "object",
"properties": {
"handle": {
"type": "string",
"description": "沟渠实体 handle"
},
"color": {
"type": "integer"
},
"points": {
"type": "array",
"items": {
"type": "array",
"items": {
"type": "number"
}
},
"description": "沟渠走向 [[x,y],...](至少 2 点)"
},
"width": {
"type": "number",
"description": "总宽,缺省 800"
},
"height": {
"type": "number",
"description": "总高,缺省 800"
},
"inner_width": {
"type": "number",
"description": "内底宽,缺省 700"
},
"angle": {
"type": "number",
"description": "侧壁坡度角(度),缺省 0"
},
"wall_thickness": {
"type": "number",
"description": "壁厚,缺省 10"
},
"bottom_elevation": {
"type": "number",
"description": "底标高,缺省 0"
},
"material": {
"type": "string",
"description": "材质,缺省 素砼"
},
"purpose": {
"type": "string",
"description": "用途,缺省 进水渠"
}
},
"required": [
"handle"
]
},
"backend": {
"type": "c++_dll",
"dll_name": "cad_mcp_aec.dll",
"factory_function": "UpdateAecDitchTool"
}
},
{
"name": "add_aec_pipe_dim",
"description": "建管线标注(AecDbEwPipeDim,纯 2D 无 3D 显示)。覆盖 8 个标注命令:seq=PL_XHBZ 序号 / seq_batch=PL_XHPB 序号批标 / opening=PL_DKBZ 洞口 / casing=PL_TGBZ 套管 / ring=PL_YHBZ 翼环 / valve=PL_FMBZ 阀门 / iso_valve=IS_BZFM 标注阀门 / iso_fitting=IS_GZGJ 标注管件。给被标注实体 handle、引出起点+文字位置两个点、上/下文字。注意:命令里文字是按被标注实体数据自动拼的(如\"预留D300洞口\"),这版要调用方自己传 text。",
"inputSchema": {
"type": "object",
"properties": {
"target": {
"type": "string",
"description": "被标注实体的 handle"
},
"kind": {
"type": "string",
"enum": [
"seq",
"seq_batch",
"opening",
"casing",
"ring",
"valve",
"iso_valve",
"iso_fitting"
],
"description": "标注种类,缺省 seq"
},
"points": {
"type": "array",
"items": {
"type": "array",
"items": {
"type": "number"
}
},
"description": "两个点:[[引出起点],[文字位置]]"
},
"text": {
"type": "string",
"description": "上排文字"
},
"text_down": {
"type": "string",
"description": "下排文字"
},
"layer": {
"type": "string",
"description": "图层,缺省 LAY_PP3D_DIM"
},
"text_style": {
"type": "string",
"description": "文字样式,缺省 Pipe_Dim"
},
"color": {
"type": "integer"
},
"dim_style": {
"type": "integer",
"description": "标注样式编号,缺省按 kind"
},
"dim_dir": {
"type": "integer",
"description": "标注方向,缺省 0"
},
"text_up_down": {
"type": "integer",
"description": "上下标记:1 上 / -1 下,缺省 1"
},
"text_height": {
"type": "number",
"description": "字高,缺省 3.0"
},
"text_width_scale": {
"type": "number",
"description": "字宽比,缺省 0.75"
},
"p_scale": {
"type": "number",
"description": "出图比例,缺省 100"
}
},
"required": [
"target",
"points",
"text"
]
},
"backend": {
"type": "c++_dll",
"dll_name": "cad_mcp_aec.dll",
"factory_function": "AddAecPipeDimTool"
}
},
{
"name": "update_aec_pipe_dim",
"description": "改管线标注(AecDbEwPipeDim):上/下文字、样式、方向、上下标记、字高、字宽比、出图比例,只传要改的字段。位置点不能改,要挪就删了重建。",
"inputSchema": {
"type": "object",
"properties": {
"handle": {
"type": "string",
"description": "标注实体 handle"
},
"text": {
"type": "string"
},
"text_down": {
"type": "string"
},
"color": {
"type": "integer"
},
"dim_style": {
"type": "integer",
"description": "标注样式编号,缺省按 kind"
},
"dim_dir": {
"type": "integer",
"description": "标注方向,缺省 0"
},
"text_up_down": {
"type": "integer",
"description": "上下标记:1 上 / -1 下,缺省 1"
},
"text_height": {
"type": "number",
"description": "字高,缺省 3.0"
},
"text_width_scale": {
"type": "number",
"description": "字宽比,缺省 0.75"
},
"p_scale": {
"type": "number",
"description": "出图比例,缺省 100"
}
},
"required": [
"handle"
]
},
"backend": {
"type": "c++_dll",
"dll_name": "cad_mcp_aec.dll",
"factory_function": "UpdateAecPipeDimTool"
}
}
]
}
+10 -2
View File
@@ -32,6 +32,8 @@
| `PL_FZTJ` | 放置台阶 | `AecDbXStep` | `add/update_aec_xstep` |
| `PL_FZPD` | 放置坡道 | `AecDbAscent` | `add/update_aec_ascent` |
| `PL_FZSS` | 放置散水 | `AecDbXApron` | `add/update_aec_apron` |
| `PL_LSJM` | 绘制沟渠 | `AecDbEwPipeBase` | `add/update_aec_ditch` |
| 标注 8 个 | 序号/批标/洞口/套管/翼环/阀门/标注阀门/标注管件 | `AecDbEwPipeDim` | `add/update_aec_pipe_dim` + `kind` |
| `PL_PTLT` | 直线钢梯 | `AecDbLineStair` | `add/update_aec_line_stair` |
| `PL_FZHN` | 放置护栏 | `AecDbGuardBar` | `add/update_aec_guard_bar` |
| `PL_QXHN` | 曲线护栏 | `AecDbGuardBar` | 同上(`curve` 给已有曲线 handle) |
@@ -128,7 +130,13 @@
**实现方案**:每个一个 `add/update_aec_<x>`,参数"关键尺寸 + 对话框缺省";
需要墙/路径的(阳台/散水/沟渠)用 `wall` handle 或 `points` 提供路径。
### D. 标注 8 个(用户要求"要做")
### D. 标注 8 个 —— ✅ 已完成(一个工具 + kind)
> `add/update_aec_pipe_dim`(`AecDbEwPipeDim`,纯 2D)覆盖 8 个命令,`kind` 选
> seq / seq_batch / opening / casing / ring / valve / iso_valve / iso_fitting。
> 限制:标注文字命令里是自动拼的,这版要调用方传 `text`/`text_down`;引出点/文字点不能改。
原始调查记录:
| 命令 | 4字名 | 实体 | handler |
| --- | --- | --- | --- |
@@ -167,7 +175,7 @@
---
## 四、我建议的顺序(不冲突可按此推进)
## 四、我建议的顺序(已完成)
1. ~~楼梯族 8 个~~ ✅ 已完成
2. ~~普通门窗 `AecDbXOpening`~~ ✅ 已完成(`add/update_aec_window`);
+50 -23
View File
@@ -19,9 +19,10 @@ SourceCode/Code2026/cad_mcp_aec/
├── aec_mcp_roof_tools.cpp 屋顶:add/update_aec_roof(一个工具 + style,4 种样式,2 个)
├── aec_mcp_sfp_stair_tools.cpp 双分/双平行家族楼梯:add/update_aec_sfp_stair(一个工具 + kind,7 种,2 个)
├── aec_mcp_window_tools.cpp 普通门窗:add/update_aec_window(AecDbXOpening,2 个)
├── aec_mcp_attachment_tools.cpp 附属构件:阳台/台阶/坡道/散水(各 add+update,8 个)
├── 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 运行期配置(77 个工具:26 个 cad_mcp_plugins + 49 个本插件 + 2 个 lisp_inline)
└── mcp_config.json 运行期配置(81 个工具:26 个 cad_mcp_plugins + 53 个本插件 + 2 个 lisp_inline)
```
顶层 `cmakelists.txt` 里挂在 `cad_mcp_frame` 同一处:
@@ -50,7 +51,7 @@ if (IS_ZWCAD OR CAD_SDK_VERSION GREATER_EQUAL 20)
插件的头文件里必须保持默认的 `dllimport`。`cad_mcp_plugins` 里定义了它们,
那是因为它不使用这些类;本插件用了,定义了就变成"导出自己没有的符号"。
## 3. 工具清单(本插件 49 个;`mcp_config.json` 合计 77 个)
## 3. 工具清单(本插件 53 个;`mcp_config.json` 合计 81 个)
工具名和参数都按仓库既有工具的写法(`add_line` / `query_entities` / `get_entity_detail`):
**动词_名词、点用 `[x,y]` 或 `[x,y,z]` 数组、颜色用 `color`(ACI,256=ByLayer)**。
@@ -88,6 +89,8 @@ if (IS_ZWCAD OR CAD_SDK_VERSION GREATER_EQUAL 20)
| `add_aec_balcony` / `update_aec_balcony` | 建/改阳台(`AecDbBalcony`,`PL_FZYT`):墙 handle + 沿墙起止点 + 外侧点 + 挑出宽/栏杆高/板厚/梁尺寸 | `wall`/`start`/`end`/`side_point`、`width`/`rail_height`/`slab_thickness`/`girder_thickness`/`beam_*`/`bottom_elevation`/`material`/`factory`/`no` |
| `add_aec_xstep` / `update_aec_xstep` | 建/改台阶(`AecDbXStep`,`PL_FZTJ`):墙 handle + 沿墙起止点 + 外侧点 | `wall`/`start`/`end`/`side_point`、`width`/`steep_width`/`steep_height`/`steep_count`/`base_width`/`base_align`/`step_style`/`struct_style`/`bottom_elevation` |
| `add_aec_ascent` / `update_aec_ascent` | 建/改坡道(`AecDbAscent`,`PL_FZPD`):起点+终点 | `start`/`end`、`run_length`/`rise`/`width`/`side_width`/`top_elevation`/`align_left`/`align_right`/`nonslip` |
| `add_aec_ditch` / `update_aec_ditch` | 建/改沟渠(`AecDbEwPipeBase`,`PL_LSJM`):走向 `points` + U 形断面(总宽/总高/内底宽/坡度角/壁厚) | `points`、`width`/`height`/`inner_width`/`angle`/`wall_thickness`/`bottom_elevation`/`material`/`purpose` |
| `add_aec_pipe_dim` / `update_aec_pipe_dim` | 建/改管线标注(`AecDbEwPipeDim`,纯 2D):覆盖 序号/序号批标/洞口/套管/翼环/阀门/标注阀门/标注管件 8 个命令 | `target`、`kind`、`points`(引出点+文字点)、`text`/`text_down`、`dim_style`/`dim_dir`/`text_up_down`/`text_height`/`text_width_scale`/`p_scale` |
| `add_aec_apron` / `update_aec_apron` | 建/改散水(`AecDbXApron`,`PL_FZSS`):走向 `points` | `points`、`width`/`inside_thickness`/`outside_thickness`/`offset_from_wall`/`elevation` |
| `add_aec_window` / `update_aec_window` | 建/改普通门窗(`AecDbXOpening`,`PL_QTCC` 等"插入门窗"):给墙 handle + 定位点(自动投影到墙中心线)+ 门窗块 + 宽高窗台高,内部扣墙的 2D 洞口并挂到墙的关联件 | `wall`、`position`、`block`/`block_3d`、`type`(window/door)、`width`/`height`/`sill_height`/`thickness`、`no`/`name`/`material`/`factory` |
| `add_aec_sfp_stair` / `update_aec_sfp_stair` | 建/改双分·双平行家族楼梯(`SFPXStair` 一套数据,7 种实体 + `kind`):双平行/双分转角/双分三跑/交叉/剪刀/三角/矩形转角 | `kind`、`start`+`direction_point`、`height`/`steep_*`/`total_width`/`run_width`/`mid_run_width`/`well_width`/`rest_platform_width`/`platform_thickness`、扶手栏杆开关与高度、`material`/`rail_material`;update 另收边梯/中梯/剖切步数、内外边梁、上梯位置、踏步取齐、层显示、平台形状、加强筋、扶手/栏杆截面与伸出、双分系列的对称与 1~4 跑跑数跑宽 |
@@ -157,7 +160,7 @@ MCP 工具是通过 `PostMessage` 在主线程的消息里跑的,**不在命
## 5. 端到端实测(AutoCAD 2020 / R230 Debug)
做法:把仓库里的 `mcp_config.json` 拷到部署目录,用 `/b` 脚本加载 `cad_mcp_frame.arx`,
然后用裸 socket 打 JSON-RPC。`tools/list` 现在返回 **77** 个工具(本插件 49 个),
然后用裸 socket 打 JSON-RPC。`tools/list` 现在返回 **81** 个工具(本插件 53 个),
`%TEMP%\mcp_plugin_load.log` 里每个工厂都是 `[try ] ... create=... destroy=...` 成功。
**第一轮(只有 12 个工具时)的建/改实测**(仍然有效):
@@ -176,11 +179,11 @@ MCP 工具是通过 `PostMessage` 在主线程的消息里跑的,**不在命
| 类型不匹配 | ✅ `update_aec_wall` 传板的 handle → `-32004`「实体是 XSlab,不是 AecDbXWall」 |
| 不存在的 handle | ✅ `-32002` |
导出表:49 个工厂(`aec_mcp_entity_tools.cpp` 18 + `aec_mcp_stair_tools.cpp` 10 +
`aec_mcp_shape_tools.cpp` 5 + `aec_mcp_attachment_tools.cpp` 8 + `aec_mcp_roof_tools.cpp` 2 +
`aec_mcp_sfp_stair_tools.cpp` 2 + `aec_mcp_window_tools.cpp` 2 + `aec_mcp_query.cpp` 2)+
`Destroy_*` + `g_mcpPluginApiVersion`,与 `mcp_config.json` 里 `dll_name=cad_mcp_aec.dll`
的 49 条一一对应(少一条 backend 就不会被注册,见 §6)。
导出表:53 个工厂(`aec_mcp_entity_tools.cpp` 18 + `aec_mcp_stair_tools.cpp` 10 +
`aec_mcp_attachment_tools.cpp` 10 + `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_dim_tools.cpp` 2 +
`aec_mcp_query.cpp` 2)+ `Destroy_*` + `g_mcpPluginApiVersion`,与 `mcp_config.json` 里
`dll_name=cad_mcp_aec.dll` 的 53 条一一对应(少一条 backend 就不会被注册,见 §6)。
**后续各轮补的东西(都在 R230 Debug + pcf_1.dwg / 空图上实测过)**:
@@ -220,8 +223,8 @@ MCP 工具是通过 `PostMessage` 在主线程的消息里跑的,**不在命
`cad-mcp-frame.json`),重启 CAD。
注意:`set_debug_post_build()` 只拷构建产物,**配置文件不自动部署**,需要手工拷一次。
仓库里这份 `mcp_config.json` 是"26 个 `cad_mcp_plugins` + 49 个本插件 + 2 个 `lisp_inline`"
= 77 的合集,拷过去就等于全量替换。
仓库里这份 `mcp_config.json` 是"26 个 `cad_mcp_plugins` + 53 个本插件 + 2 个 `lisp_inline`"
= 81 的合集,拷过去就等于全量替换。
**每条工具都必须有 `backend`**(`{"type":"c++_dll","dll_name":"cad_mcp_aec.dll",
"factory_function":"AddAecShapeTool"}`):只写 `name`/`description`/`inputSchema`
@@ -239,9 +242,9 @@ MCP 工具是通过 `PostMessage` 在主线程的消息里跑的,**不在命
- 造型里只有 7 种基本体能 `update_aec_shape`;曲线类(loft/extrude/revolve/sweep/cut/weir)
的截面/路径没存在实体里,要改只能删了重建。
- 没有事务/撤销包装:调用即改库。批量改图建议先 `query_aec_entities` 拿 handle,再逐条 `update`。
- `mcp_config.json` 里的 77 个工具现在都能加载(`tools/list` = 77)。
其中 26 个属于 `cad_mcp_plugins`(含从 CadProject 合并过来的批量注/编辑类工具),
49 个属于本插件,2 个是 lisp_inline。
- `mcp_config.json` 里的 81 个工具现在都能加载(`tools/list` = 81)。
其中 26 个属于 `cad_mcp_plugins`(含从 CadProject 合并过来的批注/编辑类工具),
53 个属于本插件,2 个是 lisp_inline。
移植那批工具时踩到两个本仓库差异(已修,见那次提交):
1. 上游 `dll` 的写库工具没有文档锁,在本仓库的运行方式下会返回
`cannot open target space for write`(`eLockViolation`)—— 补了 `dwg_annotate::DocLock`;
@@ -310,7 +313,7 @@ MCP 工具是通过 `PostMessage` 在主线程的消息里跑的,**不在命
|PL_JFYJ|加方圆井|AecDbX3dPartEntity|add_aec_well|update_aec_well|
|PL_JYXJ|加异形井|AecDbX3dPartEntity|add_aec_well|update_aec_well|
|PL_JJSK|加集水坑|AecDbX3dPartEntity|add_aec_well|update_aec_well|
|PL_LSJM|绘制沟渠|AecDbEwPipeBase|(未实现)||
|PL_LSJM|绘制沟渠|AecDbEwPipeBase|add_aec_ditch|update_aec_ditch|
|PL_YXGZ|<-异形构筑|AecDbMultiPartEntity|add_aec_multipart|add_aec_shape|
|PL_DTYG|造型设计|AecDbX3dPart|add_aec_shape|update_aec_shape / delete_aec_shape|
|PL_FZZJ|放置支架|AecDbHolder|(未实现)||
@@ -333,18 +336,18 @@ MCP 工具是通过 `PostMessage` 在主线程的消息里跑的,**不在命
|PL_WGZZ|弯管支座|AecDbPipeHanger|(未实现)||
|PL_SBLG|设备连管|AecDbEwPipe|add_aec_pipe|update_aec_pipe|
|PL_RYGZ|任意管嘴|AecDbEwEquipment|(未实现)||
|PL_XHBZ|序号标注|AecDbEwPipeDim|(未实现)||
|PL_XHPB|序号批标|AecDbEwPipeDim|(未实现)||
|PL_XHBZ|序号标注|AecDbEwPipeDim|add_aec_pipe_dim(kind=seq)|update_aec_pipe_dim|
|PL_XHPB|序号批标|AecDbEwPipeDim|add_aec_pipe_dim(kind=seq_batch)|update_aec_pipe_dim|
|DI_JDBZ|角度标注|AecDbDimension|(未实现)||
|DI_JDBZ|角度标注|AecDbX3dPart|(内部构件,不单独建)||
|DI_JDBZ|角度标注|AecDbXEquipment|(未实现)||
|PL_DKBZ|洞口标注|AecDbEwPipeDim|(未实现)||
|PL_TGBZ|套管标注|AecDbEwPipeDim|(未实现)||
|PL_YHBZ|翼环标注|AecDbEwPipeDim|(未实现)||
|PL_FMBZ|阀门标注|AecDbEwPipeDim|(未实现)||
|PL_DKBZ|洞口标注|AecDbEwPipeDim|add_aec_pipe_dim(kind=opening)|update_aec_pipe_dim|
|PL_TGBZ|套管标注|AecDbEwPipeDim|add_aec_pipe_dim(kind=casing)|update_aec_pipe_dim|
|PL_YHBZ|翼环标注|AecDbEwPipeDim|add_aec_pipe_dim(kind=ring)|update_aec_pipe_dim|
|PL_FMBZ|阀门标注|AecDbEwPipeDim|add_aec_pipe_dim(kind=valve)|update_aec_pipe_dim|
|HA_FBBZ|风管标注|AecDbEwPipeDim|(未实现)||
|IS_BZFM|标注阀门|AecDbEwPipeDim|(未实现)||
|IS_GZGJ|标注管件|AecDbEwPipeDim|(未实现)||
|IS_BZFM|标注阀门|AecDbEwPipeDim|add_aec_pipe_dim(kind=iso_valve)|update_aec_pipe_dim|
|IS_GZGJ|标注管件|AecDbEwPipeDim|add_aec_pipe_dim(kind=iso_fitting)|update_aec_pipe_dim|
### 8.1 你点名的几类:现状与实现路线
@@ -867,3 +870,27 @@ bottom_elevation = 900;`update_aec_window` 改 1800×2100/窗台 600/编号 C1
还没做:**沟渠 `PL_LSJM`**(`AecDbEwPipeBase`)—— 断面由 `CHZGQDlg::GetSection()` 从
宽/高/坡度角/壁厚现算一个 region,再沿 jig 路径扫;要先把 `GetSection` 的构造逻辑搬出来。
**第六批:沟渠 + 标注(AecDbEwPipeDim)**
**沟渠 `PL_LSJM`(`AecDbEwPipeBase`)**:断面是 `CHZGQDlg::GetSection()` 用 9 个点现算的 U 形槽
(总宽 W / 总高 H / 内底宽 V / 侧壁坡度角 / 壁厚 T),工具里照抄成 `BuildDitchRegion`,
再 `SetSection(reg, cen)` + `SetBaseCurve(路径)` + `KEY_NAME=沟渠` + `KEY_2DSTYLE=2` +
`KEY_CENNODRAW` + `KEY_W/H/V/Angle/T`。update 改断面时重建 region,只改底标高时把路径整体抬高。
**标注 `AecDbEwPipeDim`(8 个命令共用)**:创建序列都一样 ——
`AddAecDbWEntity(被标注实体)` + `SetDimStyle` / `SetDimDir` / `SetDimTextUporDownFlag` +
文字样式/图层(`LAY_PP3D_DIM` + `Pipe_Dim`)+ `SetPScale` / `SetTextHeight(3.0)` /
`SetTextWidthScale(0.75)` + `AddDimText(上, 下)` + `AppendPoint(引出点)` + `AppendPoint(文字点)`。
工具做成 `add_aec_pipe_dim` + `kind`(seq / seq_batch / opening / casing / ring / valve /
iso_valve / iso_fitting),`update_aec_pipe_dim` 改文字/样式/字高。
**限制**:命令里的标注文字是按被标注实体的专业数据**自动拼**的
(如 `预留D%d洞口` / `预留%dx%d洞口` / `中心标高:%.3f`),这版要求调用方自己把 `text` /
`text_down` 传进来;自动拼文字没做(8 个命令各有一套拼法)。
另外标注的引出点/文字点目前不能改,要挪就删了重建。
**实测**(R230 Debug,空图):沟渠(L 形走向、W800/H800/V700/T10、底标高 −500)
→ handle `290`,bbox 0~6400 × −400~3000;改 W1000/H900/T20 生效。
管线上加序号标注(文字 `1`、字高 250)→ `311`,改成 `7` + 下排 `中心标高 1.000` + 字高 300 正确;
再加一个洞口标注(`预留D250洞口` + 中心标高)→ `312`。