Skip to main content
Glama

update_elements

Batch update parameter values for Revit elements with automatic type conversion, detailed error reporting, and transaction support.

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

TableJSON Schema
NameRequiredDescriptionDefault
methodNoUpdateElements
paramsNo

Implementation Reference

  • Registration of the update_elements tool as part of GENERAL_TOOLS using the FastMCP server.tool() decorator in the register_tools function.
    # 注册通用工具 for tool in GENERAL_TOOLS: server.tool()(tool)
  • update_elements is listed in the GENERAL_TOOLS array which is used for registration.
    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 ]
  • Example input schema for the tool: list of dicts with elementId (int or str), parameterName (str), parameterValue (str). Used with RPC method 'UpdateElements'.
    data = [ {"elementId": 212781, "parameterName": "注释", "parameterValue": "2100"}, {"elementId": "212792", "parameterName": "注释", "parameterValue": "test"} ] # 构造 JSON-RPC 请求 json_rpc_request = { "jsonrpc": "2.0", "method": "UpdateElements", "params": data, } # 发送更新元素数据 send_tcp_data(json_rpc_request)
  • Documentation mentioning usage of update_elements to modify element parameters after getting them with parameter_elements.
    - 使用parameter_elements()获取元素参数,然后使用update_elements()修改

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ZedMoster/revit-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server