get_element_info
Retrieve detailed information about Revit elements, including properties and parameters, using the element ID. Enhances data accessibility for Revit model management.
Instructions
获取 Revit 元素的详细信息
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| elementId | Yes | 元素的 ID | |
| getItemParameterInfo | No | 是否获取元素参数信息 | |
| getItemPropertyInfo | No | 是否获取元素属性信息 |
Implementation Reference
- src/revitService.ts:65-72 (handler)Handler method in RevitService that is dynamically invoked by the MCP server for the 'get_element_info' tool. Delegates the call to the underlying socket client.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)Specific handler in RevitSocketClient that executes the tool logic by sending a 'get_element_info' socket request to the Revit plugin.public async getElementInfo(args: GetElementInfoArgs): Promise<any> { return await this.sendRequest('get_element_info', args); }
- src/index.ts:175-197 (registration)Tool registration entry 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 schema for get_element_info arguments, matching the MCP inputSchema.export interface GetElementInfoArgs { elementId: string; getItemPropertyInfo?: boolean; getItemParameterInfo?: boolean; }
- src/index.ts:201-239 (registration)MCP CallToolRequestSchema handler that dynamically dispatches tool calls to RevitService methods based on tool name (e.g., 'get_element_info' -> getElementInfo).this.server.setRequestHandler( 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, } } } ); }