[TOC]
[TOC]
```
char_separate (this);
function char_separate (thisObj){
var scriptName = "separate_char";
var scriptVersion = "1.3";
if(parseFloat(app.version)>=13.5 || 12>parseFloat(app.version)){
alert("Only CC or CC2014");
return 0;
};
var comp;
var layer;
var checkcolor = new Array();
var point;
var temp;
var check;
var COLOR = [1,1,1,1];
var OVERCOLOR = [1,0,0,1];
var SOLIDCOLOR = [0,1,1];
var dupOutLineLayer;
var xx = new Array();
var count = new Array();
var checkcomplayer;
var checkcomp;
var xlist, ylist;
var pos_checkbox, scl_checkbox, rot_checkbox, opa_checkbox, pre_checkbox;
var num_generatelayer;
var FONTSIZE = null;
function UI(thisObj){
if (thisObj instanceof Panel) {
var myPal = thisObj;
} else {
var myPal = new Window("palette",scriptName + " v" + scriptVersion,undefined,{resizeable:true});
}
if (myPal != null) {
var paletteGrp = myPal.add('group', undefined, 'all');
paletteGrp.orientation= 'row';
paletteGrp.alignChildren = ['fill','fill'];
///////
var rightGrp = paletteGrp.add('group', undefined, 'rightgroup');
rightGrp.orientation= 'column';
var checkerGrp = rightGrp.add('panel', undefined, 'Setting Checker');
checkerGrp.orientation= 'column';
var xlistGrp = checkerGrp.add('group', undefined, 'xlistgrp');
xlistGrp.orientation= 'row';
xtxt = xlistGrp.add('statictext', undefined,'X:');
xlist= xlistGrp.add('dropdownlist', undefined,[1,2,3,4,5,8,10,20]);
var ylistGrp = checkerGrp.add('group', undefined, 'ylistgrp');
ylistGrp.orientation= 'row';
ytxt = ylistGrp.add('statictext', undefined,'Y:');
ylist= ylistGrp.add('dropdownlist', undefined,[1,2,3,4,5,8,10,20]);
pre_checkbox = rightGrp.add('checkbox', undefined,'Precompose');
var doneGrp = rightGrp.add('group', undefined, 'Done');
doneGrp.orientation= 'column';
doneGrp.alignChildren = 'center';
var btn = doneGrp.add('button', undefined, 'Done');
var btn2 = doneGrp.add('button', undefined, 'sentence');
btn.onClick = function(){
main();
}
btn2.onClick = function(){
FONTSIZE = Window.prompt("Please enter FONTSIZE","195");
if(FONTSIZE == null){
alert("Cansel");
return 0;
}
sentence();
}
///////
var leftGrp = paletteGrp.add('group', undefined, 'leftgroup');
leftGrp.orientation= 'column';
var expGrp = leftGrp.add('panel', undefined, 'Expression');
expGrp.orientation= 'column';
expGrp.alignChildren = 'left';
pos_checkbox = expGrp.add('checkbox', undefined,'Position');
scl_checkbox = expGrp.add('checkbox', undefined,'Scale');
rot_checkbox = expGrp.add('checkbox', undefined,'Rotation');
opa_checkbox = expGrp.add('checkbox', undefined,'Opacity');
myPal.layout.layout(true);
myPal.layout.resize();
myPal.onResizing = myPal.onResize = function () {this.layout.resize();}
}
return myPal;
}
function main(){
comp = app.project.activeItem;
layer = comp.selectedLayers[0];
if(checklayer(layer)==1){
return 0;
}
num_generatelayer = 0;
app.beginUndoGroup("MAIN")
checkcomp = createcomp(); //CompItem object
addeffects();
///////
dupOutLineLayer = comp.layer(2);
dupOutLineLayer.name = "dupOutLine";
var OutLineLayer2 = checkcomp.layer(1);
OutLineLayer2.name = "index2";
OutLineLayer2 = checkcomp.layer("index2");
removemask(OutLineLayer2.mask.numProperties, OutLineLayer2);
var OutLineLayer1 = OutLineLayer2.duplicate();
OutLineLayer1.name = "index1";
OutLineLayer1 = checkcomp.layer("index1");
OutLineLayer1.blendingMode = BlendingMode.DIFFERENCE
OutLineLayer1.effect.addProperty("ADBE Tint");
OutLineLayer1.effect("ADBE Tint")("ADBE Tint-0002").setValue(SOLIDCOLOR);
/////////
if(dupOutLineLayer.mask.numProperties == 1){
dupOutLineLayer = comp.layer("dupOutLine");
var sepa = dupOutLineLayer.duplicate();
sepa.name ="separate_"+1;
dupOutLineLayer.remove();
checkcomp.remove();
comp.layer(1).selected = true;
app.executeCommand(10312);
}else{
for(var k = 1;k+1 <= dupOutLineLayer.mask.numProperties;k++){
dupOutLineLayer = comp.layer("dupOutLine");
var count = 0;
var temp2 = dupOutLineLayer.mask(k).maskPath.value;
var newmask2 = OutLineLayer2.Masks.addProperty("Mask");
newmask2.maskPath.setValue(temp2);
var temp1 = dupOutLineLayer.mask(k+1).maskPath.value;
var newmask1 = OutLineLayer1.Masks.addProperty("Mask");
newmask1.maskPath.setValue(temp1);
OutLineLayer2.quality = LayerQuality.DRAFT;
OutLineLayer1.quality = LayerQuality.DRAFT;
check = prechecker();
if(check == true){
removemask(OutLineLayer1.mask.numProperties, OutLineLayer1);
count++;
}
else{
for(var i = 1; i <= OutLineLayer2.mask.numProperties; i++){
xx.push(OutLineLayer2.mask(i).maskPath.value);
}
dupOutLineLayer = comp.layer("dupOutLine");
var sepa = dupOutLineLayer.duplicate();
sepa.name ="separate_"+(num_generatelayer+1);
removemask(sepa.mask.numProperties, sepa);
for(var t=0; t < xx.length; t++){
var sepamask = sepa.Masks.addProperty("Mask");
sepamask.maskPath.setValue(xx[t]);
if(t >= 1){
sepamask.maskMode = MaskMode.SUBTRACT;
}
}
removemask(OutLineLayer1.mask.numProperties, OutLineLayer1);
removemask(OutLineLayer2.mask.numProperties, OutLineLayer2);
xx = [];
num_generatelayer++;
}
if(k+1 == dupOutLineLayer.mask.numProperties){
var temp2 = dupOutLineLayer.mask(k+1).maskPath.value;
var newmask2 = OutLineLayer2.Masks.addProperty("Mask");
newmask2.maskPath.setValue(temp2);
for(var i = 1; i <= OutLineLayer2.mask.numProperties; i++){
xx.push(OutLineLayer2.mask(i).maskPath.value);
}
dupOutLineLayer = comp.layer("dupOutLine");
var sepa = dupOutLineLayer.duplicate();
sepa.name ="separate_"+(num_generatelayer+1);
removemask(sepa.mask.numProperties, sepa);
for(var t=0; t < xx.length; t++){
var sepamask = sepa.Masks.addProperty("Mask");
sepamask.maskPath.setValue(xx[t]);
if(t >= 1){
sepamask.maskMode = MaskMode.SUBTRACT;
}
}
removemask(OutLineLayer1.mask.numProperties, OutLineLayer1);
removemask(OutLineLayer2.mask.numProperties, OutLineLayer2);
xx = [];
num_generatelayer++;
}
}
dupOutLineLayer.remove();
checkcomp.remove();
/////// Center Anchor Point in Layer Content
for(i = 1; i <= num_generatelayer; i++){
comp.layer(i).selected = true;
}
app.executeCommand(10312);
///////
}
if(pos_checkbox.value == true || scl_checkbox.value == true || rot_checkbox.value == true || opa_checkbox.value == true ){
////// adding expression
//var controler = comp.layers.addNull();
var controler = comp.layer(1);
controler.name = "separate_Control"
var n_Eff = controler.effect;
var n_delay = n_Eff.addProperty("ADBE Slider Control");
n_delay.name = "delay";
controler.effect("delay")(1).setValue(3);
}
//////
if(pos_checkbox.value == true){
var p = [];
var p_temp;
for(var i = 1; i <= num_generatelayer; i++){
if(i == 1){
p_temp = "var p = [];\n"
p_temp = p_temp + "p["+i+"] = ["+comp.layer(i).transform.position.value.toString().substring( 0, comp.layer(i).transform.position.value.toString().length-2 )+"];\n";
}else{
p_temp = p_temp + "p["+i+"] = ["+comp.layer(i).transform.position.value.toString().substring( 0, comp.layer(i).transform.position.value.toString().length-2 )+"];\n";
}
}
for(var i = 2; i <= num_generatelayer; i++){
comp.layer(i).transform.position.expression = p_temp
+"value\n"
+"- p[index-1]\n"
+"+ thisComp.layer(index-1).transform.position.valueAtTime( time-(thisComp.layer('separate_Control').effect('delay')(1) /30));\n";
}
}
if(scl_checkbox.value == true){
for(var i = 2; i <= num_generatelayer; i++){
comp.layer(i).transform.scale.expression = "thisComp.layer(index-1).transform.scale.valueAtTime(time - thisComp.layer('separate_Control').effect('delay')(1)/30);";
}
}
if(rot_checkbox.value == true){
for(var i = 2; i <= num_generatelayer; i++){
comp.layer(i).transform.rotation.expression = "thisComp.layer(index-1).transform.rotation.valueAtTime(time - thisComp.layer('separate_Control').effect('delay')(1)/30);";
}
}
if(opa_checkbox.value == true){
for(var i = 2; i <= num_generatelayer; i++){
comp.layer(i).transform.opacity.expression = "thisComp.layer(index-1).transform.opacity.valueAtTime(time - thisComp.layer('separate_Control').effect('delay')(1)/30);";
}
}
if(pre_checkbox.value == true){
precompose();
}
//////
/////
alert("finish");
app.endUndoGroup();
}
///////// function
function createcomp(){ //nesesally para only return CompItem object
// if(para == ParagraphJustification.CENTER_JUSTIFY){
var pos = layer.transform.position;
var size = layer.text.sourceText.value.fontSize;
app.executeCommand(10312);
app.executeCommand(3819);
app.executeCommand(2933);
comp.layer(1).duplicate();
////////
var checkcomp = comp.layers.precompose([1], "newComp", true);
checkcomp.name = "checkComp";
checkcomp.width = size;
checkcomp.height = size;
checkcomp.layer(1).transform.position.setValue([size/2, size/2]);
return checkcomp;
}
function addeffects(){
/////////// add effects
checkcomplayer = comp.layer("checkComp");
var p_Eff = checkcomplayer.effect.addProperty("ADBE Point Control");
p_Eff.name = "check_point"
checkcomplayer.effect.addProperty("ADBE Color Control");
point = checkcomplayer.effect("ADBE Point Control")("ADBE Point Control-0001");
checkcomplayer.effect(2)("ADBE Color Control-0001").expression = "point = effect('check_point')(1);"
+"sampleImage(point,radius=[1,1],postEffect=true,t=time)";
///////////
}
function removemask(len, obj){
for(var i = 1; i <= len; i++){
obj.mask(1).remove();
}
}
function prechecker(){
checkcomplayer = comp.layer("checkComp");
var test = false;
loop: for(var j = 0; j <= checkcomp.width; j += (Number(ylist.selection)+1)){
for(var i = 0; i <= checkcomp.height; i += (Number(xlist.selection)+1)){
point.setValue([j,i]);
checkcolor = checkcomplayer.effect("ADBE Color Control")("ADBE Color Control-0001");
if(checkcolor.value.toString() == OVERCOLOR.toString()){
//alert(true);
test = true;
break loop
}
}
}
return test;
}
function precompose(){
if(num_generatelayer == 0){
yy = new Array();
yy.push(1);
var c = comp.layers.precompose(yy, "newComp", true);
c.name = "pre_separate";
}else{
yy = new Array();
for(i = 1; i <= num_generatelayer; i++){
yy.push(i);
}
var c = comp.layers.precompose(yy, "newComp", true);
c.name = "pre_separate";
}
}
function sentence(){
app.beginUndoGroup("SENTENCE")
comp = app.project.activeItem;
layer = comp.selectedLayers;
var txtlength = comp.selectedLayers.length;
var txtcenter = Math.floor(txtlength/2);
var center = layer[txtcenter].transform.position.value;
FONTSIZE = parseInt(FONTSIZE);
if(txtlength <= 1){
alert("Please select two or more LayerObject");
return 0;
}
var cont = comp.layers.addNull();
cont.name = "sentence_controlar";
var c_Eff = cont.effect;
var c_track = c_Eff.addProperty("ADBE Slider Control");
c_track.name = "tracking";
cont.effect("tracking")(1).setValue(0);
if(txtlength % 2 == 1){
/* back char */
for(var i = txtlength -1;i > txtcenter;i--){//43
layer[i].transform.position.setValue([center[0]+(FONTSIZE*(i - txtcenter)), center[1]]);
layer[i].transform.position.expression = "value+thisComp.layer('sentence_controlar').effect('tracking')(1)*"+(i - txtcenter)+";";
layer[i].parent = comp.layer(1);
}
/*char of center*/
layer[txtcenter].transform.position.setValue([center[0], center[1]]);
layer[txtcenter].parent = comp.layer(1);
/* front char */
for(var i = txtcenter -1;i >= 0;i--){//21
layer[i].transform.position.setValue([center[0]-(FONTSIZE*(txtcenter - i)), center[1]]);
layer[i].transform.position.expression = "value-thisComp.layer('sentence_controlar').effect('tracking')(1)*"+(txtcenter - i)+";";
layer[i].parent = comp.layer(1);
}
}else{
for(i = txtcenter-1; i >= 0;i--){//10
layer[i].transform.position.setValue([center[0]-(FONTSIZE/2)-(FONTSIZE*((txtcenter-1)-i)), center[1]]);
layer[i].transform.position.expression = "value-thisComp.layer('sentence_controlar').effect('tracking')(1)*"+(txtcenter - i)+";";
layer[i].parent = comp.layer(1);
}
for(i = txtlength-1;i >= txtcenter;i--){//23
layer[i].transform.position.setValue([center[0]+(FONTSIZE/2)+(FONTSIZE*(i - txtcenter)),center[1]]);
layer[i].transform.position.expression = "value+thisComp.layer('sentence_controlar').effect('tracking')(1)*"+(i - (txtcenter-1))+";";
layer[i].parent = comp.layer(1);
}
}
alert("finish");
app.endUndoGroup();
}
function checklayer(layerObj)
{
if(!(layerObj instanceof TextLayer)){
alert("Please select TextLayer");
return 1;
}else{
if(layerObj.text.sourceText.value.toString().length != 1){
alert("Please select single charactor");
return 1;
}
return 0;
}
}
////////////////
/*main*/
var myPalette = UI(thisObj);
if (myPalette != null && myPalette instanceof Window) {
myPalette.show();
}
xlist.items[2].selected = true;
ylist.items[2].selected = true;
/////////////////
}
```
- 脚本管理器
- 读取文件夹内文件
- 层层时间线偏移Sequencer.jsx
- 层层随机时间偏移
- 文字分离char_separate_1.3
- 分解文字 把一个文字层分成若干个文字层
- 快速导入Smart Import
- 查找与替换字符 Find and Replace Text.jsx
- 层改名Selected_Layers_Renamer.jsx
- 创建灯光为选择的三维层.jsx
- 创建摄像机为选择的三维图层.jsx
- 创建调节图层CreateTrimmedAdjustmentLayer.jsx
- 创建调节图层多个CreateSeveralTrimmedAdjustmentLayers.jsx
- 创建一个空物体到选择的层Add Parented Null to Selected Layers.jsx
- 文字分离DecomposeText
- 修改渲染输出文件位置Change Render Locations
- AE脚本读取txt文档并写入数组
- AE脚本把数组写入到txt文档中
- AE提取字幕脚本
- AE批量用txt内容替换字幕脚本