fit_box_to_text
Creates or updates a rounded-rectangle background behind a text layer, sized to its bounds plus padding; live-links to text edits in expression mode or bakes static values.
Instructions
Create (or update) a rounded-rectangle background shape that tracks a text layer's bounds + padding, placed directly BEHIND the text. mode="expression" (default) live-links the box Size + Position to the text's sourceRectAtTime every frame, so the box follows edits and animation; mode="bake" computes once at the current comp time and sets static values. padding is a number (all sides), [x,y], or [left,top,right,bottom] px. corner = rounded-corner radius. color (hex "#rrggbb"/"#rgb" or [r,g,b(,a)], 0–1 or 0–255, auto-normalized) + opacity (0–100) style the fill (default black). Pass boxLayer to update an existing box instead of creating a new one. Returns { boxLayer, mode, expressionError }.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"textLayer": "<textLayer>"
},
"name": "fit_box_to_text"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| comp | No | Comp: name (string), or { id: N } for duplicate-name-safe stable-id addressing. Defaults to active comp. | |
| mode | No | expression = live-linked; bake = static at current time. | expression |
| name | No | Name for a newly created box (default "<text> BG"). | |
| color | No | Fill color: hex or [r,g,b(,a)]. Default black. | |
| corner | No | Rounded-corner radius (px). | |
| opacity | No | Fill opacity %. Default 100. | |
| padding | No | px: number (all sides), [x,y], or [left,top,right,bottom]. | |
| boxLayer | No | Existing box layer to update (name, 1-based index, or { id: N }). Omit to create a new one. | |
| instance | No | Target a specific AE when more than one is connected (e.g. "2026", "2025", or a major like "26"). Omit when only one AE is open — see list_instances. | |
| textLayer | Yes | Layer: name (string), 1-based index (integer), or { id: N } for duplicate-name-safe stable-id addressing. |