create_levels
Create and manage building levels in Revit in bulk, including automatic unit conversion (mm to feet) and resolving naming conflicts. Follows JSON-RPC 2.0 for structured requests and responses.
Instructions
在Revit中创建标高,支持批量创建,遵循JSON-RPC 2.0规范。 mcp_tool使用时params不要有任何注释信息
特性:
支持批量创建多个标高
自动处理单位转换(毫米转英尺)
自动处理标高名称冲突
完善的错误处理机制
参数: ctx (Context): FastMCP上下文对象 method (str): JSON-RPC方法名,默认为"CreateLevels" params (List[Dict]): 标高参数列表,每个字典包含: - elevation (float): 标高高度(毫米) - name (str, optional): 标高名称(可选,默认为"Level_{elevation}")
返回: 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_levels(ctx, params=[ {"elevation": 8000, "name": "Level_3"}, {"elevation": 12000} # 自动生成名称"Level_12000" ])
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| method | No | CreateLevels | |
| params | No |
Implementation Reference
- xml_revit_mcp/server.py:41-44 (registration)create_levels is listed in ARCHITECTURAL_TOOLS array for registration as an architectural tool.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 ]
- xml_revit_mcp/server.py:137-139 (registration)The register_tools function registers all architectural tools including create_levels using server.tool() decorator.for tool in ARCHITECTURAL_TOOLS: server.tool()(tool)
- xml_revit_mcp/prompts.py:22-22 (helper)Prompt documentation references create_levels for creating levels.- 使用create_levels()创建必要的标高
- tests/CreateLevels.py:27-33 (helper)Test script demonstrates the JSON-RPC call to "CreateLevels" method with level data (name, elevation). This shows expected input format for the tool."method": "CreateLevels", "params": data, } # 发送数据 send_tcp_data(json_rpc_request)