create_rooms
Automatically creates rooms on specified levels within Revit models, ensuring data consistency through transactional operations and validating level element accuracy.
Instructions
在指定标高上创建房间,遵循JSON-RPC 2.0规范。 mcp_tool使用时params不要有任何注释信息
特性:
支持批量在多个标高上创建房间
自动验证标高元素有效性
事务化操作确保数据一致性
完善的错误处理机制
参数: ctx (Context): FastMCP上下文对象 method (str): JSON-RPC方法名,默认为"CreateRooms" 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 = create_rooms(ctx, params=[ {"elementId": 123456}, {"elementId": "789012"} ])
注意: 1. 会在指定标高的所有封闭区域创建房间 2. 返回的房间信息列表顺序与创建顺序一致 3. 如果标高没有封闭区域,则不会创建房间但也不会报错
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| method | No | CreateRooms | |
| params | No |
Implementation Reference
- xml_revit_mcp/server.py:41-44 (registration)The 'create_rooms' function is included in the ARCHITECTURAL_TOOLS list used for registering 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 ]
- xml_revit_mcp/server.py:137-139 (registration)The register_tools function applies the MCP server.tool() decorator to register all ARCHITECTURAL_TOOLS, including create_rooms.for tool in ARCHITECTURAL_TOOLS: server.tool()(tool)
- xml_revit_mcp/prompts.py:41-41 (helper)Prompt documentation describes the usage of create_rooms() to create rooms in enclosed areas.- 使用create_rooms()在封闭区域创建房间
- tests/CreateRooms.py:14-19 (helper)Test script demonstrates calling the 'CreateRooms' RPC method, corresponding to the create_rooms tool."method": "CreateRooms", "params": data, } # 发送更新元素数据 send_tcp_data(json_rpc_request)