Translate AI & Automation + CLI reference to all 6 locales
48 translated pages (de, es, fr, it, pl, ru) for the Programmable
section: overview, AI Chat, Collaboration, JSX Renderer, CLI
(inspecting, exporting, analyzing, scripting).
CLI reference and MCP server pages copied as-is (mostly code/tables).
2026-03-08 12:35:03 +00:00
---
title: Scripting
description: Ejecuta JavaScript con la API de Plugins de Figma — consulta nodos, modifica diseños por lotes, crea frames.
---
# Scripting
2026-05-29 12:56:52 +00:00
`openpencil eval` te da acceso a la API completa de Plugins de Figma en la terminal. Lee nodos, modifica propiedades, crea formas — y luego guarda los cambios en el archivo.
Translate AI & Automation + CLI reference to all 6 locales
48 translated pages (de, es, fr, it, pl, ru) for the Programmable
section: overview, AI Chat, Collaboration, JSX Renderer, CLI
(inspecting, exporting, analyzing, scripting).
CLI reference and MCP server pages copied as-is (mostly code/tables).
2026-03-08 12:35:03 +00:00
## Uso Básico
```sh
2026-05-29 12:56:52 +00:00
openpencil eval design.fig -c "figma.currentPage.children.length"
Translate AI & Automation + CLI reference to all 6 locales
48 translated pages (de, es, fr, it, pl, ru) for the Programmable
section: overview, AI Chat, Collaboration, JSX Renderer, CLI
(inspecting, exporting, analyzing, scripting).
CLI reference and MCP server pages copied as-is (mostly code/tables).
2026-03-08 12:35:03 +00:00
```
El flag `-c` recibe JavaScript. El global `figma` funciona como la API de Plugins de Figma.
## Consultar Nodos
```sh
2026-05-29 12:56:52 +00:00
openpencil eval design.fig -c "
Translate AI & Automation + CLI reference to all 6 locales
48 translated pages (de, es, fr, it, pl, ru) for the Programmable
section: overview, AI Chat, Collaboration, JSX Renderer, CLI
(inspecting, exporting, analyzing, scripting).
CLI reference and MCP server pages copied as-is (mostly code/tables).
2026-03-08 12:35:03 +00:00
figma.currentPage.findAll(n => n.type === 'FRAME' & & n.name.includes('Button'))
.map(b => ({ id: b.id, name: b.name, w: b.width, h: b.height }))
"
```
## Modificar y Guardar
```sh
2026-05-29 12:56:52 +00:00
openpencil eval design.fig -c "
Translate AI & Automation + CLI reference to all 6 locales
48 translated pages (de, es, fr, it, pl, ru) for the Programmable
section: overview, AI Chat, Collaboration, JSX Renderer, CLI
(inspecting, exporting, analyzing, scripting).
CLI reference and MCP server pages copied as-is (mostly code/tables).
2026-03-08 12:35:03 +00:00
figma.currentPage.children.forEach(n => n.opacity = 0.5)
" -w
```
`-w` escribe los cambios de vuelta al archivo de entrada. Usa `-o output.fig` para escribir en un archivo diferente.
## Leer desde Stdin
Para scripts más largos:
```sh
2026-05-29 12:56:52 +00:00
cat transform.js | openpencil eval design.fig --stdin -w
Translate AI & Automation + CLI reference to all 6 locales
48 translated pages (de, es, fr, it, pl, ru) for the Programmable
section: overview, AI Chat, Collaboration, JSX Renderer, CLI
(inspecting, exporting, analyzing, scripting).
CLI reference and MCP server pages copied as-is (mostly code/tables).
2026-03-08 12:35:03 +00:00
```
## Modo Aplicación en Vivo
Omite el archivo para ejecutar contra la aplicación de escritorio en ejecución:
```sh
2026-05-29 12:56:52 +00:00
openpencil eval -c "figma.currentPage.name"
Translate AI & Automation + CLI reference to all 6 locales
48 translated pages (de, es, fr, it, pl, ru) for the Programmable
section: overview, AI Chat, Collaboration, JSX Renderer, CLI
(inspecting, exporting, analyzing, scripting).
CLI reference and MCP server pages copied as-is (mostly code/tables).
2026-03-08 12:35:03 +00:00
```
## API Disponible
El objeto `figma` soporta:
- `figma.currentPage` — la página activa
- `figma.root` — la raíz del documento
- `figma.createFrame()` , `figma.createRectangle()` , `figma.createEllipse()` , `figma.createText()` , etc.
- `.findAll()` , `.findOne()` — buscar descendientes
- `.appendChild()` , `.insertChild()` — manipulación del árbol
- Todos los setters de propiedades: `.fills` , `.strokes` , `.effects` , `.opacity` , `.cornerRadius` , `.layoutMode` , `.itemSpacing` , etc.
Esta es la misma API que usan los plugins de Figma, por lo que el conocimiento existente y los fragmentos de código se transfieren directamente.
## Salida JSON
```sh
2026-05-29 12:56:52 +00:00
openpencil eval design.fig -c "..." --json
Translate AI & Automation + CLI reference to all 6 locales
48 translated pages (de, es, fr, it, pl, ru) for the Programmable
section: overview, AI Chat, Collaboration, JSX Renderer, CLI
(inspecting, exporting, analyzing, scripting).
CLI reference and MCP server pages copied as-is (mostly code/tables).
2026-03-08 12:35:03 +00:00
```