add_shape
Add shapes like rectangles, circles, or triangles to Adobe Premiere Pro timelines with precise timing, positioning, and sizing controls.
Instructions
Adds a shape (rectangle, circle, etc.) to the timeline.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| shapeType | Yes | The type of shape to add | |
| sequenceId | Yes | The sequence to add the shape to | |
| trackIndex | Yes | The video track to place the shape on | |
| startTime | Yes | The time in seconds when the shape should appear | |
| duration | Yes | How long the shape should remain on screen in seconds | |
| color | No | The hex color code for the shape | |
| size | No | Shape size | |
| position | No | Shape position on screen |
Implementation Reference
- src/tools/index.ts:1581-1648 (handler)The handler function that implements the 'add_shape' tool. It constructs and executes an ExtendScript via the bridge to create a shape layer in Premiere Pro using the legacy title system, add properties like color/size/position, and insert it into the specified sequence track.private async addShape(args: any): Promise<any> { const script = ` try { var sequence = app.project.getSequenceByID("${args.sequenceId}"); if (!sequence) { JSON.stringify({ success: false, error: "Sequence not found" }); return; } var track = sequence.videoTracks[${args.trackIndex}]; if (!track) { JSON.stringify({ success: false, error: "Video track not found" }); return; } // Create a shape using the legacy title system var shapeItem = app.project.createNewTitle("Shape"); if (!shapeItem) { JSON.stringify({ success: false, error: "Failed to create shape" }); return; } // Add shape to title var shape = shapeItem.addShape("${args.shapeType}"); if (shape) { ${args.color ? `shape.fillColor = "${args.color}";` : ''} ${args.size ? ` shape.width = ${args.size.width || 100}; shape.height = ${args.size.height || 100}; ` : ''} ${args.position ? ` shape.x = ${args.position.x || 50}; shape.y = ${args.position.y || 50}; ` : ''} } // Insert the shape into the timeline var shapeClip = track.insertClip(shapeItem, new Time("${args.startTime}s")); shapeClip.end = new Time(shapeClip.start.seconds + ${args.duration}); JSON.stringify({ success: true, message: "Shape added successfully", shapeType: "${args.shapeType}", clipId: shapeClip.nodeId, startTime: ${args.startTime}, duration: ${args.duration}, trackIndex: ${args.trackIndex} }); } catch (e) { JSON.stringify({ success: false, error: e.toString() }); } `; return await this.bridge.executeScript(script); }
- src/tools/index.ts:280-298 (schema)Input schema (Zod) for the 'add_shape' tool, defining parameters like shapeType, sequenceId, trackIndex, startTime, duration, and optional color, size, position.name: 'add_shape', description: 'Adds a shape (rectangle, circle, etc.) to the timeline.', inputSchema: z.object({ shapeType: z.enum(['rectangle', 'circle', 'triangle']).describe('The type of shape to add'), sequenceId: z.string().describe('The sequence to add the shape to'), trackIndex: z.number().describe('The video track to place the shape on'), startTime: z.number().describe('The time in seconds when the shape should appear'), duration: z.number().describe('How long the shape should remain on screen in seconds'), color: z.string().optional().describe('The hex color code for the shape'), size: z.object({ width: z.number().optional().describe('Width in pixels'), height: z.number().optional().describe('Height in pixels') }).optional().describe('Shape size'), position: z.object({ x: z.number().optional().describe('Horizontal position (0-100)'), y: z.number().optional().describe('Vertical position (0-100)') }).optional().describe('Shape position on screen') }) },
- src/tools/index.ts:495-495 (registration)Registration of the 'add_shape' tool in the executeTool switch statement, dispatching to the addShape handler.return await this.addShape(args);