Skip to main content
Glama

get_locations

Retrieve precise location data for Revit elements in JSON-RPC 2.0 format. Batch query multiple elements, handle unit conversions (feet to millimeters), and process point and curve positions for efficient automation.

Instructions

获取Revit元素的位置信息,支持点和曲线元素,遵循JSON-RPC 2.0规范。 mcp_tool使用时params不要有任何注释信息

特性:

  • 支持批量查询多个元素的位置

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

  • 支持点位置和曲线位置(直线和圆弧)

  • 完善的错误处理机制

参数: ctx (Context): FastMCP上下文对象 method (str): JSON-RPC方法名,默认为"GetLocations" params (List[Dict]): 查询参数列表,每个字典包含: - elementId (Union[str, int]): 要查询的元素ID,优先使用str类型Id

返回: dict: JSON-RPC 2.0格式的响应,结构为: 成功时: { "jsonrpc": "2.0", "result": { "elementId1": [ { "X": float, # X坐标(毫米) "Y": float, # Y坐标(毫米) "Z": float # Z坐标(毫米) }, ... ], ... }, "id": request_id } 失败时: { "jsonrpc": "2.0", "error": { "code": int, "message": str, "data": any }, "id": request_id }

错误代码: -32600: 无效请求 -32602: 无效参数(元素不存在等) -32603: 内部错误 -32700: 解析错误

示例: # 查询多个元素的位置 response = get_location(ctx, params=[ {"elementId": 123456}, {"elementId": "789012"} ])

# 输出示例(XYZ元素) { "jsonrpc": "2.0", "result": { "123456": [ {"X": 1000.0, "Y": 2000.0, "Z": 0.0} ] }, "id": 1 } # 输出示例(Line元素) { "jsonrpc": "2.0", "result": { "789012": [ {"X": 0.0, "Y": 0.0, "Z": 0.0}, {"X": 5000.0, "Y": 0.0, "Z": 0.0} ] }, "id": 1 } # 输出示例(Arc元素) { "jsonrpc": "2.0", "result": { "789012": [ {"X": 0.0, "Y": 0.0, "Z": 0.0}, {"X": 5000.0, "Y": 0.0, "Z": 0.0} {"X": 2500.0, "Y": 1200, "Z": 0.0} ] }, "id": 1 } 用途:找到定位后可用于创建门窗这种带有主体的族,族插入点就可以通过这个计算出来

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
methodNoGetLocations
paramsNo

Implementation Reference

  • Registration reference: get_locations is included in the GENERAL_TOOLS list, which is imported from .tools and registered to the FastMCP server.
    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 ]
  • Code block that registers all tools in GENERAL_TOOLS (including get_locations) to the MCP server using server.tool() decorator.
    for tool in GENERAL_TOOLS: server.tool()(tool)
  • Test script demonstrating the RPC call to 'GetLocations' method on Revit side, which corresponds to the MCP tool get_locations.
    json_rpc_request = { "jsonrpc": "2.0", "method": "GetLocations", "params": data, } # 发送更新元素数据 send_tcp_data(json_rpc_request)
  • Prompt text referencing the usage of get_locations() tool.
    - 使用get_locations()获取墙体的位置信息,以便正确放置门窗

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