Revit MCP Server

by ZedMoster
Verified

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

NameRequiredDescriptionDefault
methodNoFindElements
paramsNo

Input Schema (JSON Schema)

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