源工程在 d:\new-start\CadProject\src\cad_mcp_frame(vcpkg 独立工程), 本次按 code2026 的 preset/CMake 体系移植到 SourceCode/Code2026/cad_mcp_frame。 移植改动: - 源码 + .def + .rc + res/ + cad-mcp-frame.json 拷入 cad_mcp_frame/; 插件接口头 mcp_plugin_api.h 放到 cad_mcp_frame/inc/ - cadsdk.h -> KTCad.h(两者除尾部 4 个 include 与 using namespace MemOper 外完全一致) - nlohmann/json 单头放 SourceCode/dep_inc/nlohmann/json.hpp, ghc::filesystem 单头放 SourceCode/dep_inc/ghc/filesystem.hpp; target_link_objectarx 已把 DEP_INC_ROOT 加进 include 路径,故无需额外配置 - 新增 cad_mcp_frame/cmakelists.txt:按 PipeHangerCmd 的写法 (add_def_file_name / target_set_name_and_suffix .arx / target_link_objectarx / target_include_directories inc / set_debug_post_build) - 补 SUB_ARX 宏:原工程由 CadProject 的 cmake 注入,code2026 只注入 ARX; 在模块自己的 CMake 里补,不动共享 functions.cmake(中望给 0) - 顶层挂载 add_custom_module_2(cad_mcp_frame CadMcpFrame "SH/Other"), 并加条件:nlohmann/json 与 ghc::filesystem 都需要 C++11+, 而 R180/R190 是 C++98,故只在 (IS_ZWCAD OR CAD_SDK_VERSION >= 20) 时编译 - 中望适配两处:_zrx.def 要导出 zcrxEntryPoint/zcrxGetApiVersion; 代码里显式声明的 acrxGetApiVersion() 不会被 SDK 宏改名, 改为 #ifdef ZWCAD 取 zcrxGetApiVersion() 验证: - R230 Debug 编译通过,cad_mcp_frame.arx 818 KB,自动部署到 c:\ShangHuaSoft\Envi3D-2026-M\R230\ - Z2026 Debug 编译通过,cad_mcp_frame.zrx 818 KB,自动部署到 ...\Z2026\ - R190/R180 按条件跳过(C++98 无法编译 nlohmann/json) - 所有 .cpp/.h 均为 UTF-8 with BOM;cmakelists.txt 保持 ASCII 无 BOM 未做:没有在 CAD 里加载实测;配置文件仍是 cad-mcp-frame.json, 而代码里找的是 mcp_config.json,加载前需要统一(详见 cad_mcp_frame-review.md); 插件工程 cad_mcp_plugins 未移植(18 个工具里 16 个依赖它)。
333 lines
13 KiB
JSON
333 lines
13 KiB
JSON
{
|
|
"version": "1.0.0",
|
|
"global_settings": {
|
|
"plugin_directory": ".",
|
|
"lisp_directory": ".",
|
|
"hot_reload": true
|
|
},
|
|
"tools": [
|
|
{
|
|
"name": "zoom_window_normalized",
|
|
"description": "归一化框选放大工具。当你发现当前截图中某些目标太小、细节模糊时,估算该目标在画面中的归一化坐标,调用此工具将该区域全屏放大以看清细节。",
|
|
"inputSchema": {
|
|
"type": "object",
|
|
"properties": {
|
|
"x1": { "type": "number", "description": "左上角 X 坐标,取值 0.0 到 1.0" },
|
|
"y1": { "type": "number", "description": "左上角 Y 坐标,取值 0.0 到 1.0" },
|
|
"x2": { "type": "number", "description": "右下角 X 坐标,取值 0.0 到 1.0" },
|
|
"y2": { "type": "number", "description": "右下角 Y 坐标,取值 0.0 到 1.0" }
|
|
},
|
|
"required": [ "x1", "y1", "x2", "y2" ]
|
|
},
|
|
"backend": {
|
|
"type": "lisp_inline",
|
|
"script_template": "(progn (setq vc (getvar \"VIEWCTR\") vs (getvar \"VIEWSIZE\") ss (getvar \"SCREENSIZE\") w (* vs (/ (car ss) (cadr ss))) x_tl (- (car vc) (/ w 2.0)) y_tl (+ (cadr vc) (/ vs 2.0)) pt1 (list (+ x_tl (* {x1} w)) (- y_tl (* {y1} vs))) pt2 (list (+ x_tl (* {x2} w)) (- y_tl (* {y2} vs)))) (command \"_.ZOOM\" \"_W\" \"_non\" pt1 \"_non\" pt2))"
|
|
}
|
|
},
|
|
{
|
|
"name": "zoom_extents",
|
|
"description": "全局缩放。将CAD视口重置为显示所有图元。当你迷失方向、放大过度或者需要寻找新目标时使用。",
|
|
"inputSchema": {
|
|
"type": "object",
|
|
"properties": {}
|
|
},
|
|
"backend": {
|
|
"type": "lisp_inline",
|
|
"script_template": "(command \"_.ZOOM\" \"_E\")"
|
|
}
|
|
},
|
|
{
|
|
"name": "get_viewport_screenshot",
|
|
"description": "获取 AutoCAD 当前工作视口的实时截图。当需要检查图纸细节、判断是否需要缩放,或需要通过视觉确认图元位置时调用。",
|
|
"inputSchema": {
|
|
"type": "object",
|
|
"properties": {},
|
|
"required": []
|
|
},
|
|
"backend": {
|
|
"type": "c++_dll",
|
|
"dll_name": "cad_mcp_plugins.dll",
|
|
"factory_function": "CreateViewportScreenshotTool"
|
|
}
|
|
},
|
|
{
|
|
"name": "get_drawing_info",
|
|
"description": "获取当前图纸的元数据:文件名、单位、布局数量、各空间实体总数。审查流程的第一步。",
|
|
"inputSchema": {
|
|
"type": "object",
|
|
"properties": {}
|
|
},
|
|
"backend": {
|
|
"type": "c++_dll",
|
|
"dll_name": "cad_mcp_plugins.dll",
|
|
"factory_function": "CreateGetDrawingInfoTool"
|
|
}
|
|
},
|
|
{
|
|
"name": "get_layers",
|
|
"description": "获取图层清单:开关、冻结、锁定、颜色、线型,可选统计每图层实体数(用于查找空图层/规范检查)。",
|
|
"inputSchema": {
|
|
"type": "object",
|
|
"properties": {
|
|
"name_filter": { "type": "string", "description": "图层名通配符,如 \"WALL*\",省略则全部" },
|
|
"include_empty": { "type": "boolean", "description": "统计实体数时是否包含空图层,默认 false" },
|
|
"count_entities": { "type": "boolean", "description": "是否统计每图层实体数,默认 false" }
|
|
}
|
|
},
|
|
"backend": {
|
|
"type": "c++_dll",
|
|
"dll_name": "cad_mcp_plugins.dll",
|
|
"factory_function": "CreateGetLayersTool"
|
|
}
|
|
},
|
|
{
|
|
"name": "get_layouts",
|
|
"description": "获取布局清单:模型空间与各图纸空间布局、实体数、布局内视口。",
|
|
"inputSchema": {
|
|
"type": "object",
|
|
"properties": {}
|
|
},
|
|
"backend": {
|
|
"type": "c++_dll",
|
|
"dll_name": "cad_mcp_plugins.dll",
|
|
"factory_function": "CreateGetLayoutsTool"
|
|
}
|
|
},
|
|
{
|
|
"name": "query_entities",
|
|
"description": "按图层/类型/范围查询图元摘要,分页返回(total/returned/offset/items)。实体 ID 为 handle。",
|
|
"inputSchema": {
|
|
"type": "object",
|
|
"properties": {
|
|
"space": { "type": "string", "description": "\"Model\" 或布局名,默认 Model" },
|
|
"layer_filter": { "type": "string", "description": "图层通配符" },
|
|
"type_filter": { "type": "array", "items": { "type": "string" }, "description": "类型白名单,如 [\"LINE\",\"LWPOLYLINE\"]" },
|
|
"window": {
|
|
"type": "object",
|
|
"properties": {
|
|
"min_x": { "type": "number" }, "min_y": { "type": "number" },
|
|
"max_x": { "type": "number" }, "max_y": { "type": "number" }
|
|
}
|
|
},
|
|
"limit": { "type": "integer", "description": "单次最大返回,默认 200,上限 1000" },
|
|
"offset": { "type": "integer", "description": "分页偏移,默认 0" }
|
|
}
|
|
},
|
|
"backend": {
|
|
"type": "c++_dll",
|
|
"dll_name": "cad_mcp_plugins.dll",
|
|
"factory_function": "CreateQueryEntitiesTool"
|
|
}
|
|
},
|
|
{
|
|
"name": "get_text_content",
|
|
"description": "提取 TEXT/MTEXT/ATTRIB 文字:内容、位置、字高、旋转、图层、包围盒。用于查错字、空文字、重叠、字高异常。",
|
|
"inputSchema": {
|
|
"type": "object",
|
|
"properties": {
|
|
"space": { "type": "string" },
|
|
"layer_filter": { "type": "string" },
|
|
"content_filter": { "type": "string", "description": "内容子串过滤(可选)" },
|
|
"window": { "type": "object", "properties": { "min_x": { "type": "number" }, "min_y": { "type": "number" }, "max_x": { "type": "number" }, "max_y": { "type": "number" } } },
|
|
"limit": { "type": "integer" },
|
|
"offset": { "type": "integer" }
|
|
}
|
|
},
|
|
"backend": {
|
|
"type": "c++_dll",
|
|
"dll_name": "cad_mcp_plugins.dll",
|
|
"factory_function": "CreateGetTextContentTool"
|
|
}
|
|
},
|
|
{
|
|
"name": "get_dimensions",
|
|
"description": "提取标注:类型、测量值、文本覆盖、标注样式、图层。用于查漏标/标注异常。",
|
|
"inputSchema": {
|
|
"type": "object",
|
|
"properties": {
|
|
"space": { "type": "string" },
|
|
"layer_filter": { "type": "string" },
|
|
"window": { "type": "object", "properties": { "min_x": { "type": "number" }, "min_y": { "type": "number" }, "max_x": { "type": "number" }, "max_y": { "type": "number" } } },
|
|
"limit": { "type": "integer" },
|
|
"offset": { "type": "integer" }
|
|
}
|
|
},
|
|
"backend": {
|
|
"type": "c++_dll",
|
|
"dll_name": "cad_mcp_plugins.dll",
|
|
"factory_function": "CreateGetDimensionsTool"
|
|
}
|
|
},
|
|
{
|
|
"name": "get_block_references",
|
|
"description": "提取块参照:块名、插入点、旋转、缩放、图层及全部属性(tag/value)。用于查属性缺失/不符。",
|
|
"inputSchema": {
|
|
"type": "object",
|
|
"properties": {
|
|
"space": { "type": "string" },
|
|
"layer_filter": { "type": "string" },
|
|
"block_name_filter": { "type": "string", "description": "块名通配符" },
|
|
"window": { "type": "object", "properties": { "min_x": { "type": "number" }, "min_y": { "type": "number" }, "max_x": { "type": "number" }, "max_y": { "type": "number" } } },
|
|
"limit": { "type": "integer" },
|
|
"offset": { "type": "integer" }
|
|
}
|
|
},
|
|
"backend": {
|
|
"type": "c++_dll",
|
|
"dll_name": "cad_mcp_plugins.dll",
|
|
"factory_function": "CreateGetBlockReferencesTool"
|
|
}
|
|
},
|
|
{
|
|
"name": "get_polylines_info",
|
|
"description": "提取多段线信息:闭合性、面积、长度、顶点数、包围盒。用于查未闭合轮廓。",
|
|
"inputSchema": {
|
|
"type": "object",
|
|
"properties": {
|
|
"space": { "type": "string" },
|
|
"layer_filter": { "type": "string" },
|
|
"window": { "type": "object", "properties": { "min_x": { "type": "number" }, "min_y": { "type": "number" }, "max_x": { "type": "number" }, "max_y": { "type": "number" } } },
|
|
"limit": { "type": "integer" },
|
|
"offset": { "type": "integer" }
|
|
}
|
|
},
|
|
"backend": {
|
|
"type": "c++_dll",
|
|
"dll_name": "cad_mcp_plugins.dll",
|
|
"factory_function": "CreateGetPolylinesInfoTool"
|
|
}
|
|
},
|
|
{
|
|
"name": "get_entity_detail",
|
|
"description": "按 handle 获取单个实体的完整属性。用于对某疑点下钻查看。",
|
|
"inputSchema": {
|
|
"type": "object",
|
|
"properties": {
|
|
"handle": { "type": "string", "description": "实体句柄" }
|
|
},
|
|
"required": [ "handle" ]
|
|
},
|
|
"backend": {
|
|
"type": "c++_dll",
|
|
"dll_name": "cad_mcp_plugins.dll",
|
|
"factory_function": "CreateGetEntityDetailTool"
|
|
}
|
|
},
|
|
{
|
|
"name": "detect_drawing_frames",
|
|
"description": "识别图纸中的图框(块参照/闭合矩形多段线/直线组三种形态),推算图幅(A0-A4及加长)与方向,按位置排序。用于按图框逐张审查或分图。",
|
|
"inputSchema": {
|
|
"type": "object",
|
|
"properties": {
|
|
"space": { "type": "string" },
|
|
"layer_filter": { "type": "string", "description": "限定图框所在图层通配符" },
|
|
"block_name_filter": { "type": "string", "description": "图框块名通配符;指定后仅按块名匹配,信任该块" },
|
|
"detect_line_loops": { "type": "boolean", "description": "是否识别四条直线围成的图框,默认 false" },
|
|
"min_side": { "type": "number", "description": "最小短边过滤(图纸单位)" },
|
|
"ratio_tol": { "type": "number", "description": "长宽比容差,默认 0.06" },
|
|
"axis_tol": { "type": "number", "description": "轴对齐判定容差,默认 1.0" },
|
|
"min_confidence": { "type": "number", "description": "最低置信度过滤 0~1,默认 0" },
|
|
"window": { "type": "object", "properties": { "min_x": { "type": "number" }, "min_y": { "type": "number" }, "max_x": { "type": "number" }, "max_y": { "type": "number" } } }
|
|
}
|
|
},
|
|
"backend": {
|
|
"type": "c++_dll",
|
|
"dll_name": "cad_mcp_plugins.dll",
|
|
"factory_function": "CreateDetectDrawingFramesTool"
|
|
}
|
|
},
|
|
{
|
|
"name": "find_duplicate_entities",
|
|
"description": "查找几何重复/重叠实体,按几何签名分桶,返回重复组(handles)。",
|
|
"inputSchema": {
|
|
"type": "object",
|
|
"properties": {
|
|
"space": { "type": "string" },
|
|
"layer_filter": { "type": "string" },
|
|
"type_filter": { "type": "array", "items": { "type": "string" } },
|
|
"tolerance": { "type": "number", "description": "几何容差,默认 0.001" },
|
|
"limit": { "type": "integer", "description": "最大重复组数,默认 200" }
|
|
}
|
|
},
|
|
"backend": {
|
|
"type": "c++_dll",
|
|
"dll_name": "cad_mcp_plugins.dll",
|
|
"factory_function": "CreateFindDuplicateEntitiesTool"
|
|
}
|
|
},
|
|
{
|
|
"name": "find_zero_length",
|
|
"description": "查找零长度/退化实体(长度小于容差的 LINE/ARC/LWPOLYLINE)。",
|
|
"inputSchema": {
|
|
"type": "object",
|
|
"properties": {
|
|
"space": { "type": "string" },
|
|
"layer_filter": { "type": "string" },
|
|
"tolerance": { "type": "number", "description": "长度容差,默认 0.001" },
|
|
"limit": { "type": "integer" },
|
|
"offset": { "type": "integer" }
|
|
}
|
|
},
|
|
"backend": {
|
|
"type": "c++_dll",
|
|
"dll_name": "cad_mcp_plugins.dll",
|
|
"factory_function": "CreateFindZeroLengthTool"
|
|
}
|
|
},
|
|
{
|
|
"name": "zoom_to_entity",
|
|
"description": "缩放到指定 handle(或 handle 列表)实体的范围,四周留 5% 边距。配合截图确认。",
|
|
"inputSchema": {
|
|
"type": "object",
|
|
"properties": {
|
|
"handle": { "type": "string" },
|
|
"handles": { "type": "array", "items": { "type": "string" } }
|
|
}
|
|
},
|
|
"backend": {
|
|
"type": "c++_dll",
|
|
"dll_name": "cad_mcp_plugins.dll",
|
|
"factory_function": "CreateZoomToEntityTool"
|
|
}
|
|
},
|
|
{
|
|
"name": "zoom_to_window",
|
|
"description": "缩放到指定 WCS 范围(逐图框审查用,对直线组图框尤其实用)。范围可给 min_x/min_y/max_x/max_y 或 window 对象。",
|
|
"inputSchema": {
|
|
"type": "object",
|
|
"properties": {
|
|
"min_x": { "type": "number" },
|
|
"min_y": { "type": "number" },
|
|
"max_x": { "type": "number" },
|
|
"max_y": { "type": "number" },
|
|
"window": { "type": "object", "properties": { "min_x": { "type": "number" }, "min_y": { "type": "number" }, "max_x": { "type": "number" }, "max_y": { "type": "number" } } },
|
|
"margin": { "type": "number", "description": "四周留边比例,默认 0.02" }
|
|
}
|
|
},
|
|
"backend": {
|
|
"type": "c++_dll",
|
|
"dll_name": "cad_mcp_plugins.dll",
|
|
"factory_function": "CreateZoomToWindowTool"
|
|
}
|
|
},
|
|
{
|
|
"name": "highlight_entities",
|
|
"description": "按 handle 列表临时高亮实体(改色,默认红色);restore=true 时复位为 ByLayer。",
|
|
"inputSchema": {
|
|
"type": "object",
|
|
"properties": {
|
|
"handle": { "type": "string" },
|
|
"handles": { "type": "array", "items": { "type": "string" } },
|
|
"color": { "type": "integer", "description": "ACI 颜色索引,默认 1(红)" },
|
|
"restore": { "type": "boolean", "description": "是否复位为 ByLayer" }
|
|
}
|
|
},
|
|
"backend": {
|
|
"type": "c++_dll",
|
|
"dll_name": "cad_mcp_plugins.dll",
|
|
"factory_function": "CreateHighlightEntitiesTool"
|
|
}
|
|
}
|
|
]
|
|
}
|