docs: 工具清单与对照表补井族(第 5 项) #136

Merged
gjm merged 2 commits from company-desktop/company-desktop-computer/feat-aec-wells-complete AGit into main 2026-10-30 19:59:15 +08:00
4 changed files with 496 additions and 57 deletions

No files matched your search

@@ -1430,68 +1430,214 @@ namespace
delete pBase;
}
// 井:先按 1.1 倍板厚开洞,再叠井体(与 PL_JFYJ / PL_JYZJ 一致)
bool ApplyWell(AecDbX3dPartEntity* pPart, const AcGePoint3d& ptCenIn,
double dSlabThickDefault, const nlohmann::json& a, bool bCreate, std::wstring& err)
// 井的四种形态(对应菜单命令 方井 PL_JFZJ / 圆井 PL_JYZJ / 方圆井 PL_JFYJ / 异形井 PL_JYXJ)
enum WellShape
{
const std::wstring sShape = hasKey(a, "shape") ? wstrOr(a, "shape", L"rect") : L"rect";
const bool bCircle = (sShape == L"circle");
kWellRect = 0, //方台井:矩形上下口
kWellCircle, //圆台井:圆形上下口
kWellRectCircle, //方圆井:上口矩形、下口圆
kWellPolygon //异形偏心井:上下口都是点串
};
const double dH = numOr(a, "height", 0.0);
const double dT = numOr(a, "wall_thickness", 0.0);
const double dSlabT = numOr(a, "slab_thickness", dSlabThickDefault);
if (dH <= 0.0 || dT <= 0.0)
bool ParseWellShape(const nlohmann::json& a, WellShape& eShape, std::wstring& err)
{
const std::wstring s = hasKey(a, "shape") ? wstrOr(a, "shape", L"rect") : L"rect";
if (s == L"rect") { eShape = kWellRect; return true; }
if (s == L"circle") { eShape = kWellCircle; return true; }
if (s == L"rect_circle") { eShape = kWellRectCircle; return true; }
if (s == L"polygon") { eShape = kWellPolygon; return true; }
err = L"shape 只支持 rect(方井)/ circle(圆井)/ rect_circle(方圆井)/ polygon(异形井)";
return false;
}
// update 时按实体自己的名字判断它属于哪种井(名字由 SetAsWell 写进实体)
bool ShapeFromWellName(const CString& sName, WellShape& eShape)
{
if (sName.CompareNoCase(_T("方台井")) == 0) { eShape = kWellRect; return true; }
if (sName.CompareNoCase(_T("圆台井")) == 0) { eShape = kWellCircle; return true; }
if (sName.CompareNoCase(_T("方圆井")) == 0) { eShape = kWellRectCircle; return true; }
if (sName.CompareNoCase(_T("异形偏心井")) == 0) { eShape = kWellPolygon; return true; }
return false;
}
// 点串 [[x,y],...] -> "x,y@bulge,..."(闭合),与 CoreTools::PolylineToString 一致
bool PointsToScript(const nlohmann::json& arr, const nlohmann::json& bulges,
CString& sOut, AcGePoint3d& ptCen)
{
if (!arr.is_array() || arr.size() < 3) return false;
double dMinX = 1e300, dMinY = 1e300, dMaxX = -1e300, dMaxY = -1e300;
double dFirstX = 0.0, dFirstY = 0.0, dLastX = 0.0, dLastY = 0.0;
CString sAll;
for (size_t i = 0; i < arr.size(); ++i)
{
err = L"井需要 height 与 wall_thickness,且都 > 0";
return false;
const nlohmann::json& e = arr[i];
if (!e.is_array() || e.size() < 2) return false;
const double x = e[0].get<double>();
const double y = e[1].get<double>();
double b = 0.0;
if (bulges.is_array() && i < bulges.size() && bulges[i].is_number())
b = bulges[i].get<double>();
CString sOne;
sOne.Format(_T("%.9f,%.9f@%.9f,"), x, y, b);
sAll += sOne;
if (x < dMinX) dMinX = x;
if (y < dMinY) dMinY = y;
if (x > dMaxX) dMaxX = x;
if (y > dMaxY) dMaxY = y;
if (i == 0) { dFirstX = x; dFirstY = y; }
dLastX = x; dLastY = y;
}
if (fabs(dLastX - dFirstX) > 1e-9 || fabs(dLastY - dFirstY) > 1e-9)
{
CString sOne;
sOne.Format(_T("%.9f,%.9f@0.0,"), dFirstX, dFirstY);
sAll += sOne;
}
sAll.TrimRight(_T(','));
ptCen.set((dMinX + dMaxX) * 0.5, (dMinY + dMaxY) * 0.5, 0.0);
sOut = sAll;
return !sOut.IsEmpty();
}
// 从实体专业数据里取一个 double(update 时没传参数就沿用原值)
double XDataD(const AecDbObjXDataMap* pX, const TCHAR* pszKey, double dDef)
{
double d = 0.0;
if (pX != NULL && pX->GetAt(pszKey, d))
return d;
return dDef;
}
// 井:先开洞、再叠井体。序列与 DBL_AEC_X3DPART 里各井的修改分支一致:
// 洞口中心 = 板底标高 + 半板厚;井体原点 = 板底标高。
bool ApplyWell(AecDbX3dPartEntity* pPart, WellShape eShape, const AcGePoint3d& ptWellOrg,
double dSlabT, double dSlabBomEl, const nlohmann::json& a, bool bCreate, std::wstring& err)
{
if (dSlabT <= 0.0)
{
err = L"取不到板厚,请显式给 slab_thickness";
return false;
}
AcGePoint3d ptCen = ptCenIn;
AcGeVector2d vtOffset(0.0, 0.0);
if (hasKey(a, "offset_x") || hasKey(a, "offset_y"))
vtOffset.set(numOr(a, "offset_x", 0.0), numOr(a, "offset_y", 0.0));
// 没传就沿用实体里已有的(update 场景);新建时必须给
const AecDbObjXDataMap* pX = pPart->GetSpecialtyData(AcDb::kForRead);
const double dH = numOr(a, "height", XDataD(pX, _T("dH"), 0.0));
const double dT = numOr(a, "wall_thickness",
XDataD(pX, _T("dt"), XDataD(pX, _T("dThick"), 0.0)));
if (dH <= 0.0 || dT <= 0.0)
{
err = L"井需要 height 与 wall_thickness,且都 > 0";
return false;
}
if (bCreate)
pPart->GetSpecialtyData()->SetAt(KEY_SETASWELL, TRUE);
if (bCircle)
AcGeVector3d vtZ = AcGeVector3d::kZAxis;
AcGePoint3d ptHole = ptWellOrg;
ptHole.z = dSlabBomEl + 0.5 * dSlabT;
AcGeVector2d vtOffset(0.0, 0.0);
if (hasKey(a, "offset_x") || hasKey(a, "offset_y"))
vtOffset.set(numOr(a, "offset_x", 0.0), numOr(a, "offset_y", 0.0));
if (eShape == kWellRect)
{
const double dD = numOr(a, "diameter", 0.0);
const double dd = numOr(a, "bottom_diameter", dD);
const double dL = numOr(a, "length", XDataD(pX, _T("dL"), 0.0));
const double dW = numOr(a, "width", XDataD(pX, _T("dW"), 0.0));
const double dL1 = numOr(a, "bottom_length", XDataD(pX, _T("dL1"), dL));
const double dW1 = numOr(a, "bottom_width", XDataD(pX, _T("dW1"), dW));
if (dL <= 0.0 || dW <= 0.0)
{
err = L"方井需要 length 与 width,且都 > 0";
return false;
}
pPart->SetAsHole(ptHole, dL, dW, 1.1 * dSlabT, vtZ);
pPart->SetAsWell(ptWellOrg, dL, dW, dL1, dW1, dH, dT, dSlabT, vtOffset, true);
}
else if (eShape == kWellCircle)
{
const double dD = numOr(a, "diameter", 2.0 * XDataD(pX, _T("dR"), 0.0));
const double dd = numOr(a, "bottom_diameter", 2.0 * XDataD(pX, _T("dr"), 0.5 * dD));
if (dD <= 0.0)
{
err = L"圆井需要 diameter > 0";
return false;
}
pPart->SetAsHole(ptCen, 0.5 * dD, 1.1 * dSlabT, AcGeVector3d::kZAxis);
ptCen.z -= 0.5 * dSlabT;
pPart->SetAsWell(ptCen, 0.5 * dD, 0.5 * dd, dH, dT, dSlabT, vtOffset, true);
pPart->SetAsHole(ptHole, 0.5 * dD, 1.1 * dSlabT, vtZ);
pPart->SetAsWell(ptWellOrg, 0.5 * dD, 0.5 * dd, dH, dT, dSlabT, vtOffset, true);
}
else if (eShape == kWellRectCircle)
{
const double dL = numOr(a, "length", XDataD(pX, _T("dL"), 0.0));
const double dW = numOr(a, "width", XDataD(pX, _T("dW"), 0.0));
const double dD = numOr(a, "diameter", numOr(a, "bottom_diameter",
2.0 * XDataD(pX, _T("dr"), 0.0)));
if (dL <= 0.0 || dW <= 0.0 || dD <= 0.0)
{
err = L"方圆井需要 length / width / diameter(下口圆直径),且都 > 0";
return false;
}
// 命令里方圆井的洞按 1.2 倍板厚,且偏移只用 X 方向一个值
pPart->SetAsHole(ptHole, dL, dW, 1.2 * dSlabT, vtZ);
pPart->SetAsWell(ptWellOrg, dL, dW, 0.5 * dD, dH, dT, dSlabT,
numOr(a, "offset_x", 0.0), true);
}
else
{
const double dL = numOr(a, "length", 0.0);
const double dW = numOr(a, "width", 0.0);
const double dL1 = numOr(a, "bottom_length", dL);
const double dW1 = numOr(a, "bottom_width", dW);
if (dL <= 0.0 || dW <= 0.0)
// 异形井:上下口都是点串;没给就用实体里已经存的(修改时不改截面)
CString sTop, sBom;
AcGePoint3d ptTmp;
const nlohmann::json jBulg = hasKey(a, "bulges") ? a["bulges"] : nlohmann::json();
if (hasKey(a, "top_points"))
{
err = L"方圆井需要 length 与 width,且都 > 0";
if (!PointsToScript(a["top_points"], jBulg, sTop, ptTmp))
{
err = L"top_points 至少 3 个点,格式 [[x,y],...]";
return false;
}
}
else
{
pPart->GetSpecialtyData()->GetAt(_T("TopScr"), sTop);
}
if (hasKey(a, "bottom_points"))
{
if (!PointsToScript(a["bottom_points"], jBulg, sBom, ptTmp))
{
err = L"bottom_points 至少 3 个点,格式 [[x,y],...]";
return false;
}
}
else
{
pPart->GetSpecialtyData()->GetAt(_T("BomScr"), sBom);
}
if (sTop.IsEmpty() || sBom.IsEmpty())
{
err = L"异形井需要 top_points 与 bottom_points(新建时必填)";
return false;
}
pPart->SetAsHole(ptCen, dL, dW, 1.1 * dSlabT, AcGeVector3d::kZAxis);
ptCen.z -= 0.5 * dSlabT;
pPart->SetAsWell(ptCen, dL, dW, dL1, dW1, dH, dT, dSlabT, vtOffset, true);
pPart->SetAsHole(ptHole, (LPCTSTR)sTop, 1.1 * dSlabT, vtZ);
pPart->SetAsWell((LPCTSTR)sTop, (LPCTSTR)sBom, dH, dT, dSlabT, dSlabBomEl, true);
}
if (hasKey(a, "no"))
pPart->GetSpecialtyData()->SetAt(KEY_NO, wstrOr(a, "no", L"").c_str());
if (hasKey(a, "remark"))
pPart->GetSpecialtyData()->SetAt(KEY_REM, wstrOr(a, "remark", L"").c_str());
if (hasKey(a, "purpose"))
pPart->GetSpecialtyData()->SetAt(KEY_PURPOSE, wstrOr(a, "purpose", L"").c_str());
return true;
}
@@ -1932,9 +2078,9 @@ public:
std::string private_description() const override
{
return "在池底板上加井(对应菜单命令 方圆井 PL_JFYJ / 圆井 PL_JYZJ):给母体板 handle、"
"井位与尺寸,内部先开洞再叠井体(AecDbX3dPartEntity),自动挂到板下(LAY_HOLE)。"
"shape=rect 方圆井 / circle 圆井,尺寸用图纸单位。";
return "在池底板上加井(对应菜单命令 方井 PL_JFZJ / 圆井 PL_JYZJ / 方圆井 PL_JFYJ / 异形井 PL_JYXJ):"
"给母体板 handle、井位与尺寸,内部先开洞再叠井体(AecDbX3dPartEntity),自动挂到板下(LAY_HOLE)。"
"shape=rect 方井 / circle 圆井 / rect_circle 方圆井 / polygon 异形井。尺寸用图纸单位。";
}
nlohmann::json private_input_schema() const override
@@ -1943,21 +2089,28 @@ public:
"type": "object",
"properties": {
"host": { "type": "string", "description": "母体板(池底板)的 handle" },
"shape": { "type": "string", "enum": [ "rect", "circle" ], "description": "rect=方圆井(缺省)/ circle=圆井" },
"shape": { "type": "string", "enum": [ "rect", "circle", "rect_circle", "polygon" ],
"description": "rect=方井(缺省,上口矩形/下口矩形)/ circle=圆井 / rect_circle=方圆井(上口矩形、下口圆)/ polygon=异形井(上下口点串)" },
"position": { "type": "array", "items": { "type": "number" }, "description": "井位 [x,y]" },
"length": { "type": "number", "description": "井长(X 向,rect)" },
"width": { "type": "number", "description": "井宽(Y 向,rect)" },
"bottom_length": { "type": "number", "description": "井底长(缺省=length)" },
"bottom_width": { "type": "number", "description": "井底宽(缺省=width)" },
"diameter": { "type": "number", "description": "井直径(circle)" },
"bottom_diameter": { "type": "number", "description": "井底直径(缺省=diameter)" },
"length": { "type": "number", "description": "上口长(X 向,rect / rect_circle)" },
"width": { "type": "number", "description": "上口宽(Y 向,rect / rect_circle)" },
"bottom_length": { "type": "number", "description": "下口长(缺省=length,rect)" },
"bottom_width": { "type": "number", "description": "下口宽(缺省=width,rect)" },
"diameter": { "type": "number", "description": "圆井直径(circle)/ 方圆井下口圆直径(rect_circle)" },
"bottom_diameter": { "type": "number", "description": "圆井下口直径(缺省=diameter,circle)" },
"top_points": { "type": "array", "items": { "type": "array", "items": { "type": "number" } },
"description": "异形井上口轮廓 [[x,y],...](polygon,至少 3 点)" },
"bottom_points": { "type": "array", "items": { "type": "array", "items": { "type": "number" } },
"description": "异形井下口轮廓 [[x,y],...](polygon,至少 3 点)" },
"bulges": { "type": "array", "items": { "type": "number" }, "description": "异形井轮廓的凸度(可选)" },
"height": { "type": "number", "description": "井深" },
"wall_thickness": { "type": "number", "description": "井壁厚" },
"slab_thickness": { "type": "number", "description": "板厚(缺省取母体板厚)" },
"offset_x": { "type": "number", "description": "井心偏移 X(缺省 0)" },
"offset_y": { "type": "number", "description": "井心偏移 Y(缺省 0)" },
"offset_y": { "type": "number", "description": "井心偏移 Y(缺省 0;方圆井只用 X)" },
"no": { "type": "string", "description": "井编号" },
"remark": { "type": "string", "description": "备注/用途" },
"remark": { "type": "string", "description": "备注(方圆井/方井/圆井)" },
"purpose": { "type": "string", "description": "用途(异形井)" },
"layer": { "type": "string", "description": "图层,缺省 LAY_HOLE" }
},
"required": [ "host", "position", "height", "wall_thickness" ]
@@ -1985,25 +2138,36 @@ public:
utf8ToWstr(sCls) + L",不是板(AecDbXSlab)");
}
AcGePoint3d ptCen;
if (!readPoint(args, "position", ptCen))
WellShape eShape = kWellRect;
std::wstring err;
if (!ParseWellShape(args, eShape, err))
{
pSlab->close();
return errJson(kErrBadParam, err);
}
AcGePoint3d ptWellOrg;
if (!readPoint(args, "position", ptWellOrg))
{
pSlab->close();
return errJson(kErrBadParam, L"缺少 position(井位 [x,y])");
}
// z:板底标高 + 半板厚
// 板底标高与板厚:命令里用 GetBasinSlabData
PoolData data;
::memset(&data, 0, sizeof(PoolData));
const double dSlabT = numOr(args, "slab_thickness", pSlab->GetThick());
double dSlabT = numOr(args, "slab_thickness", pSlab->GetThick());
double dSlabBomEl = ptWellOrg.z;
if (pSlab->GetBasinSlabData(data))
ptCen.z = data.m_dBomEl + 0.5 * data.m_dBomThick;
else
ptCen.z += 0.5 * dSlabT;
{
if (!hasKey(args, "slab_thickness") && data.m_dBomThick > 1e-9)
dSlabT = data.m_dBomThick;
dSlabBomEl = data.m_dBomEl;
}
ptWellOrg.z = dSlabBomEl;
AecDbX3dPartEntity* pPart = new AecDbX3dPartEntity();
std::wstring err;
if (!ApplyWell(pPart, ptCen, dSlabT, args, true, err))
if (!ApplyWell(pPart, eShape, ptWellOrg, dSlabT, dSlabBomEl, args, true, err))
{
delete pPart;
pSlab->close();
@@ -2049,3 +2213,112 @@ public:
}
};
EXPORT_MCP_TOOL(ToolAddWell, AddAecWellTool)
class ToolUpdateWell : public mcp_Tool
{
public:
std::string private_name() const override { return "update_aec_well"; }
std::string private_description() const override
{
return "修改已有井(方井/圆井/方圆井/异形井):只传要改的字段。"
"按实体自身的类型重建井体(对应 DBL_AEC_X3DPART 里各井的修改分支),"
"改完会顺带刷新母体板的 3D。异形井不给 top_points/bottom_points 就沿用原截面。";
}
nlohmann::json private_input_schema() const override
{
return nlohmann::json::parse(R"({
"type": "object",
"properties": {
"handle": { "type": "string", "description": "井实体的 handle" },
"position": { "type": "array", "items": { "type": "number" }, "description": "新井位 [x,y](可选,z 自动按板底标高)" },
"length": { "type": "number" }, "width": { "type": "number" },
"bottom_length": { "type": "number" }, "bottom_width": { "type": "number" },
"diameter": { "type": "number" }, "bottom_diameter": { "type": "number" },
"top_points": { "type": "array", "items": { "type": "array", "items": { "type": "number" } } },
"bottom_points": { "type": "array", "items": { "type": "array", "items": { "type": "number" } } },
"bulges": { "type": "array", "items": { "type": "number" } },
"height": { "type": "number" }, "wall_thickness": { "type": "number" },
"slab_thickness": { "type": "number" },
"offset_x": { "type": "number" }, "offset_y": { "type": "number" },
"no": { "type": "string" }, "remark": { "type": "string" }, "purpose": { "type": "string" }
},
"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"拿不到图纸写锁(有别的命令在跑?)");
nlohmann::json err;
AecDbX3dPartEntity* pPart = openTyped<AecDbX3dPartEntity>(args, L"AecDbX3dPartEntity", err);
if (pPart == NULL) return err;
// 类型由实体自己的名字决定(SetAsWell 写进去的)
const CString sName = pPart->GetName();
WellShape eShape = kWellRect;
if (!ShapeFromWellName(sName, eShape))
{
pPart->close();
return errJson(kErrWrongType, L"这个实体不是井(名字:" + utf8ToWstr(acharToUtf8(sName)) + L")");
}
// 井心:命令里是 GetOrgPoint(true),并先 ResetMove()
AcGePoint3d ptWellOrg = pPart->GetOrgPoint(true);
pPart->ResetMove();
if (readPoint(args, "position", ptWellOrg))
{
// 用户给了新位置,z 稍后用板底标高覆盖
}
// 母体板:拿板厚与板底标高(跟命令一致)
AcDbObjectId idHost;
pPart->GetSpecialtyData()->GetAt(KEY_ASSOIC, idHost);
AecDbXSlab* pSlabR = NULL;
AecDbXSlab* pSlabW = NULL;
PoolData data;
::memset(&data, 0, sizeof(PoolData));
double dSlabT = numOr(args, "slab_thickness", 0.0);
if (!idHost.isNull())
{
if (acdbOpenObject(pSlabR, idHost, AcDb::kForRead) == Acad::eOk && pSlabR != NULL)
{
if (pSlabR->GetBasinSlabData(data))
{
ptWellOrg.z = data.m_dBomEl;
if (dSlabT <= 0.0) dSlabT = data.m_dBomThick;
}
}
}
if (dSlabT <= 0.0)
{
// 板读不到就退回实体存的板厚(SetAsWell 会写 dBomt/dBomT/dBomThick)
pPart->GetSpecialtyData()->GetAt(_T("dBomt"), dSlabT);
if (dSlabT <= 0.0) pPart->GetSpecialtyData()->GetAt(_T("dBomT"), dSlabT);
if (dSlabT <= 0.0) pPart->GetSpecialtyData()->GetAt(_T("dBomThick"), dSlabT);
}
std::wstring msg;
if (!ApplyWell(pPart, eShape, ptWellOrg, dSlabT, ptWellOrg.z, args, false, msg))
{
if (pSlabR != NULL) pSlabR->close();
pPart->close();
return errJson(kErrBadParam, msg);
}
// 井变了,母体板的洞也要重画(命令里是 ReCreateDraw3d)
if (!idHost.isNull() && acdbOpenObject(pSlabW, idHost, AcDb::kForWrite) == Acad::eOk && pSlabW != NULL)
{
pSlabW->ReCreateDraw3d();
pSlabW->close();
}
if (pSlabR != NULL) pSlabR->close();
return finishUpdate(pPart, args["handle"].get<std::string>(), "well");
}
};
EXPORT_MCP_TOOL(ToolUpdateWell, UpdateAecWellTool)
@@ -156,7 +156,11 @@ nlohmann::json paramsOf(AcDbEntity* pEnt, const std::string& sType)
AecDbX3dPartEntity* pPart = AecDbX3dPartEntity::cast(pEnt);
if (pPart == NULL) return p;
// 名字用来区分:开洞 / 套管 / 方台井 / 圆台井 / 方圆井 / 异形偏心井 …
CString s;
s = pPart->GetName();
if (!s.IsEmpty()) p["name"] = acharToUtf8(s);
if (pPart->GetAt(KEY_NO, s)) p["no"] = acharToUtf8(s);
if (pPart->GetAt(KEY_FORUSE, s)) p["for_use"] = acharToUtf8(s);
+133 -4
View File
@@ -2226,7 +2226,7 @@
},
{
"name": "add_aec_well",
"description": "在池底板上加井(对应菜单命令 方圆井 PL_JFYJ / 圆井 PL_JYZJ):给母体板 handle、井位与尺寸,内部先开洞再叠井体(AecDbX3dPartEntity),自动挂到板下(LAY_HOLE)。shape=rect 方圆井 / circle 圆井,尺寸用图纸单位。返回井实体 handle。",
"description": "在池底板上加井(对应菜单命令 方井 PL_JFZJ / 圆井 PL_JYZJ / 方圆井 PL_JFYJ / 异形井 PL_JYXJ):给母体板 handle、井位与尺寸,内部先开洞再叠井体(AecDbX3dPartEntity),自动挂到板下(LAY_HOLE)。shape=rect 方井 / circle 圆井 / rect_circle 方圆井 / polygon 异形井。尺寸用图纸单位。",
"inputSchema": {
"type": "object",
"properties": {
@@ -2238,9 +2238,11 @@
"type": "string",
"enum": [
"rect",
"circle"
"circle",
"rect_circle",
"polygon"
],
"description": "rect=方圆井(缺省)/ circle=圆井"
"description": "rect=方井(缺省,上下口都矩形)/ circle=圆井 / rect_circle=方圆井(上口矩形、下口圆)/ polygon=异形井(上下口点串)"
},
"position": {
"type": "array",
@@ -2267,7 +2269,7 @@
},
"diameter": {
"type": "number",
"description": "井直径(circle)"
"description": "圆井直径(circle)/ 方圆井下口圆直径(rect_circle)"
},
"bottom_diameter": {
"type": "number",
@@ -2300,6 +2302,37 @@
"layer": {
"type": "string",
"description": "图层,缺省 LAY_HOLE"
},
"top_points": {
"type": "array",
"items": {
"type": "array",
"items": {
"type": "number"
}
},
"description": "异形井上口轮廓 [[x,y],...](polygon,至少 3 点)"
},
"bottom_points": {
"type": "array",
"items": {
"type": "array",
"items": {
"type": "number"
}
},
"description": "异形井下口轮廓 [[x,y],...](polygon,至少 3 点)"
},
"bulges": {
"type": "array",
"items": {
"type": "number"
},
"description": "异形井轮廓的凸度(可选)"
},
"purpose": {
"type": "string",
"description": "用途(异形井)"
}
},
"required": [
@@ -2314,6 +2347,102 @@
"dll_name": "cad_mcp_aec.dll",
"factory_function": "AddAecWellTool"
}
},
{
"name": "update_aec_well",
"description": "修改已有井(方井/圆井/方圆井/异形井):只传要改的字段。按实体自身的类型重建井体(对应 DBL_AEC_X3DPART 里各井的修改分支),改完会顺带刷新母体板的 3D。异形井不给 top_points/bottom_points 就沿用原截面。",
"inputSchema": {
"type": "object",
"properties": {
"handle": {
"type": "string",
"description": "井实体的 handle"
},
"position": {
"type": "array",
"items": {
"type": "number"
},
"description": "新井位 [x,y](可选,z 自动按板底标高)"
},
"length": {
"type": "number"
},
"width": {
"type": "number"
},
"bottom_length": {
"type": "number"
},
"bottom_width": {
"type": "number"
},
"diameter": {
"type": "number"
},
"bottom_diameter": {
"type": "number"
},
"top_points": {
"type": "array",
"items": {
"type": "array",
"items": {
"type": "number"
}
},
"description": "异形井上口轮廓(可选)"
},
"bottom_points": {
"type": "array",
"items": {
"type": "array",
"items": {
"type": "number"
}
},
"description": "异形井下口轮廓(可选)"
},
"bulges": {
"type": "array",
"items": {
"type": "number"
}
},
"height": {
"type": "number"
},
"wall_thickness": {
"type": "number"
},
"slab_thickness": {
"type": "number"
},
"offset_x": {
"type": "number"
},
"offset_y": {
"type": "number"
},
"no": {
"type": "string"
},
"remark": {
"type": "string"
},
"purpose": {
"type": "string"
}
},
"required": [
"handle"
]
},
"backend": {
"type": "c++_dll",
"dll_name": "cad_mcp_aec.dll",
"factory_function": "UpdateAecWellTool"
}
}
]
}
+35 -2
View File
@@ -44,20 +44,24 @@ if (IS_ZWCAD OR CAD_SDK_VERSION GREATER_EQUAL 20)
插件的头文件里必须保持默认的 `dllimport`。`cad_mcp_plugins` 里定义了它们,
那是因为它不使用这些类;本插件用了,定义了就变成"导出自己没有的符号"。
## 3. 工具清单(12 个)
## 3. 工具清单(20 个)
工具名和参数都按仓库既有工具的写法(`add_line` / `query_entities` / `get_entity_detail`):
**动词_名词、点用 `[x,y]` 或 `[x,y,z]` 数组、颜色用 `color`(ACI,256=ByLayer)**。
| 工具 | 作用 | 关键参数 |
| --- | --- | --- |
| `query_aec_entities` | 列出管道/墙/板/柱/梁(handle、类型、图层、起终点、包围盒),分页 | `type`(all/pipe/wall/slab/column/beam)、`space`、`limit`、`offset` |
| `query_aec_entities` | 列出本插件支持的实体(handle、类型、图层、起终点、包围盒),分页 | `type`(all/pipe/wall/slab/column/beam/climb_stair/fitting/opening)、`space`、`limit`、`offset` |
| `get_aec_entity_detail` | 按 handle 取详细参数 | `handle` |
| `add_aec_pipe` / `update_aec_pipe` | 建/改管道(`AecDbEwPipe`) | `start`/`end`、`dn_mm`、`od_mm`、`wall_thickness_mm`、`system`、`material`、`color`、`layer`、`space` |
| `add_aec_wall` / `update_aec_wall` | 建/改墙(`AecDbXWall`) | `start`/`end`、`thickness`、`height`、`bottom_elevation`、`align`(left/center/right) |
| `add_aec_slab` / `update_aec_slab` | 建/改板(`AecDbXSlab`) | `points`([[x,y],...])、`thickness`、`bottom_elevation`、`center` |
| `add_aec_column` / `update_aec_column` | 建/改柱(`AecDbColumn`) | `position`、`height`、`length`、`width`、`rotation_deg` |
| `add_aec_beam` / `update_aec_beam` | 建/改梁(`AecDbBeam`) | `start`/`end`、`width`、`height` |
| `add_aec_climb_stair` / `update_aec_climb_stair` | 建/改爬梯(`AecDbClimbStair`) | `start`/`end`、`width`、`cage_diameter`、`height`、`bar_diameter`、`step_height`、`facing` |
| `add_aec_fitting` / `update_aec_fitting` | 建/改管件(`AecDbEwFitting`) | `position`、`direction`/`branch_direction`、`dn_mm`/`od_mm`/`wall_thickness_mm`、`type`(elbow/tee/reduce/flange/cap/…) |
| `add_aec_opening` / `update_aec_opening` | 板/墙上开洞(`AecDbX3dPartEntity`) | `host`、`shape`(circle/rect/polygon)、`position`、`diameter` 或 `width`/`height`,异形洞用 `points` |
| `add_aec_well` / `update_aec_well` | 池底板上加/改井(方井/圆井/方圆井/异形井) | `host`、`shape`(rect/circle/rect_circle/polygon)、`position`、`length`/`width`/`diameter`、异形井用 `top_points`/`bottom_points`、`height`、`wall_thickness` |
**单位约定**(写进了每个工具的 description):
@@ -356,3 +360,32 @@ MCP 工具是通过 `PostMessage` 在主线程的消息里跑的,**不在命
建议顺序(按"参数清晰 + 下游价值"):**管件 → 参数化设备 → 设备(取库) → 开洞 → 井**。
管件之所以排第一:图纸里数量最多,而且它自己就带着 3D 缓存(`Add3DBuffer` 96 处),
做完工具后还能顺带把"缓存存盘"的收益接到真实对象上。
### 8.2 井族(第 5 项):4 种井 = 1 个实体类,靠"名字"分派
`PL_JFZJ 方井 / PL_JYZJ 圆井 / PL_JFYJ 方圆井 / PL_JYXJ 异形井` 建的都是
`AecDbX3dPartEntity`,区别只在 `SetAsWell` 的哪一族重载,**实体自己被写入不同的名字**:
| 命令 | SetAsWell 重载 | 实体名 | 关键 xdata |
| --- | --- | --- | --- |
| PL_JFZJ 方井 | `(ptCen, dL, dW, dL1, dW1, dH, dt, dBomThick, vtOffset2d, true)` | `方台井` | dL/dW/dH/dL1/dW1/dt/dBomt |
| PL_JYZJ 圆井 | `(ptCen, dR, dr, dH, dt, dBomT, vtOffset2d, true)` | `圆台井` | dR/dr/dt/dBomt/dH |
| PL_JFYJ 方圆井 | `(ptCen, dL, dW, dr, dH, dt, dBomT, dXOffset, true)` | `方圆井` | dL/dW/dH/dr/dt/dBomT |
| PL_JYXJ 异形井 | `(pszTop, pszBom, dH, dThick, dBomThick, dElBom, true)` | `异形偏心井` | TopScr/BomScr/dH/dThick/dBomThick |
**工具设计**(对应 `add_aec_well` / `update_aec_well`):
- 建:`host`(池底板 handle)+ `position` + `shape` + 尺寸;内部照命令序列
`SetAsHole(板底标高+半板厚, 1.1~1.2×板厚)` → `SetAsWell(...)` → `KEY_ASSOIC`
→ `LAY_HOLE` → 入库 → 反应器 + 母体 `AppendAssocPart`;
- 改:`update_aec_well` 先按**实体自己的名字**判断是哪种井(`DBL_AEC_X3DPART` 就是这么分派的),
取 `GetOrgPoint(true)` 作井心、`ResetMove()`,再从母体板取板厚/板底标高,
按同名重载重建井体,最后让母体板 `ReCreateDraw3d()`(与命令一致);
- **异形井修改不改截面**:`update_aec_well` 不给 `top_points`/`bottom_points` 时,
直接沿用实体里存的 `TopScr`/`BomScr`;
- 没传的尺寸参数一律沿用实体里已有的值(从 xdata 读),所以 `update` 只传要改的字段即可。
实测(R230 Debug,pcf_1.dwg):四种井各建一个(3A1~3A4,名字分别是 方台井/圆台井/
方圆井/异形偏心井),随后分别改高度、圆井直径、方圆井下口直径、异形井高度——
四个 update 全部成功;方井包围盒 z 从 −3800 变 −4300(高 1500→2000 生效)。
`PL_JJSK 集水坑` 用的是带角度的重载,暂未接。