fabianmoronzirfas
7/1/2012 - 5:08 PM

Split The Shapes from one layer to multiple

Split The Shapes from one layer to multiple

{
    
    main();
    function main(){
app.beginUndoGroup("Split Shape layer");
    var curComp = app.project.activeItem;

   if (!curComp || !(curComp instanceof CompItem)){
        alert("Please select a Composition.");
        return;
    }

    if (curComp.selectedLayers.length < 1){
        alert("Please select at least one layer");
        return;
    }


var shapelayer = curComp.selectedLayers[0];

    if(shapelayer instanceof ShapeLayer){ 
    
    }else{
    return;
    };

    
var number = shapelayer("ADBE Root Vectors Group").numProperties;

    for(var i = 1 ; i < number;i++){
        
    var shape = shapelayer("ADBE Root Vectors Group").property(i).property("ADBE Vector Shape").value;
    
    var newLayer = curComp.layers.addShape();
    newLayer.anchorPoint.setValue([curComp.width/2,curComp.height/2])
    
    newLayer.name =  "Shape";
    
    var vcs = newLayer("ADBE Root Vectors Group").addProperty("ADBE Vector Shape - Group");
    
    var maskShape = vcs.property("ADBE Vector Shape");
    
    maskShape.setValue(shape);

    var fill = newLayer("ADBE Root Vectors Group").addProperty("ADBE Vector Graphic - Fill");
    fill.property("ADBE Vector Fill Color").setValue([1,1,1]);
    fill.property("ADBE Vector Fill Opacity").setValue(100);
    
//~     var bMstroke = newLayer("ADBE Root Vectors Group").addProperty("ADBE Vector Graphic - Stroke");
//~     bMstroke.property("ADBE Vector Stroke Color").setValue(meta.bMarkerStrokeColor);
//~     bMstroke.property("ADBE Vector Stroke Width").setValue(1);
//~     bMstroke.property("ADBE Vector Stroke Opacity").setValue(meta.bMarkerFillTint);
    }


app.endUndoGroup();
}
}