Revit MCP Server

by ZedMoster
Verified

link_dwg_and_activate_view

Link local DWG drawings to the current Revit project and activate a specified view using JSON-RPC 2.0 protocol. Automates parameter validation and ensures error handling for efficient workflow integration.

Instructions

链接本地 DWG 图纸并激活指定视图,遵循JSON-RPC 2.0规范。

特性:

  • 支持链接本地 DWG 图纸到当前项目
  • 支持激活指定视图
  • 自动验证参数有效性
  • 完善的错误处理机制

参数: ctx (Context): FastMCP上下文对象 method (str): JSON-RPC方法名,默认为"LinkDWGAndActivateView" params (List[Dict]): 参数列表,每个字典包含: - filePath (str): 本地 DWG 图纸路径 - viewName (str): 要激活的视图名称

返回: dict: JSON-RPC 2.0格式的响应,结构为: 成功时: { "jsonrpc": "2.0", "result": [ { "filePath": "链接的文件路径", "viewId": "视图ID", "viewName": "视图名称" }, ... ], "id": request_id } 失败时: { "jsonrpc": "2.0", "error": { "code": int, "message": str, "data": any }, "id": request_id }

示例: response = link_and_activate_view(ctx, params=[ {"filePath": "C:\Projects\SampleDrawing.dwg", "viewName": "Level 1"} ])

# 输出示例 { "jsonrpc": "2.0", "result": [ { "filePath": "C:\Projects\SampleDrawing.dwg", "viewId": 123456, "viewName": "Level 1" } ], "id": 1 }

Input Schema

NameRequiredDescriptionDefault
methodNoLinkDWGAndActivateView
paramsNo

Input Schema (JSON Schema)

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