get_element_info
Retrieve detailed information about Revit elements, including properties and parameters, by specifying the element ID to analyze model components.
Instructions
获取 Revit 元素的详细信息
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| elementId | Yes | 元素的 ID | |
| getItemPropertyInfo | No | 是否获取元素属性信息 | |
| getItemParameterInfo | No | 是否获取元素参数信息 |
Implementation Reference
- src/revitService.ts:65-72 (handler)The main handler method for the 'get_element_info' tool in the RevitService class. It delegates the request to the RevitSocketClient.async getElementInfo(args: GetElementInfoArgs): Promise<any> { try { return await this.client.getElementInfo(args); } catch (error) { console.error('[RevitService] 获取元素信息失败:', error); throw error; } }
- src/revitSocketClient.ts:232-234 (handler)Socket client handler that sends the 'get_element_info' command with arguments to the Revit plugin via socket.public async getElementInfo(args: GetElementInfoArgs): Promise<any> { return await this.sendRequest('get_element_info', args); }
- src/index.ts:175-197 (registration)Tool registration in the ListToolsRequestSchema handler, defining the tool name, description, and input schema.name: "get_element_info", description: "获取 Revit 元素的详细信息", inputSchema: { type: "object", properties: { elementId: { type: "string", description: "元素的 ID" }, getItemPropertyInfo: { type: "boolean", description: "是否获取元素属性信息", default: true }, getItemParameterInfo: { type: "boolean", description: "是否获取元素参数信息", default: false } }, required: ["elementId"] } }]
- src/types.ts:27-31 (schema)TypeScript interface defining the input arguments for get_element_info, used in service and client classes.export interface GetElementInfoArgs { elementId: string; getItemPropertyInfo?: boolean; getItemParameterInfo?: boolean; }
- src/index.ts:202-239 (handler)Generic MCP CallToolRequestSchema handler that dynamically dispatches to RevitService methods based on tool name (e.g., 'get_element_info' -> getElementInfo).CallToolRequestSchema, async (request) => { // 获取工具名称 const toolName = request.params.name; // 将工具名称转换为 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 || {}); //const result = ''; return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] }; } catch (error) { return { content: [{ type: "text", text: `Revit API 错误: ${error instanceof Error ? error.message : String(error)}` }], isError: true, } } } ); }