Skip to main content
Glama
ZedMoster

Revit MCP Server

by ZedMoster

create_grids

Create straight and curved grid lines in Revit for architectural layouts, handling batch creation, unit conversion, and name conflicts automatically.

Instructions

在Revit中创建轴网,支持直线轴网和弧线轴网,遵循JSON-RPC 2.0规范。 mcp_tool使用时params不要有任何注释信息

特性:

  • 支持批量创建多个轴网

  • 支持直线轴网和弧线轴网创建

  • 自动处理单位转换(毫米转英尺)

  • 自动处理轴网名称冲突

  • 完善的错误处理机制

参数: ctx (Context): FastMCP上下文对象 method (str): JSON-RPC方法名,默认为"CreateGrids" params (List[Dict]): 轴网参数列表,每个字典包含: - startX (float): 起点X坐标(毫米) - startY (float): 起点Y坐标(毫米) - endX (float): 终点X坐标(毫米) - endY (float): 终点Y坐标(毫米) - name (str, optional): 轴网名称(可选) - centerX (float, optional): 弧线轴网的圆心X坐标(毫米) - centerY (float, optional): 弧线轴网的圆心Y坐标(毫米)

返回: 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 }

示例: # 创建直线轴网和弧线轴网 response = create_grids(ctx, params=[ { "name": "Grid_A", "startX": 0, "startY": 0, "endX": 10000, "endY": 0 }, { "name": "Grid_B", "startX": 5000, "startY": 0, "endX": 5000, "endY": 10000, "centerX": 5000, "centerY": 5000 } ])

# 输出示例
{
    "jsonrpc": "2.0",
    "result": [
        {
            "elementId": "212801",
            "name": "Grid_A",
            "familyName": "轴网"
        },
        {
            "elementId": "212802",
            "name": "Grid_B",
            "familyName": "轴网"
        }
    ],
    "id": 1
}

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
methodNoCreateGrids
paramsNo

Implementation Reference

  • Tool categorization lists where create_grids is included in ARCHITECTURAL_TOOLS. These lists are used to register the MCP tools.
    # 工具分类
    ARCHITECTURAL_TOOLS = [
        create_levels, create_floor_plan_views, create_grids, create_walls, create_floors,
        create_door_windows, create_rooms, create_room_tags, create_family_instances, create_sheets
    ]
    
    MEP_TOOLS = [
        create_ducts, create_pipes, create_cable_trays
    ]
    
    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 that loops over ARCHITECTURAL_TOOLS (including create_grids) and registers each as an MCP tool using server.tool() decorator.
    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)
  • Test script demonstrating the input schema and structure for the CreateGrids RPC method, which the MCP create_grids tool likely invokes via RevitConnection.send_command.
    # -*- coding: utf-8 -*-
    
    from _tcp import send_tcp_data
    
    data = [
        # 直线轴网
        {
            "name": "Grid_Line_1",
            "startX": 0,
            "startY": 0,
            "endX": 10000,
            "endY": 0,
        },
        {
            "name": "Grid_Line_2",
            "startX": 0,
            "startY": 5000,
            "endX": 10000,
            "endY": 5000,
        },
        {
            "categoryName": "轴网",
            "name": "Grid_Line_3",
            "startX": 0,
            "startY": 10000,
            "endX": 10000,
            "endY": 10000,
        },
    
        # 弧线轴网
        {
            "name": "Grid_Arc_1",
            "startX": 5000,
            "startY": 5000,
            "endX": 15000,
            "endY": 0,
            "centerX": 7000,
            "centerY": 2000,
        },
        {
            "name": "Grid_Arc_2",
            "startX": 10000,
            "startY": 5000,
            "endX": 20000,
            "endY": 5000,
            "centerX": 15000,
            "centerY": 7000,
        }
    ]
    
    # 构造 JSON-RPC 请求
    json_rpc_request = {
        "jsonrpc": "2.0",
        "method": "CreateGrids",
        "params": data,
    }
    
    # 发送数据
    send_tcp_data(json_rpc_request)
  • Prompt documentation referencing create_grids() usage in the recommended asset creation workflow.
    return """创建Revit模型元素时,请遵循以下策略和最佳实践:
    
    0. 在创建任何元素前,优先检查当前项目状态:
       - 使用get_commands()获取所有可用功能
       - 使用get_selected_elements()检查当前选中的元素
       - 使用find_elements()查找特定类别的现有元素
    
    1. 始终遵循正确的创建顺序:
       1. 基础参考系统
          - 使用create_levels()创建必要的标高
          - 使用create_grids()创建轴网系统
          - 使用create_floor_plan_views()为每个标高创建平面视图
    
       2. 主体结构元素
          - 使用create_walls()创建墙体,注意指定正确的起点、终点、高度和宽度
          - 使用create_floors()创建楼板,确保边界点形成封闭环路
    
       3. 二次构件
          - 使用create_door_windows()在墙体上创建门窗
            注意:门窗族需要指定宿主墙,所以必须先有墙再创建门窗
          - 使用get_locations()获取墙体的位置信息,以便正确放置门窗
    
       4. MEP系统
          - 使用create_ducts()创建风管
          - 使用create_pipes()创建管道
          - 使用create_cable_trays()创建电缆桥架
    
       5. 内部划分和标注
          - 使用create_rooms()在封闭区域创建房间
          - 使用create_room_tags()添加房间标签
    
       6. 文档整理
          - 使用create_sheets()创建图纸
          - 使用active_view()切换到需要的视图
          - 使用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查找
    """
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden and does well by disclosing key behaviors: batch creation, unit conversion (mm to feet), automatic name conflict handling, and error handling. It also notes JSON-RPC 2.0 compliance and a usage note about params. However, it lacks details on permissions, side effects, or rate limits, leaving some gaps for a mutation tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is front-loaded with purpose and features, but includes extensive parameter details, return format, and a lengthy example that may be verbose. While informative, it could be more streamlined by focusing on essential guidance rather than full JSON-RPC response structures. Some sentences (e.g., the example output) are lengthy but add value.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no annotations, 0% schema coverage, and no output schema, the description does well by covering purpose, behaviors, parameters, and return format comprehensively. It includes an example for clarity. However, as a mutation tool in Revit, it could benefit from more context on when to use it or potential impacts, leaving minor gaps.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate fully. It provides detailed parameter semantics: method defaults to 'CreateGrids', params is a list of dictionaries with specific fields (startX, startY, endX, endY, name, centerX, centerY), including units (mm) and optionality. This adds significant meaning beyond the minimal schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool creates grids (axis networks) in Revit, specifying support for both straight and arc grids. It distinguishes from siblings like create_walls or create_floors by focusing on grid creation, though it doesn't explicitly contrast with them. The purpose is specific but lacks explicit sibling differentiation.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives. While it mentions JSON-RPC 2.0 compliance and a note about params without comments, it doesn't explain prerequisites, context (e.g., when grids are needed in Revit workflows), or when to choose this over other creation tools like create_levels. Usage is implied but not explicit.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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