update_elements
Modify Revit element parameters in bulk using JSON-RPC 2.0, handling mixed ID formats, type conversion, and detailed error reporting for efficient updates.
Instructions
批量更新Revit元素参数值,遵循JSON-RPC 2.0规范,支持事务处理。 mcp_tool使用时params不要有任何注释信息
特性:
支持混合格式元素ID(整数/字符串)
自动参数值类型转换
详细的错误报告和元素级状态跟踪
严格遵循JSON-RPC 2.0规范
参数: ctx (Context): FastMCP上下文对象 method (str): JSON-RPC方法名,默认为"UpdateElements" params (List[Dict[str, Union[str, int]]]): 更新参数列表,每个字典必须包含: - elementId (Union[str, int]): 要更新的元素ID - parameterName (str): 参数名称(区分大小写) - parameterValue (str): 参数新值
返回: dict: JSON-RPC 2.0格式的响应,结构为: 成功时: { "jsonrpc": "2.0", "result": [ { "elementId": "元素ID", "name": "元素名称", "familyName": "族名称" }, ... ], "id": request_id } 失败时: { "jsonrpc": "2.0", "error": { "code": 错误代码, "message": 错误描述, "data": 错误详情 }, "id": request_id }
错误代码: -32600 (Invalid Request): 参数验证失败 -32602 (Invalid Params): 无效参数(元素不存在/参数不存在等) -32603 (Internal Error): 内部处理错误 -32700 (Parse Error): 参数解析错误
示例: > # 批量更新元素参数 > response = update_elements(ctx, params=[ ... {"elementId": 123456, "parameterName": "Comments", "parameterValue": "Test"}, ... {"elementId": "789012", "parameterName": "Height", "parameterValue": "3000"} ... ]) > print(response) { "jsonrpc": "2.0", "result": [ {"elementId": "123456", "name": "基本墙", "familyName": "基本墙"}, {"elementId": "789012", "name": "单扇门", "familyName": "M_单扇门"} ], "id": 1 }
事务说明: 所有更新操作在Revit事务组中执行,任一更新失败自动跳过。
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| method | No | UpdateElements | |
| params | No |
Implementation Reference
- xml_revit_mcp/server.py:50-55 (registration)update_elements is included in the GENERAL_TOOLS list used for MCP tool registrationGENERAL_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 ]
- xml_revit_mcp/server.py:144-146 (registration)The register_tools function registers all tools in GENERAL_TOOLS (including update_elements) to the FastMCP server using server.tool() decorator# 注册通用工具 for tool in GENERAL_TOOLS: server.tool()(tool)
- xml_revit_mcp/prompts.py:50-50 (helper)Documentation in prompts.py describing usage of update_elements tool- 使用parameter_elements()获取元素参数,然后使用update_elements()修改
- tests/UpdateElements.py:19-20 (handler)Test file demonstrating the RPC call to UpdateElements method, indicating the tool proxies to Revit RPC 'UpdateElements'send_tcp_data(json_rpc_request)