Skip to main content
Glama

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

TableJSON Schema
NameRequiredDescriptionDefault
methodNoLinkDWGAndActivateView
paramsNo

Implementation Reference

  • The tool 'link_dwg_and_activate_view' is registered by being included in the GENERAL_TOOLS list. This list is used in register_tools() to apply server.tool() decorator to each tool function.
    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 loops over GENERAL_TOOLS (which includes link_dwg_and_activate_view) and registers each tool using server.tool().
    def register_tools(server: FastMCP) -> None: """注册所有工具到MCP服务器""" # 注册建筑工具 for tool in ARCHITECTURAL_TOOLS: server.tool()(tool) # 注册MEP工具 for tool in MEP_TOOLS: server.tool()(tool) # 注册通用工具 for tool in GENERAL_TOOLS: server.tool()(tool)
  • The tool is mentioned in the asset_creation_strategy prompt as part of the documentation for creating sheets and linking DWG files.
    - 使用link_dwg_and_activate_view()链接DWG图纸 2. 操作现有元素时的最佳实践: - 使用parameter_elements()获取元素参数,然后使用update_elements()修改 - 使用move_elements()调整元素位置 - 使用show_elements()在视图中高亮显示特定元素 - 使用delete_elements()移除不需要的元素 3. 创建复杂组件时: - 使用create_family_instances()创建参数化族实例 - 对于未预定义的功能,使用call_func()调用特定功能 4. 所有元素创建后的检查与验证: - 检查元素参数是否符合要求 - 确保结构完整性和空间关系合理性 - 使用show_elements()检查关键元素 - 使用active_view()切换到需要的视图 仅在以下情况使用原生RevitAPI: - 上述函数不能满足特定需求 - 需要创建自定义参数或复杂约束 - 需要进行高级计算或特殊几何操作 - 需要与其他应用程序进行数据交换 - 如果获取BuiltInCategory失败可以通过get_all_builtin_category查找 """

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