Skip to main content
Glama

get_elements

Retrieve elements from Revit models by specifying categories, views, or levels to access and analyze building information data.

Instructions

获取 Revit 模型中的元素

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
categoryIdsNo需要获取的元素所属类别的Id集合
viewIdsNo需要获取的元素所处的视图的Id集合
levelIdsNo需要获取的元素所处的标高的Id集合

Implementation Reference

  • src/index.ts:140-158 (registration)
    Registration of the 'get_elements' tool including name, description, and input schema in ListToolsRequestSchema.
    name: "get_elements", description: "获取 Revit 模型中的元素", inputSchema: { type: "object", properties: { categoryIds: { type: "array", description: "需要获取的元素所属类别的Id集合" }, viewIds: { type: "array", description: "需要获取的元素所处的视图的Id集合" }, levelIds: { type: "array", description: "需要获取的元素所处的标高的Id集合" } } }
  • Dynamic dispatching in CallToolRequestSchema handler that maps 'get_elements' to revitService.getElements and invokes it.
    // 将工具名称转换为 camelCase 方法名 const methodName = toolName.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase()); // 检查 RevitService 是否有对应的方法 if (typeof (this.revitService as any)[methodName] !== 'function') { throw new McpError( ErrorCode.MethodNotFound, `未知工具: ${toolName}` ); } try { // 动态调用对应的方法 const result = await (this.revitService as any)[methodName](request.params.arguments || {});
  • Core handler method in RevitService that forwards get_elements request to the RevitSocketClient.
    async getElements(args: GetElementsArgs): Promise<RevitElement[]> { try { return await this.client.getElements(args); } catch (error) { console.error('[RevitService] 获取元素失败,使用模拟数据:', error); throw error; // 不使用模拟数据,直接抛出错误 } }
  • Socket client method that sends the 'get_elements' command with arguments to the Revit plugin.
    public async getElements(args: GetElementsArgs): Promise<RevitElement[]> { const response = await this.sendRequest<RevitElement[]>('get_elements', args); return response; }
  • Type definition for GetElementsArgs used in the handler signatures.
    export interface GetElementsArgs { category?: string; family?: string; type?: string; level?: string; limit?: number; }

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/PiggyAndrew/revit_mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server