diff --git a/SourceCode/Code2026/cad_mcp_aec/aec_mcp_entity_tools.cpp b/SourceCode/Code2026/cad_mcp_aec/aec_mcp_entity_tools.cpp index 7038113..d3e6af0 100644 --- a/SourceCode/Code2026/cad_mcp_aec/aec_mcp_entity_tools.cpp +++ b/SourceCode/Code2026/cad_mcp_aec/aec_mcp_entity_tools.cpp @@ -1872,7 +1872,9 @@ namespace vtDir = AcGeVector3d::kZAxis; // 尺寸:没传就沿用实体里已有的(update 场景) - const double dLen = numOr(a, "casing_length", XDataD(pX, _T("dH"), dDepthDefault)); + double dLen = numOr(a, "casing_length", XDataD(pX, _T("dH"), dDepthDefault)); + if (dLen <= 0.0 && !hasKey(a, "casing_length")) + dLen = XDataD(pX, _T("m_dT"), 0.0); // 洞转套管:洞的 m_dT 存的是洞深 const double dT = numOr(a, "casing_wall_thickness", XDataD(pX, _T("dT"), 0.0)); const double dExt1 = numOr(a, "casing_extend1", XDataD(pX, _T("dEx1"), 0.0)); const double dExt2 = numOr(a, "casing_extend2", XDataD(pX, _T("dEx2"), 0.0)); @@ -1902,7 +1904,9 @@ namespace } else { - const double dD = numOr(a, "diameter", XDataD(pX, _T("dD"), 0.0)); + double dD = numOr(a, "diameter", XDataD(pX, _T("dD"), 0.0)); + if (dD <= 0.0 && !hasKey(a, "diameter")) + dD = 2.0 * XDataD(pX, _T("m_dL"), 0.0); // 洞转套管:洞的 m_dL 存的是半径 if (dD <= 0.0) { err = L"圆套管需要 diameter > 0"; @@ -1937,9 +1941,12 @@ public: std::string private_description() const override { - return "在板或墙上开洞(对应菜单命令 平板开洞 PL_CDKD / 墙体开洞 PL_CBKD):给母体的 handle 与洞口参数," - "生成 AecDbX3dPartEntity 并自动与母体做布尔、挂到母体下(LAY_HOLE 图层)。" - "尺寸用图纸单位;depth 缺省取母体厚度(板厚/墙厚)。洞口方向自动取板法向或墙厚方向。返回洞口实体 handle。"; + return "在板或墙上开洞(对应菜单命令 平板开洞 PL_CDKD / 墙体开洞 PL_CBKD / 阵列开洞 PL_ZLKD / 穿管开洞 PL_YXCG)," + "也可以做成套管:给母体的 handle 与洞口参数,生成 AecDbX3dPartEntity 并自动与母体做布尔、挂到母体下" + "(洞=LAY_HOLE / 套管=LAY_CASEPIPE)。尺寸用图纸单位;depth 缺省取母体厚度(板厚/墙厚);" + "洞口方向自动取板法向或墙厚方向。阵列给 rows/columns + spacing_x/spacing_y;" + "穿管开洞给 source=管线 handle(圆管道自动取外径);casing=true 走 SetAsPipe。" + "返回洞口/套管实体 handle,阵列时另给 handles 数组。"; } nlohmann::json private_input_schema() const override @@ -1958,7 +1965,22 @@ public: "nozzle": { "type": "boolean", "description": "是否要管嘴(缺省否)" }, "no": { "type": "string", "description": "洞口编号" }, "for_use":{ "type": "string", "description": "洞口用途" }, - "layer": { "type": "string", "description": "图层,缺省 LAY_HOLE" } + "layer": { "type": "string", "description": "图层,缺省 洞=LAY_HOLE / 套管=LAY_CASEPIPE" }, + "source": { "type": "string", "description": "穿管开洞(PL_YXCG):管线 handle(管道/风管/桥架),洞口中心取管线轴线与母体中面的交点;圆管道自动取外径" }, + "rows": { "type": "integer", "description": "阵列开洞(PL_ZLKD)行数,缺省 1" }, + "columns": { "type": "integer", "description": "阵列开洞列数,缺省 1" }, + "spacing_x": { "type": "number", "description": "阵列列间距(墙=沿墙方向 / 板=X 方向)" }, + "spacing_y": { "type": "number", "description": "阵列行间距(墙=竖向 / 板=Y 方向)" }, + "casing": { "type": "boolean", "description": "true=做成套管(SetAsPipe,只支持 circle/rect);缺省否" }, + "casing_length": { "type": "number", "description": "套管长度(缺省取母体厚度)" }, + "casing_wall_thickness": { "type": "number", "description": "套管壁厚" }, + "casing_extend": { "type": "boolean", "description": "套管两端是否外伸" }, + "casing_extend1": { "type": "number", "description": "外伸长度 1" }, + "casing_extend2": { "type": "number", "description": "外伸长度 2" }, + "material": { "type": "string", "description": "套管材质" }, + "pipe_type": { "type": "string", "description": "套管类型" }, + "ring_od": { "type": "string", "description": "翼环外径" }, + "ring_count": { "type": "integer", "description": "翼环数量" } }, "required": [ "host" ] })"); @@ -1972,7 +1994,10 @@ public: if (!hasKey(args, "host")) return errJson(kErrBadParam, L"缺少 host(母体板的 handle)"); - const std::string sHost = args["host"].get(); + // 局部副本:穿管开洞(source)要往里补缺省直径 + nlohmann::json a(args); + + const std::string sHost = a["host"].get(); AcDbEntity* pEnt = openByHandle(sHost, AcDb::kForWrite); if (pEnt == NULL) return errJson(kErrNotFound, L"按 handle 打不开母体:" + utf8ToWstr(sHost)); @@ -1990,10 +2015,14 @@ public: // 洞口中心:没给就用母体中心(板=板中心,墙=基线中点) AcGePoint3d ptCen(0.0, 0.0, 0.0); - const bool bHasPos = readPoint(args, "position", ptCen); + const bool bHasPos = readPoint(a, "position", ptCen); AcGeVector3d vtDir = AcGeVector3d::kZAxis; // 洞口法向 = 深度方向 - double dDepth = numOr(args, "depth", 0.0); + double dDepth = numOr(a, "depth", 0.0); + WallData wd; + ::memset(&wd, 0, sizeof(WallData)); + if (pWall != NULL) + pWall->GetWallData(wd); if (pSlab != NULL) { @@ -2009,9 +2038,6 @@ public: } else { - WallData wd; - ::memset(&wd, 0, sizeof(WallData)); - pWall->GetWallData(wd); if (dDepth <= 0.0) dDepth = wd.dThick; if (dDepth <= 0.0) @@ -2027,7 +2053,7 @@ public: } // 法向 = 墙厚方向;给了 direction 就用给的 AcGePoint3d ptGiven; - if (readPoint(args, "direction", ptGiven)) + if (readPoint(a, "direction", ptGiven)) vtDir = ptGiven.asVector(); else if (!WallNormalAt(pWall, ptCen, vtDir)) vtDir = AcGeVector3d::kZAxis; @@ -2038,66 +2064,156 @@ public: vtUnit.normalize(); ptCen += vtUnit * 0.5 * dDepth; - // 套管:给了 casing / casing_length / casing_wall_thickness 就走 SetAsPipe 那条 - const bool bCasing = hasKey(args, "casing") - ? (intOr(args, "casing", 0) != 0) - : (hasKey(args, "casing_length") || hasKey(args, "casing_wall_thickness")); - - AecDbX3dPartEntity* pPart = new AecDbX3dPartEntity(); - std::wstring err; - const bool bApplied = bCasing - ? ApplyCasing(pPart, ptCen, vtDir, dDepth, args, true, err) - : ApplyHole(pPart, pEnt, ptCen, dDepth, vtDir, args, true, err); - if (!bApplied) + // 穿管开洞(PL_YXCG):source 给管线 handle,洞口中心取"管线轴线与母体中面"的交点, + // 直径缺省取管道外径(PIPE_OD 已是图纸单位)。 + // shortcut: 这里只对圆管道自动取外径,风管/桥架请自己给 diameter 或 width+height。 + std::string sSrc; + double dSrcDia = 0.0; + if (hasKey(a, "source")) { - delete pPart; - pEnt->close(); - return errJson(kErrBadParam, err); + const std::string sIn = a["source"].get(); + AcDbEntity* pSrc = openByHandle(sIn, AcDb::kForRead); + AcDbCurve* pCur = (pSrc != NULL) ? AcDbCurve::cast(pSrc) : NULL; + if (pCur == NULL) + { + if (pSrc != NULL) pSrc->close(); + if (pSlab != NULL) pSlab->close(); else pWall->close(); + return errJson(kErrWrongType, L"source 必须是曲线类管线(管道/风管/桥架),handle=" + utf8ToWstr(sIn)); + } + + AcGePoint3d ptS(0.0, 0.0, 0.0), ptE(0.0, 0.0, 0.0); + pCur->getStartPoint(ptS); + pCur->getEndPoint(ptE); + + AecDbEwPipe* pPipe = AecDbEwPipe::cast(pSrc); + if (pPipe != NULL) + { + const AecDbObjXDataMap* pXPipe = pPipe->GetSpecialtyData(AcDb::kForRead); + if (pXPipe != NULL) + { + double dOd = 0.0, dDn = 0.0; + pXPipe->GetAt(PIPE_OD, dOd); + pXPipe->GetAt(PIPE_DN, dDn); + dSrcDia = (dOd > 0.0) ? dOd : dDn; // 没写外径就用公称直径 + } + } + + // 轴线与"过 ptCen、法向 vtUnit"的平面求交 + const AcGeVector3d vtAxis = ptE - ptS; + const double dDen = vtAxis.dotProduct(vtUnit); + if (fabs(dDen) > 1e-9) + ptCen = ptS + vtAxis * ((ptCen - ptS).dotProduct(vtUnit) / dDen); + + sSrc = sIn; + pSrc->close(); + + if (dSrcDia > 0.0 && !hasKey(a, "diameter") && !hasKey(a, "width")) + a["diameter"] = dSrcDia; } - // 母体关联 + 中心/法向:update 与"洞↔套管互转"都要用 - pPart->GetSpecialtyData()->SetAt(KEY_ASSOIC, pEnt->objectId()); - pPart->GetSpecialtyData()->SetAt(kHoleCenKey, ptCen); - pPart->GetSpecialtyData()->SetAt(kHoleDirKey, vtDir); + // 套管:给了 casing / casing_length / casing_wall_thickness 就走 SetAsPipe 那条 + const bool bCasing = hasKey(a, "casing") + ? (intOr(a, "casing", 0) != 0) + : (hasKey(a, "casing_length") || hasKey(a, "casing_wall_thickness")); - // 图层:缺省 LAY_HOLE,与命令一致 - if (hasKey(args, "layer")) + std::wstring err; + std::string sFail; + // 单个洞/套管:阵列时同一套参数只换中心 + auto makeOne = [&](const AcGePoint3d& pt) -> std::string { - const std::wstring sLay = wstrOr(args, "layer", L""); - if (!sLay.empty()) + AecDbX3dPartEntity* pPart = new AecDbX3dPartEntity(); + const bool bApplied = bCasing + ? ApplyCasing(pPart, pt, vtDir, dDepth, a, true, err) + : ApplyHole(pPart, pEnt, pt, dDepth, vtDir, a, true, err); + if (!bApplied) { - AcDbObjectId idLay = layerIdByName(sLay); - if (!idLay.isNull()) pPart->setLayer(idLay); + delete pPart; + return std::string(); + } + + // 母体关联 + 中心/法向:update 与"洞↔套管互转"都要用 + pPart->GetSpecialtyData()->SetAt(KEY_ASSOIC, pEnt->objectId()); + pPart->GetSpecialtyData()->SetAt(kHoleCenKey, pt); + pPart->GetSpecialtyData()->SetAt(kHoleDirKey, vtDir); + + // 图层:缺省 洞=LAY_HOLE / 套管=LAY_CASEPIPE,与命令一致 + std::wstring sLay; + if (hasKey(a, "layer")) + sLay = wstrOr(a, "layer", L""); + if (sLay.empty()) + sLay = bCasing ? L"LAY_CASEPIPE" : L"LAY_HOLE"; + AcDbObjectId idLay = KTSetting::InitLayer(sLay.c_str()); // 图层不存在就建,与命令一致 + if (!idLay.isNull()) + pPart->setLayer(idLay); + + AcDbObjectId idHole; + Acad::ErrorStatus es = addToSpace(pPart, &idHole); + if (es != Acad::eOk) + { + delete pPart; + sFail = "加入模型空间失败,err=" + std::to_string((int)es); + return std::string(); + } + + // 与母体建立关联:持久反应器 + 母体的关联件表(绘制时母体据此做布尔) + pPart->addPersistentReactor(pEnt->objectId()); + if (pSlab != NULL) + pSlab->AppendAssocPart(idHole); + else + pWall->AppendAssocPart(idHole); + pPart->close(); + return handleOfId(idHole); + }; + + // 阵列开洞(PL_ZLKD):rows/columns + spacing_x(墙=沿墙、板=X)/ spacing_y(墙=竖向、板=Y) + int nRows = intOr(a, "rows", 1); + int nCols = intOr(a, "columns", 1); + if (nRows < 1) nRows = 1; + if (nCols < 1) nCols = 1; + const double dSpX = numOr(a, "spacing_x", 0.0); + const double dSpY = numOr(a, "spacing_y", 0.0); + + AcGeVector3d vtColDir = AcGeVector3d::kXAxis; + AcGeVector3d vtRowDir = AcGeVector3d::kYAxis; + if (pWall != NULL) + { + // 墙:列沿墙方向(法向绕 Z 转 -90°),行沿 +Z + if (WallNormalAt(pWall, ptCen, vtColDir)) + vtColDir.rotateBy(-PI / 2.0, AcGeVector3d::kZAxis); + else + vtColDir = AcGeVector3d::kXAxis; + vtRowDir = AcGeVector3d::kZAxis; + } + + nlohmann::json arHandles = nlohmann::json::array(); + for (int i = 0; i < nRows; ++i) + { + for (int j = 0; j < nCols; ++j) + { + const AcGePoint3d pt = ptCen + vtColDir * (j * dSpX) + vtRowDir * (i * dSpY); + const std::string sH = makeOne(pt); + if (sH.empty()) + { + if (pSlab != NULL) pSlab->close(); else pWall->close(); + return errJson(kErrBadParam, !err.empty() ? err : utf8ToWstr(sFail)); + } + arHandles.push_back(sH); } } - else - { - AcDbObjectId idLay = layerIdByName(L"LAY_HOLE"); - if (!idLay.isNull()) pPart->setLayer(idLay); - } - AcDbObjectId idHole; - Acad::ErrorStatus es = addToSpace(pPart, &idHole); - if (es != Acad::eOk) - { - delete pPart; - pEnt->close(); - return errJson(kErrInternal, std::wstring(L"加入模型空间失败,err=") + std::to_wstring((int)es)); - } - - // 与母体建立关联:持久反应器 + 母体的关联件表(绘制时母体据此做布尔) - pPart->addPersistentReactor(pEnt->objectId()); - if (AecDbXSlab* pS = AecDbXSlab::cast(pEnt)) - pS->AppendAssocPart(idHole); - else if (AecDbXWall* pW = AecDbXWall::cast(pEnt)) - pW->AppendAssocPart(idHole); - pPart->close(); - pEnt->close(); + if (pSlab != NULL) pSlab->close(); else pWall->close(); nlohmann::json body; - body["type"] = "opening"; - body["handle"] = handleOfId(idHole); + body["type"] = bCasing ? "casing" : "opening"; body["host"] = sHost; + body["handle"] = arHandles[0]; + body["count"] = (int)arHandles.size(); + body["handles"] = arHandles; + if (!sSrc.empty()) + { + body["source"] = sSrc; + if (dSrcDia > 0.0) body["source_diameter"] = dSrcDia; + } return okJson(body); } }; @@ -2212,7 +2328,7 @@ public: // 洞 / 套管 切换后图层要跟着换(命令里就是 LAY_HOLE / LAY_CASEPIPE) if (!hasKey(args, "layer")) { - AcDbObjectId idLay = layerIdByName(bCasing ? L"LAY_CASEPIPE" : L"LAY_HOLE"); + AcDbObjectId idLay = KTSetting::InitLayer(bCasing ? L"LAY_CASEPIPE" : L"LAY_HOLE"); if (!idLay.isNull()) pPart->setLayer(idLay); } diff --git a/SourceCode/Code2026/cad_mcp_aec/mcp_config.json b/SourceCode/Code2026/cad_mcp_aec/mcp_config.json index da78eea..1d6e18b 100644 --- a/SourceCode/Code2026/cad_mcp_aec/mcp_config.json +++ b/SourceCode/Code2026/cad_mcp_aec/mcp_config.json @@ -2069,7 +2069,7 @@ }, { "name": "add_aec_opening", - "description": "在板或墙上开洞(PL_CDKD 平板开洞 / PL_CBKD 墙体开洞),也可以做成套管:给母体(板或墙)handle 与洞口参数,生成 AecDbX3dPartEntity 并自动与母体布尔、挂到母体下(洞=LAY_HOLE / 套管=LAY_CASEPIPE)。casing=true 时走 SetAsPipe(只支持 circle/rect)+ 套管长/壁厚/外伸/材质/翼环。尺寸用图纸单位;depth 缺省取母体厚度;方向自动取板法向或墙厚方向。", + "description": "在板或墙上开洞(PL_CDKD 平板 / PL_CBKD 墙体 / PL_ZLKD 阵列 / PL_YXCG 穿管),也可以做成套管:给母体(板或墙)handle 与洞口参数,生成 AecDbX3dPartEntity 并自动与母体布尔、挂到母体下(洞=LAY_HOLE / 套管=LAY_CASEPIPE)。尺寸用图纸单位;depth 缺省取母体厚度;方向自动取板法向或墙厚方向。阵列给 rows/columns + spacing_x/spacing_y;穿管开洞给 source=管线 handle(圆管道自动取外径);casing=true 走 SetAsPipe。返回 handle,阵列时另给 handles 数组。", "inputSchema": { "type": "object", "properties": { @@ -2181,6 +2181,26 @@ "ring_count": { "type": "integer", "description": "翼环数量" + }, + "source": { + "type": "string", + "description": "穿管开洞(PL_YXCG):管线 handle(管道/风管/桥架),洞口中心取管线轴线与母体中面的交点;圆管道自动取外径" + }, + "rows": { + "type": "integer", + "description": "阵列开洞(PL_ZLKD)行数,缺省 1" + }, + "columns": { + "type": "integer", + "description": "阵列开洞列数,缺省 1" + }, + "spacing_x": { + "type": "number", + "description": "阵列列间距(墙=沿墙方向 / 板=X 方向)" + }, + "spacing_y": { + "type": "number", + "description": "阵列行间距(墙=竖向 / 板=Y 方向)" } }, "required": [ diff --git a/cad-mcp-aec.md b/cad-mcp-aec.md index 35c9d08..609249a 100644 --- a/cad-mcp-aec.md +++ b/cad-mcp-aec.md @@ -274,7 +274,7 @@ MCP 工具是通过 `PostMessage` 在主线程的消息里跑的,**不在命 | 管件 `AecDbEwFitting` | `PL_DJWT` 等 | 创建要填一整套专业数据:`KEY_RUNTIME`(弯头/三通/大小头…)、`KEY_MID`/`KEY_MAJBR`(位置/朝向)、`PIPE_DN`/`PIPE_OD`/`PIPE_THICK`/`PIPE_SYS`/`PIPE_MATERIAL`/`PIPE_CONNECT`,其中接口尺寸来自 `TDbPipeSupport::QueryInfFDFL`(**查库**)。参照 `PipelineCmd/AecPipeLine.cpp:812` `AddReducer` | 未做(要先把"最小可用专业数据集"试出来) | | 设备 `AecDbEwEquipment` | `PL_TJSB`/设备插入系 | 不是画出来的:`ReadFromFile(pszEquFile)`(`.equ` / `.r2p` 两种)→ `SetInsert(pt, dir)`。设备库不是散文件,存在 `sys\Aec3DMep.db`(1 GB SQLite),要按编号取 blob 再落成实体 | 未做(需要先确认"按编号取设备"的入口) | | 参数化设备 `AecDbXEquipment` | 水池/泵房系 | `new AecDbXEquipment(dbType)` + `SetSrcString(json)` + `SetPosAndDir(pt,dir)` + `SetElev(z)`,定义走 JSON(`Pool3dCmd/ParamEquJson.cpp:291`) | 未做(要先定 JSON 的最小字段) | -| 开洞(墙/板) | `PL_CBKD`/`PL_CDKD`/`PL_YXKD`/`PL_ZLKD`/`PL_YXCG` | 洞不是普通实体:命令建的是 `AecDbX3dPartEntity` + `AcDbX3dSolid`,再对**母体**做布尔(和"墙体倒角/倒圆"同一族)。工具要能指定母体 handle + 洞口轮廓/尺寸 | 未做(需要母体+布尔时序,风险最高) | +| 开洞(墙/板) | `PL_CBKD`/`PL_CDKD`/`PL_YXKD`/`PL_ZLKD`/`PL_YXCG` | 洞不是普通实体:命令建的是 `AecDbX3dPartEntity` + `AcDbX3dSolid`,再对**母体**做布尔(和"墙体倒角/倒圆"同一族)。工具要能指定母体 handle + 洞口轮廓/尺寸 | ✅ 已做(`add/update_aec_opening`,含阵列与穿管,见 §8.5/§8.6) | | 集水井/方圆井 | `PL_JFZJ`/`PL_JYZJ`/`PL_JFYJ`/`PL_JYXJ`/`PL_JJSK` | 同上,也是 `AecDbX3dPartEntity` 组合体;井的尺寸来自对话框 | 未做 | |HA_TJ3T|添加三通|AecDbEwFitting|add_aec_fitting|update_aec_fitting| |HA_TJ4T|添加四通|AecDbEwFitting|add_aec_fitting|update_aec_fitting| @@ -319,8 +319,8 @@ MCP 工具是通过 `PostMessage` 在主线程的消息里跑的,**不在命 |PL_CDKD|平板开洞|AecDbX3dPartEntity|add_aec_opening|update_aec_opening| |PL_CBKD|墙体开洞|AecDbX3dPartEntity|add_aec_opening|update_aec_opening| |PL_YXKD|异形开洞|AecDbX3dPartEntity|add_aec_opening|update_aec_opening| -|PL_ZLKD|阵列开洞|AecDbX3dPartEntity|(未实现:一次开一排/矩阵洞)|| -|PL_YXCG|穿管开洞|AecDbX3dPartEntity|(未实现:要引用管道位置并带套管)|| +|PL_ZLKD|阵列开洞|AecDbX3dPartEntity|✅ `add_aec_opening`(rows/columns + spacing_x/spacing_y)| +|PL_YXCG|穿管开洞|AecDbX3dPartEntity|✅ `add_aec_opening`(source=管线 handle)| > 开洞(上表 PL_CDKD / PL_CBKD):洞不是普通实体,是 `AecDbX3dPartEntity` + 对母体做布尔, > 工具收 `host`(板的 handle)+ 洞口参数,内部照 `PL_CDKDCmdFnc` > (Pool3dCmd/pool3dcmdCmd.cpp:14763)的序列:`SetAsHole(中心,尺寸,板厚,法向)` @@ -395,8 +395,8 @@ MCP 工具是通过 `PostMessage` 在主线程的消息里跑的,**不在命 | `PL_YXKD` 异形开洞 | 板/墙 + 任意闭合轮廓 | ✅ 同上 | `shape=polygon` + `points`(可选 `bulges`) | | 洞口改属性 | 改尺寸/位置/编号/用途/管嘴 | ✅ `update_aec_opening` | 参数集照 `DBL_AEC_X3DPART` 里"开洞"分支 | | 洞口 ↔ 套管 | 把洞做成套管、或改回洞口 | ✅ `add_aec_opening(casing=true)` / `update_aec_opening(casing=)` | `SetAsPipe` + `LAY_CASEPIPE`,详见 §8.5 | -| `PL_ZLKD` 阵列开洞 | 一次开一排/矩阵洞 | ❌ 未做 | 要定工具形态(给角点+行列数,还是方向+数量) | -| `PL_YXCG` 穿管开洞 | 按管道位置 + 套管开洞 | ❌ 未做 | 要引用管道实体(handle)取位置/方向/口径,本质是"套管 + 位置来自管道" | +| `PL_ZLKD` 阵列开洞 | 一次开一排/矩阵洞 | ✅ `add_aec_opening(rows, columns, spacing_x, spacing_y)` | 形态定为"首个洞中心 + 行列数 + 间距",见 §8.6 | +| `PL_YXCG` 穿管开洞 | 按管道位置 + 套管开洞 | ✅ `add_aec_opening(source=管线 handle)` | 位置=管线轴线与母体中面交点,圆管道自动取外径,见 §8.6 | 结论:**洞本身(板/墙、圆/矩形/异形、增与改)已经齐了**;剩下的是"套管"这一类 (洞口与套管的差别在 `SetAsPipe` 而不是 `SetAsHole`),以及阵列、穿管两种自动布置。 @@ -442,3 +442,36 @@ xdata 键:`dL/dW/dH/dSlabThick/dBomThick/Ang`(注意这里的 `dBomThick` - 墙上矩形套管 800x600/长400 → 3A3,包围盒 x 7700~8100(墙厚 200)、z 1200~1800; - 3A1 `casing=false` → 名字变 `开洞`、位置仍 (2000,2000,150);再 `casing=true`(长 800、壁厚 25) → 名字回 `套管`、包围盒 z 变 -250~550 —— **洞↔套管互转正常**。 + +### 8.6 阵列开洞与穿管开洞 + +两种都做进 `add_aec_opening`,不新增工具(同族实体一个工具 + 参数选型)。 + +**阵列(`PL_ZLKD`)**:`rows` / `columns` + `spacing_x` / `spacing_y`,`position` 是**第一个洞**的中心。 + +| 母体 | 列方向(spacing_x) | 行方向(spacing_y) | +| --- | --- | --- | +| 墙 | 沿墙方向(墙法向绕 Z 转 −90°) | +Z 竖向 | +| 板 | X | Y | + +命令里的 `m_dX`(沿墙)/ `m_dY`(竖向)就是这个意思,只是它用"参考点 + 距离"定位第一个洞, +工具里换成直接给 `position`,等价且更好用。返回里 `handles` 是全部洞的 handle(`handle` = 第一个)。 + +**穿管(`PL_YXCG`)**:`source` 给管线 handle(管道 / 风管 / 桥架), +位置取**管线轴线与母体中面的交点**(命令用布尔求交再取两点中点,结果等价), +圆管道自动用 `PIPE_OD`(没写外径就用 `PIPE_DN`)当 `diameter`; +显式给了 `diameter`/`width` 就以给的为准。想带套管就再给 `casing=true`。 + +实测(R230 Debug,pcf_1.dwg): +- 墙 12000×3000、洞 D300,`rows=3 columns=4 spacing_x=2500 spacing_y=900` → 12 个洞, + 中心 (2000/4500/7000/9500, 100(墙厚中点), 1200/2100/3000),图层 `HOLE`; +- 矩形阵列 2×3(600×400,3000/1000 间距)→ 6 个,中心同样按间距递增; +- 竖管 D150 穿板(板 −1000~−700,管 z −2500~2500)→ 套管中心 (6000,10000,**−850**)、 + `source_diameter` 0.15、图层 `CasePipe`; +- 横管 D250 穿墙(墙 y=20000 厚 200)→ 洞中心 (4000,**20100**,1000)、图层 `HOLE`; + 再 `casing=true` 变套管(图层 `CasePipe`、名字`套管`),`casing=false` 又变回洞 —— 位置全程不动。 +- 阵列里任意一个洞也能单独 `update_aec_opening(casing=true)` 转成套管。 + +**注意**:`SetAsHole` 建出来的洞,`geomExtents` 在 MCP 侧查出来是空的(±1e20), +因为洞的几何要等母体重绘时才生成;`SetAsPipe`(套管)是当场建 solid,包围盒立刻有效。 +**不是 bug**,别拿包围盒判断洞建没建成,看 `position` / 图层 / 母体的关联件。