Revit MCP Server

by ZedMoster
Verified

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 }

# 错误情况示例 > response = update_elements(ctx, params=[ ... {"elementId":112,"parameterName":"InvalidParam","parameterValue":"X"} ]) > print(response) > {"jsonrpc":"2.0","error":{"code":-32602,"message":"参数无效","data":"参数'InvalidParam'不存在"},"id":1}

事务说明: 所有更新操作在Revit事务组中执行,任一更新失败自动跳过。

Input Schema

NameRequiredDescriptionDefault
methodNoUpdateElements
paramsNo

Input Schema (JSON Schema)

{ "properties": { "method": { "default": "UpdateElements", "title": "Method", "type": "string" }, "params": { "default": null, "items": { "additionalProperties": true, "type": "object" }, "title": "Params", "type": "array" } }, "title": "update_elementsArguments", "type": "object" }
ID: 4dgua6bhbf