Skip to main content
Glama

delete_elements

Remove multiple elements from Revit models using batch operations with dictionary parameters. Supports integer or string element IDs and ensures data consistency through transactional processing.

Instructions

批量删除Revit元素,支持字典格式参数,支持批量操作并遵循JSON-RPC 2.0规范。 mcp_tool使用时params不要有任何注释信息

特性:

  • 完全匹配服务器参数处理逻辑

  • 支持字典列表格式参数,每个字典包含elementId键

  • 自动处理整数和字符串格式的elementId

  • 事务化操作确保数据一致性

  • 详细的错误处理和日志记录

参数: ctx (Context): FastMCP上下文对象 method (str): JSON-RPC方法名,默认为"DeleteElements" params (List[Dict[str, Union[int, str]]]): 删除参数列表,每个字典必须包含: - elementId (Union[int, str]): 要删除的元素ID

返回: dict: JSON-RPC 2.0格式的响应,结构为: 成功时: { "jsonrpc": "2.0", "result": [ { "elementId": "删除的元素ID", "name": "元素名称", "familyName": "族名称" }, ... ], "id": request_id } 失败时: { "jsonrpc": "2.0", "error": { "code": int, "message": str, "data": any }, "id": request_id }

示例: >>> # 删除多个元素(混合格式) >>> response = delete_elements(ctx, params=[ ... {"elementId": 5943}, ... {"elementId": "5913"}, ... {"elementId": 212831} ... ]) >>> print(response) { "jsonrpc": "2.0", "result": [ {"elementId": "5943", "name": "Wall 1", "familyName": "Basic Wall"}, {"elementId": "5913", "name": "Door 1", "familyName": "Single-Flush"}, {"elementId": "212831", "name": "Window 1", "familyName": "Fixed"} ], "id": 1 }

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
methodNoDeleteElements
paramsNo

Implementation Reference

  • delete_elements is included in the GENERAL_TOOLS list used for registering general purpose Revit operation tools with the FastMCP server.
    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 ]
  • Loop that registers each tool in GENERAL_TOOLS, including delete_elements, as an MCP tool using the FastMCP server.tool() decorator.
    # 注册通用工具 for tool in GENERAL_TOOLS: server.tool()(tool)
  • Prompt text instructing usage of delete_elements() tool for removing unwanted elements in the asset creation strategy.
    - 使用delete_elements()移除不需要的元素
  • Test/client script sending JSON-RPC request with method 'DeleteElements' (likely the backend RPC called by the delete_elements MCP tool) to the Revit plugin.
    json_rpc_request = { "jsonrpc": "2.0", "method": "DeleteElements", "params": data, } # 发送更新元素数据 send_tcp_data(json_rpc_request)
  • Call to register_tools(mcp) which registers the delete_elements tool among others.
    register_tools(mcp)

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