+function explodeLayer(e){if(consLog("==============\n=============="),e.length>1)alert("Select a single shape layer");else{var r=e[0];if(void 0!=r&&"ADBE Vector Layer"===r.matchName)for(var o=r.containingComp,t=r.property("Contents"),p=1;p<=t.numProperties;p++){var a=t.property(p);if(a.enabled){var c=o.layers.addShape();c.name=a.name,copyLayerTransform(r,c),insertPropertyToContents(a,c.property("Contents"),"")}}else alert("Select a shape layer")}}function insertPropertyToContents(e,r,o){if(!r.canAddProperty(e.matchName))return!1;for(var t=r.addProperty(e.matchName),p=1;p<=e.numProperties;p++){var a=e.property(p);if(a.enabled&&t.canAddProperty(a.matchName)){consLog(o+a.matchName);var c=t.property(a.matchName)?t.property(a.matchName):t.addProperty(a.matchName);switch(a.matchName){case"ADBE Vector Filter - Merge":case"ADBE Vector Materials Group":consLog(o+"-- skipped");break;case"ADBE Vector Graphic - Stroke":copyPropertyStroke(a,c);break;case"ADBE Vector Graphic - Fill":copyPropertyFill(a,c);break;case"ADBE Vector Transform Group":copyPropertyTransform(a,c);break;case"ADBE Root Vectors Group":case"ADBE Vectors Group":case"ADBE Vector Group":insertPropertyToContents(a,t,o+=" ");break;case"ADBE Vector Shape - Group":copyPropertyShape(a,c);break;default:c.setValue(a.value)}}}}function copyProperty(e,r,o){o[e].setValue(r[e].value)}function copyPropertyShape(e,r){r.property("ADBE Vector Shape").setValue(e.property("ADBE Vector Shape").value)}function copyPropertyStroke(e,r){copyProperty("composite",e,r),copyProperty("color",e,r),copyProperty("strokeWidth",e,r),copyProperty("lineCap",e,r),copyProperty("lineJoin",e,r),copyProperty("miterLimit",e,r)}function copyPropertyFill(e,r){copyProperty("composite",e,r),copyProperty("fillRule",e,r),copyProperty("color",e,r)}function copyPropertyTransform(e,r){copyProperty("anchorPoint",e,r),copyProperty("position",e,r),copyProperty("scale",e,r),copyProperty("skew",e,r),copyProperty("skewAxis",e,r),copyProperty("rotation",e,r),copyProperty("opacity",e,r)}function copyLayerTransform(e,r){copyProperty("anchorPoint",e,r),copyProperty("position",e,r),copyProperty("scale",e,r),copyProperty("rotation",e,r),copyProperty("opacity",e,r)}function createUI(e){if(e instanceof Panel){var r=e;return r.add("button",[10,10,100,30],"Explode layer").onClick=function(){explodeLayer(app.project.activeItem.selectedLayers)},r}explodeLayer(app.project.activeItem.selectedLayers)}function consLog(e){configs.log&&$.writeln(e)}var configs={log:!1},myToolsPanel=createUI(this);
0 commit comments