Skip to main content
Glama

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
NameRequiredDescriptionDefault
modelCategoryListNoList of Revit model category names (e.g., 'OST_Walls', 'OST_Doors', 'OST_Floors')
annotationCategoryListNoList of Revit annotation category names (e.g., 'OST_Dimensions', 'OST_WallTags', 'OST_TextNotes')
includeHiddenNoWhether to include hidden elements in the results
limitNoMaximum 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"), },
  • 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) }`, }, ], }; } } ); }

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/revit-mcp/revit-mcp'

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