I found a script online which removes all Expressions from all layers within a composition. I tried to change it up so it only removes all expressions from selected layers and it works, but I always get an Alert after I run it that says "Unable to execute script at line 14. undefined is not an object". I was able to get rid of this error but than it only works on the last selected layer.
Also I don't really know what the recurse_children function does. Maybe someone knows a better way to do this?
Thanks in advance
Christian
Code: Select all
app.beginUndoGroup("Remove all Expressions");
{
var comp = app.project.activeItem;
var layerNumber = comp.selectedLayers.length;
var chosenLayers = comp.selectedLayers;
if (layerNumber >= 1){
for (var i = 0; i <= layerNumber; i++)
{
var layerNames = chosenLayers[i].index;
recurse_children(comp.layers[layerNames]);
}
}
else{
alert('no layer selected');
}
function recurse_children(propParent)
{
if (propParent != null)
{
var prop;
for (var i=1; i<=propParent.numProperties; i++)
{
prop = propParent.property(i);
switch (prop.propertyType)
{
case PropertyType.PROPERTY:
// do action
if (prop.canSetExpression && prop.expression) prop.expression = '';
break;
case PropertyType.INDEXED_GROUP:
recurse_children(prop);
break;
case PropertyType.NAMED_GROUP:
recurse_children(prop);
break;
default:
break;
}
}
}
}
}
app.endUndoGroup();