il_run_script
Run custom ExtendScript in Illustrator and return the result, with helpers for documents, layers, colors, fonts, and exports. Use it to automate vector edits and queries.
Instructions
Run any ExtendScript in Illustrator and return its result (body of a function; return sends data back). Helpers: KAI.doc(ref), KAI.docInfo(doc), KAI.itemInfo(item), KAI.find(doc, name|/re/, layer), KAI.item(...), KAI.layer(doc, "A/B"), KAI.color("#hex"|[r,g,b]), KAI.font(name), KAI.bounds(item), KAI.clipBounds(item) (what you see of a clipped group), KAI.exportPNG(doc, file, artboard, scale), KAI.exportSVG(...). ARGS holds args. Alerts are suppressed during the run. Illustrator has no scripted undo groups: save a copy (il_save version) before big edits.
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": {
"code": "<code>"
},
"name": "il_run_script"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| args | No | ||
| code | Yes | ||
| timeout_sec | No | ||
| expected_project | No | Document guard: refuse to run unless the active document path contains this text. Use it for every edit to a client file. |