ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

find words in the expression box

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Rainier Raydán
find words in the expression box
on Jun 17, 2017 at 10:03:18 pm

Hi. I have an array ["app", "project"] and I want to find any of those words in a string "app.project.item(2).layer("Dark Gray Solid 3").property("ADBE Transform Group").property("ADBE Rotate Z")"

I found this match(/\b**insert the word**\b/); but I just cant put a variable on it... I've try to set a for() loop so it can look for all the words of the array on the string but I dont know how to do it...


Return to posts index

Rainier Raydán
Re: find words in the expression box
on Jun 19, 2017 at 11:39:57 pm

So I found the split function to split a string in words and make an arry, that way I can just search for a match and in return I get the curLayer. I've use an if(curProp.expressionEnable == true){ exprAry.push(curProp)} so the loop only gets the expressions that are enabled. But for some reason it also gets some of the expressions box that are disabled... when I search for "color" it also gets me all the layers that have a fill color or a color picker...

This is my script:

var proj = app.project;

app.beginUndoGroup("undo");
var exprAry = new Array();

for(i=1;i<=proj.numItems;i++){
var curItem = proj.item(i);
if(curItem instanceof CompItem){
for(q=1;q<=curItem.numLayers;q++){
var curLayer = curItem.layer(q);
for(w=1;w<=curLayer.numProperties;w++){
var curProp1 = curLayer.property(w);
for(e=1;e<=curProp1.numProperties;e++){
var curProp2 = curProp1.property(e);
if(curProp2.expressionEnabled == true){
exprAry.push(getWords (curProp2));
}
for(a=1;a<=curProp2.numProperties;a++){
var curProp3 = curProp2.property(a);
if(curProp3.expressionEnabled == true){
exprAry.push(getWords (curProp3));
}
for(s=1;s<=curProp3.numProperties;s++){
var curProp4 = curProp3.property(s);
if(curProp4.expressionEnabled == true){
exprAry.push(getWords (curProp4));
}
}
}
}
}
for(m=0;m<exprAry.length;m++){
var curAry = exprAry[m];
for(n=0;n<curAry.length;n++){
var curWord = curAry[n];
if(curWord == "color"){
curLayer.label = (2);
}
}
}
}
}
}








function getWords(curProp){
var splitAry = new Array();
var exprS = curProp.expression;
var toLowerC = exprS.toLowerCase();
var split1 = toLowerC.split(".");
for(r=0;r<split1.length;r++){
var a1 = split1[r];
var split2 = a1.split("[");
for(t=0;t<split2.length;t++){
var a2 = split2[t];
var split3 = a2.split("]");
for(y=0;y<split3.length;y++){
var a3 = split3[y];
var split4 = a3.split("(");
for(u=0;u<split4.length;u++){
var a4 = split4[u];
var split5 = a4.split(")");
for(f=0;f<split5.length;f++){
var a5 = split5[f];
var split6 = a5.split('"');
for(g=0;g<split6.length;g++){
var a6 = split6[g];
var split7 = a6.split(" ");
for(h=0;h<split7.length;h++){
var a7 = split7[h];
var split8 = a7.split("+");
splitAry.push(split8);
for(aa=0;aa<split8.length;aa++){
var a8 = split8[aa];
var split9 = a8.split("*");
splitAry.push(split9);
for(ss=0;ss=1){
}
return splitAry;
}






app.endUndoGroup();


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]