show_elements
Highlight and center specified elements in Revit views using JSON-RPC 2.0. Supports batch operations, auto-scaling, strict parameter validation, and detailed error handling for precise element visualization.
Instructions
在Revit视图中高亮显示指定元素,支持批量操作并遵循JSON-RPC 2.0规范。 mcp_tool使用时params不要有任何注释信息
特性:
支持批量显示多个元素
自动处理整数和字符串格式的元素ID
元素自动缩放至视图中心并高亮显示
严格的参数验证和错误处理
完全匹配服务器端实现逻辑
参数: ctx (Context): FastMCP上下文对象 method (str): JSON-RPC方法名,默认为"ShowElements" params (List[Dict[str, Union[int, str]]]): 元素参数列表,每个字典必须包含: - elementId (Union[int, str]): 要显示的元素ID
返回: dict: JSON-RPC 2.0格式的响应,结构为: 成功时: { "jsonrpc": "2.0", "result": [成功显示的元素ID列表], "id": request_id } 失败时: { "jsonrpc": "2.0", "error": { "code": 错误代码, "message": 错误描述, "data": 错误详情 }, "id": request_id }
错误代码: -32600 (Invalid Request): 参数验证失败 -32602 (Invalid Params): 无效元素ID或元素不存在 -32603 (Internal Error): 内部处理错误 -32700 (Parse Error): 参数解析错误
示例: >>> # 显示多个元素 >>> response = show_elements(ctx, params=[ ... {"elementId": 212781}, ... {"elementId": "212792"} ... ]) >>> print(response) {"jsonrpc":"2.0","result":[212781,212792],"id":1}
视图操作: 成功调用后,元素将在当前视图中: 1. 自动缩放至视图中心 2. 高亮显示 3. 被添加到当前选择集
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| method | No | ShowElements | |
| params | No |
Implementation Reference
- xml_revit_mcp/server.py:50-55 (registration)show_elements is registered as part of GENERAL_TOOLS list, which are then registered using server.tool() in register_tools function called at line 248.GENERAL_TOOLS = [ get_commands, execute_commands, call_func, find_elements, update_elements, delete_elements, parameter_elements, get_locations, move_elements, show_elements, active_view, get_selected_elements, link_dwg_and_activate_view, get_view_data ]
- tests/ShowElements.py:14-20 (helper)Test file demonstrating usage of ShowElements RPC method with element IDs."method": "ShowElements", "params": data, } # 发送更新元素数据 send_tcp_data(json_rpc_request)
- xml_revit_mcp/prompts.py:52-52 (helper)Documentation mentioning usage of show_elements() to highlight elements in view.- 使用show_elements()在视图中高亮显示特定元素
- xml_revit_mcp/prompts.py:62-62 (helper)Documentation mentioning using show_elements() to check key elements.- 使用show_elements()检查关键元素
- xml_revit_mcp/server.py:145-146 (registration)The loop that applies server.tool() decorator to all tools in GENERAL_TOOLS including show_elements.for tool in GENERAL_TOOLS: server.tool()(tool)