get_current_view_elements
Retrieve elements from the active Revit view, filtering by model or annotation categories. Control results with options to include hidden elements and limit the number of returned items for precise data extraction.
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 |
|---|---|---|---|
| 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 | |
| modelCategoryList | No | List of Revit model category names (e.g., 'OST_Walls', 'OST_Doors', 'OST_Floors') |
Implementation Reference
- The handler function that executes the tool logic: processes input args into params, uses withRevitConnection to send 'get_current_view_elements' command to Revit client, formats response as JSON text content or 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) }`, }, ], }; } }
- Input schema defined with Zod for tool parameters: modelCategoryList (array of strings), annotationCategoryList (array of strings), includeHidden (boolean), limit (number). All optional.{ 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)The registration function registerGetCurrentViewElementsTool that calls server.tool to register the 'get_current_view_elements' tool with its name, description, input schema, and handler. This function is dynamically invoked by src/tools/register.ts.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) }`, }, ], }; } } ); }