Skip to main content
Glama

find_elements

Locate elements in Revit by category, returning a list of matching elements in JSON-RPC 2.0 format. Supports BuiltInCategory, Category.Name, and filters for instance or type elements.

Instructions

在Revit中按类别查找元素,返回匹配的元素信息列表,遵循JSON-RPC 2.0规范。 mcp_tool使用时params不要有任何注释信息

特性:

  • 支持按类别BuiltInCategory或者Category.Name查找

  • 可指定查找实例或类型元素

  • 支持批量多个查询条件

  • 严格遵循JSON-RPC 2.0规范

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

参数: ctx (Context): FastMCP上下文对象 method (str): JSON-RPC方法名,默认为"FindElements" params (List[Dict[str, Union[str, bool]]]): 查询条件列表,每个字典包含: - categoryName (str): BuiltInCategory或者Category.Name (如"OST_Walls","OST_Doors", "墙", "门", "结构框架"等) - isInstance (bool): True查找实例,False查找类型

返回: 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: 无效请求(参数验证失败) -32602: 类别未找到(无效的BuiltInCategory或Category.Name) -32603: 内部错误 -32700: 解析错误(参数格式错误)

示例: >>> response = find_elements(ctx, params=[ ... {"categoryName": "OST_Doors", "isInstance": False}, ... {"categoryName": "门", "isInstance": True} ... ]) >>> print(response) { "jsonrpc": "2.0", "result": [ {"elementId": "123456", "name": "单扇门", "familyName": "M_单扇门"}, {"elementId": "789012", "name": "双扇门", "familyName": "M_双扇门"} ], "id": 1 }

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
methodNoFindElements
paramsNo

Implementation Reference

  • The find_elements tool function is included in the GENERAL_TOOLS list used for registering general purpose Revit tools to the MCP 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 ]
  • The register_tools function registers each tool in GENERAL_TOOLS, including find_elements, to the FastMCP server using the @tool decorator equivalent.
    for tool in GENERAL_TOOLS: server.tool()(tool)
  • Import statement that brings in the find_elements handler function and other tools from the tools module.
    from .tools import *

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