Created
October 23, 2015 10:20
-
-
Save dokluch/cf90b0d4581d1bc18a3b to your computer and use it in GitHub Desktop.
Скрипт для статичного соединения объектов шейпом
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Скрипт создает шейп, проходящий через position всех выбранных слоев | |
Не будет работать, если: | |
-слои прикреплены к другим слоям | |
-на позиции есть ключевые кадры/выражения | |
-Все в 3д и есть камеры | |
Все эти пункты легко исправляются по необходимости | |
Nik Ska, 2015 | |
*/ | |
var activeComp = app.project.activeItem; | |
if(activeComp && activeComp instanceof CompItem){ | |
var sel = activeComp.selectedLayers; | |
if(sel.length > 1){ | |
var pos = []; //пишем массив позиций | |
for(var s = 0; s < sel.length; s++){ | |
pos.push(sel[s].property("ADBE Transform Group").property("ADBE Position").value.slice(0,2)); | |
} | |
app.beginUndoGroup("Creating line from points"); | |
//Создаем новый шейп | |
var newShape = activeComp.layers.addShape(); | |
newShape.property("ADBE Transform Group").property("ADBE Position").setValue([0,0]); | |
var _line = new Shape(); | |
_line.vertices = pos; | |
_line.closed = false; //не закрываем | |
//наполняем структуру шейпа | |
var contents = newShape.property("ADBE Root Vectors Group"); | |
var g = contents.addProperty("ADBE Vector Group") | |
var p = g.addProperty("ADBE Vectors Group"); | |
g.name = "_line "; | |
var t1 = p.addProperty("ADBE Vector Shape - Group"); | |
t1.property("ADBE Vector Shape").setValue(_line); | |
//делаем строук | |
p.addProperty("ADBE Vector Graphic - Stroke"); | |
p.property("ADBE Vector Graphic - Stroke").property("ADBE Vector Stroke Width").setValue(2); | |
p.property("ADBE Vector Graphic - Stroke").property("ADBE Vector Stroke Color").setValue([1,1,0]); | |
app.endUndoGroup(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment