delete_element
Remove one or more elements from a Revit model by specifying their element IDs, streamlining model cleanup and updates.
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 |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"elementIds": {
"description": "The IDs of the elements to delete",
"items": {
"type": "string"
},
"type": "array"
}
},
"required": [
"elementIds"
],
"type": "object"
}
Implementation Reference
- src/tools/delete_element.ts:14-44 (handler)Handler function that executes the delete_element tool: prepares params from elementIds, sends command to Revit client, returns response or error.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)Input schema for delete_element tool using Zod: requires array of string elementIds.{ elementIds: z .array(z.string()) .describe("The IDs of the elements to delete"), },
- src/tools/delete_element.ts:5-46 (registration)Registration function for the delete_element tool, called dynamically from src/tools/register.ts. Defines name, description, schema, and handler.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) }`, }, ], }; } } ); }