create_line_based_element
Generate line-based elements like walls, beams, or pipes in Revit using precise parameters: family type ID, start/end points, thickness, height, and level. Supports batch creation with measurements in millimeters.
Instructions
Create one or more line-based elements in Revit such as walls, beams, or pipes. Supports batch creation with detailed parameters including family type ID, start and end points, thickness, height, and level information. All units are in millimeters (mm).
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| data | Yes | Array of line-based elements to create |
Implementation Reference
- The tool handler function that forwards the parameters to the Revit client via sendCommand and returns the response or formatted error.async (args, extra) => { const params = args; try { const response = await withRevitConnection(async (revitClient) => { return await revitClient.sendCommand( "create_line_based_element", params ); }); return { content: [ { type: "text", text: JSON.stringify(response, null, 2), }, ], }; } catch (error) { return { content: [ { type: "text", text: `Create line-based element failed: ${ error instanceof Error ? error.message : String(error) }`, }, ], }; } }
- Zod schema defining the input parameters for creating line-based elements, including name, typeId, locationLine (with p0 and p1 points), thickness, height, baseLevel, and baseOffset.data: z .array( z.object({ name: z .string() .describe("Description of the element (e.g., wall, beam)"), typeId: z .number() .optional() .describe("The ID of the family type to create."), locationLine: z .object({ p0: z.object({ x: z.number().describe("X coordinate of start point"), y: z.number().describe("Y coordinate of start point"), z: z.number().describe("Z coordinate of start point"), }), p1: z.object({ x: z.number().describe("X coordinate of end point"), y: z.number().describe("Y coordinate of end point"), z: z.number().describe("Z coordinate of end point"), }), }) .describe("The line defining the element's location"), thickness: z .number() .describe( "Thickness/width of the element (e.g., wall thickness)" ), height: z .number() .describe("Height of the element (e.g., wall height)"), baseLevel: z.number().describe("Base level height"), baseOffset: z.number().describe("Offset from the base level"), }) ) .describe("Array of line-based elements to create"),
- src/tools/create_line_based_element.ts:5-81 (registration)The registration function that sets up the MCP tool with name, description, schema, and handler using server.tool.export function registerCreateLineBasedElementTool(server: McpServer) { server.tool( "create_line_based_element", "Create one or more line-based elements in Revit such as walls, beams, or pipes. Supports batch creation with detailed parameters including family type ID, start and end points, thickness, height, and level information. All units are in millimeters (mm).", { data: z .array( z.object({ name: z .string() .describe("Description of the element (e.g., wall, beam)"), typeId: z .number() .optional() .describe("The ID of the family type to create."), locationLine: z .object({ p0: z.object({ x: z.number().describe("X coordinate of start point"), y: z.number().describe("Y coordinate of start point"), z: z.number().describe("Z coordinate of start point"), }), p1: z.object({ x: z.number().describe("X coordinate of end point"), y: z.number().describe("Y coordinate of end point"), z: z.number().describe("Z coordinate of end point"), }), }) .describe("The line defining the element's location"), thickness: z .number() .describe( "Thickness/width of the element (e.g., wall thickness)" ), height: z .number() .describe("Height of the element (e.g., wall height)"), baseLevel: z.number().describe("Base level height"), baseOffset: z.number().describe("Offset from the base level"), }) ) .describe("Array of line-based elements to create"), }, async (args, extra) => { const params = args; try { const response = await withRevitConnection(async (revitClient) => { return await revitClient.sendCommand( "create_line_based_element", params ); }); return { content: [ { type: "text", text: JSON.stringify(response, null, 2), }, ], }; } catch (error) { return { content: [ { type: "text", text: `Create line-based element failed: ${ error instanceof Error ? error.message : String(error) }`, }, ], }; } } ); }