delete_element
Remove specific elements from a Revit model using their element IDs to manage and clean up project data.
Instructions
Delete one or more elements from the Revit model by their element IDs.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| elementIds | Yes | The IDs of the elements to delete |
Implementation Reference
- src/tools/delete_element.ts:14-44 (handler)The handler function that implements the logic for the 'delete_element' tool. It prepares parameters from the input args, uses withRevitConnection to send a 'delete_element' command to the Revit client, and returns the response or an error message.
async (args, extra) => { const params = { elementIds: args.elementIds, }; try { const response = await withRevitConnection(async (revitClient) => { return await revitClient.sendCommand("delete_element", params); }); return { content: [ { type: "text", text: JSON.stringify(response, null, 2), }, ], }; } catch (error) { return { content: [ { type: "text", text: `delete element failed: ${ error instanceof Error ? error.message : String(error) }`, }, ], }; } } - src/tools/delete_element.ts:9-13 (schema)The Zod input schema for the 'delete_element' tool, defining 'elementIds' as an array of strings.
{ elementIds: z .array(z.string()) .describe("The IDs of the elements to delete"), }, - src/tools/delete_element.ts:5-46 (registration)The registration function that adds the 'delete_element' tool to the MCP server, including name, description, input schema, and handler function.
export function registerDeleteElementTool(server: McpServer) { server.tool( "delete_element", "Delete one or more elements from the Revit model by their element IDs.", { elementIds: z .array(z.string()) .describe("The IDs of the elements to delete"), }, async (args, extra) => { const params = { elementIds: args.elementIds, }; try { const response = await withRevitConnection(async (revitClient) => { return await revitClient.sendCommand("delete_element", params); }); return { content: [ { type: "text", text: JSON.stringify(response, null, 2), }, ], }; } catch (error) { return { content: [ { type: "text", text: `delete element failed: ${ error instanceof Error ? error.message : String(error) }`, }, ], }; } } ); }