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: Скрипты
description: Выполняйте JavaScript с Figma Plugin API — запрашивайте узлы, массово изменяйте дизайн, создавайте фреймы.
---
# Скрипты
2026-05-29 12:56:52 +00:00
`openpencil eval` предоставляет полный Figma Plugin API в терминале. Читайте узлы, изменяйте свойства, создавайте фигуры — и сохраняйте изменения обратно в файл.
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
## Базовое использование
```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
```
Флаг `-c` принимает JavaScript. Глобальный объект `figma` работает как Figma Plugin API.
## Запрос узлов
```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 }))
"
```
## Изменение и сохранение
```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` записывает изменения обратно во входной файл. Используйте `-o output.fig` , чтобы записать в другой файл.
## Чтение из stdin
Для длинных скриптов:
```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
```
## Режим работы с приложением
Опустите файл для выполнения команд в запущенном настольном приложении:
```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
Объект `figma` поддерживает:
- `figma.currentPage` — активная страница
- `figma.root` — корень документа
- `figma.createFrame()` , `figma.createRectangle()` , `figma.createEllipse()` , `figma.createText()` и др.
- `.findAll()` , `.findOne()` — поиск по потомкам
- `.appendChild()` , `.insertChild()` — манипуляции с деревом
- В с е сеттеры свойств: `.fills` , `.strokes` , `.effects` , `.opacity` , `.cornerRadius` , `.layoutMode` , `.itemSpacing` и др.
Это тот же API, который используют плагины Figma, поэтому существующие знания и фрагменты кода применимы напрямую.
## 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
```