Revit MCP Server

by ZedMoster
Verified

active_view

Activate and open views in Revit using JSON-RPC 2.0, supporting single or multiple views with element validation and error handling for efficient model navigation.

Instructions

激活并打开Revit中的视图,遵循JSON-RPC 2.0规范。 mcp_tool使用时params不要有任何注释信息

特性:

  • 支持打开单个或多个视图
  • 自动验证视图元素有效性
  • 过滤模板视图
  • 完善的错误处理机制

参数: ctx (Context): FastMCP上下文对象 method (str): JSON-RPC方法名,默认为"ActiveView" params (List[Dict]): 视图参数列表,每个字典包含: - 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 }

错误代码: -32600: 无效请求 -32602: 无效参数(元素不是视图/是模板视图/无效元素) -32603: 内部错误 -32700: 解析错误

示例: # 激活单个视图 response = active_view(ctx, params=[{"elementId": 123456}])

# 激活多个视图(最后一个成功激活的视图将成为当前视图) response = active_view(ctx, params=[ {"elementId": 123456}, {"elementId": "789012"} ]) # 输出示例 { "jsonrpc": "2.0", "result": [123456, 789012], "id": 1 }

注意: 1. 无法激活模板视图(会返回错误) 2. 如果传入多个视图ID,会依次尝试激活,最后一个成功的视图将成为当前视图 3. 返回的列表包含所有成功激活的视图ID

Input Schema

NameRequiredDescriptionDefault
methodNoActiveView
paramsNo

Input Schema (JSON Schema)

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