get_current_view_elements
Retrieve elements from Revit's active view, filtering by model or annotation categories, controlling visibility of hidden elements, and limiting results.
Instructions
Get elements from the current active view in Revit. You can filter by model categories (like Walls, Floors) or annotation categories (like Dimensions, Text). Use includeHidden to show/hide invisible elements and limit to control the number of returned elements.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| modelCategoryList | No | List of Revit model category names (e.g., 'OST_Walls', 'OST_Doors', 'OST_Floors') | |
| annotationCategoryList | No | List of Revit annotation category names (e.g., 'OST_Dimensions', 'OST_WallTags', 'OST_TextNotes') | |
| includeHidden | No | Whether to include hidden elements in the results | |
| limit | No | Maximum number of elements to return |
Implementation Reference
- The main handler function for the 'get_current_view_elements' tool. It processes input arguments, sends a command to the Revit client via withRevitConnection, and returns the response as JSON or an error message.async (args, extra) => { const params = { modelCategoryList: args.modelCategoryList || [], annotationCategoryList: args.annotationCategoryList || [], includeHidden: args.includeHidden || false, limit: args.limit || 100, }; try { const response = await withRevitConnection(async (revitClient) => { return await revitClient.sendCommand( "get_current_view_elements", params ); }); return { content: [ { type: "text", text: JSON.stringify(response, null, 2), }, ], }; } catch (error) { return { content: [ { type: "text", text: `get current view elements failed: ${ error instanceof Error ? error.message : String(error) }`, }, ], }; } }
- Zod schema defining the input parameters for the tool: modelCategoryList, annotationCategoryList, includeHidden, and limit.{ modelCategoryList: z .array(z.string()) .optional() .describe( "List of Revit model category names (e.g., 'OST_Walls', 'OST_Doors', 'OST_Floors')" ), annotationCategoryList: z .array(z.string()) .optional() .describe( "List of Revit annotation category names (e.g., 'OST_Dimensions', 'OST_WallTags', 'OST_TextNotes')" ), includeHidden: z .boolean() .optional() .describe("Whether to include hidden elements in the results"), limit: z .number() .optional() .describe("Maximum number of elements to return"), },
- src/tools/get_current_view_elements.ts:5-69 (registration)Function that registers the 'get_current_view_elements' tool on the MCP server, including name, description, schema, and handler.export function registerGetCurrentViewElementsTool(server: McpServer) { server.tool( "get_current_view_elements", "Get elements from the current active view in Revit. You can filter by model categories (like Walls, Floors) or annotation categories (like Dimensions, Text). Use includeHidden to show/hide invisible elements and limit to control the number of returned elements.", { modelCategoryList: z .array(z.string()) .optional() .describe( "List of Revit model category names (e.g., 'OST_Walls', 'OST_Doors', 'OST_Floors')" ), annotationCategoryList: z .array(z.string()) .optional() .describe( "List of Revit annotation category names (e.g., 'OST_Dimensions', 'OST_WallTags', 'OST_TextNotes')" ), includeHidden: z .boolean() .optional() .describe("Whether to include hidden elements in the results"), limit: z .number() .optional() .describe("Maximum number of elements to return"), }, async (args, extra) => { const params = { modelCategoryList: args.modelCategoryList || [], annotationCategoryList: args.annotationCategoryList || [], includeHidden: args.includeHidden || false, limit: args.limit || 100, }; try { const response = await withRevitConnection(async (revitClient) => { return await revitClient.sendCommand( "get_current_view_elements", params ); }); return { content: [ { type: "text", text: JSON.stringify(response, null, 2), }, ], }; } catch (error) { return { content: [ { type: "text", text: `get current view elements failed: ${ error instanceof Error ? error.message : String(error) }`, }, ], }; } } ); }