Skip to main content
Glama

find_elements

Locate and retrieve Revit model elements by category, such as walls, doors, or views, returning detailed element information in JSON-RPC 2.0 format.

Instructions

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

特性:

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

  • 和视图相关的请使用OST_Views类别作为categoryName参数,获取然后通过参数来过滤出如楼层平面,三维视图,剖面,图纸等

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

  • 支持批量多个查询条件

  • 严格遵循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_Views","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_Views", "isInstance": True}, {"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

  • Registration of the 'find_elements' tool as part of GENERAL_TOOLS list, which is used to register general purpose tools to 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 ]
  • The loop that applies the MCP tool decorator to each function in GENERAL_TOOLS, including find_elements, effectively registering the tool.
    # 注册通用工具 for tool in GENERAL_TOOLS: server.tool()(tool)
  • Call to register_tools which registers all tools including find_elements.
    register_tools(mcp)
  • Documentation mentioning usage of find_elements tool in prompts.
    - 使用find_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