diff --git a/dist/explode_shape_layer.jsx b/dist/explode_shape_layer.jsx deleted file mode 100644 index e41d8ad..0000000 --- a/dist/explode_shape_layer.jsx +++ /dev/null @@ -1 +0,0 @@ -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); \ No newline at end of file diff --git a/dist/explode_shape_layer.min.jsx b/dist/explode_shape_layer.min.jsx new file mode 100644 index 0000000..394144c --- /dev/null +++ b/dist/explode_shape_layer.min.jsx @@ -0,0 +1 @@ +function explodeLayer(e){if(consLog("==============\n=============="),e.length>1)alert("Select a single shape layer");else{var o=e[0];if(void 0!=o&&"ADBE Vector Layer"===o.matchName)for(var r=o.containingComp,t=o.property("Contents"),p=1;p<=t.numProperties;p++){var a=t.property(p);if(a.enabled){var c=r.layers.addShape();c.name=a.name,copyLayerTransform(o,c),insertPropertyToContents(a,c.property("Contents"),"")}}else alert("Select a shape layer")}}function insertPropertyToContents(e,o,r){if(!o.canAddProperty(e.matchName))return!1;for(var t=o.addProperty(e.matchName),p=1;p<=e.numProperties;p++){var a=e.property(p);if(a.enabled&&t.canAddProperty(a.matchName)){consLog(r+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(r+"-- 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,r+=" ");break;case"ADBE Vector Shape - Group":copyPropertyShape(a,c);break;default:c.setValue(a.value)}}}}function copyProperty(e,o,r){r[e].setValue(o[e].value)}function copyPropertyShape(e,o){o.property("ADBE Vector Shape").setValue(e.property("ADBE Vector Shape").value)}function copyPropertyStroke(e,o){copyProperty("composite",e,o),copyProperty("color",e,o),copyProperty("strokeWidth",e,o),copyProperty("lineCap",e,o),copyProperty("lineJoin",e,o),copyProperty("miterLimit",e,o)}function copyPropertyFill(e,o){copyProperty("composite",e,o),copyProperty("fillRule",e,o),copyProperty("color",e,o)}function copyPropertyTransform(e,o){copyProperty("anchorPoint",e,o),copyProperty("position",e,o),copyProperty("scale",e,o),copyProperty("skew",e,o),copyProperty("skewAxis",e,o),copyProperty("rotation",e,o),copyProperty("opacity",e,o)}function copyLayerTransform(e,o){copyProperty("anchorPoint",e,o),copyProperty("position",e,o),copyProperty("scale",e,o),copyProperty("rotation",e,o),copyProperty("opacity",e,o)}function createUI(e){if(e instanceof Panel)var o=e;else(o=new Window("palette",configs.title,void 0,{resizeable:!0})).show();var r=o.add("button",[10,10,100,30],"Explode layer");return o.text=configs.title,o.bounds.width=120,o.bounds.height=40,r.onClick=function(){explodeLayer(app.project.activeItem.selectedLayers)},o}function consLog(e){configs.log&&$.writeln(e)}var configs={title:"Explode layer tool",log:!1},myToolsPanel=createUI(this); \ No newline at end of file diff --git a/explode_shape_layer.jsx b/explode_shape_layer.jsx index 588ecd6..673d10e 100644 --- a/explode_shape_layer.jsx +++ b/explode_shape_layer.jsx @@ -178,25 +178,34 @@ function createUI(thisObj) { if(thisObj instanceof Panel) { var myPanel = thisObj; - var btn = myPanel.add("button", [10, 10, 100, 30], "Explode layer"); - btn.onClick = function() { - explodeLayer( app.project.activeItem.selectedLayers ); - } + } else { - return myPanel; + var myPanel = new Window('palette', configs.title, undefined, { + resizeable : true, + }); + myPanel.show(); - } else { + } - explodeLayer( app.project.activeItem.selectedLayers ); + var btn = myPanel.add("button", [10, 10, 100, 30], "Explode layer"); + + myPanel.text = configs.title; + myPanel.bounds.width = 120; + myPanel.bounds.height = 40; + btn.onClick = function() { + explodeLayer( app.project.activeItem.selectedLayers ); } + return myPanel; + } function consLog(text) { if (configs.log) $.writeln(text); } var configs = { + title: 'Explode layer tool', log : false, };