Created
August 17, 2014 09:03
-
-
Save getflourish/50f5f48812764abda4d2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This plugin selects all layers that have the same fill color as the currently selected layer/s (command shift c) | |
// Can be used to combine colors that are visually very similar | |
#import 'inventory.js' | |
// Get an array of all selected colors | |
var count = 0; | |
var referenceColors = []; | |
var pages = [[doc pages]objectEnumerator]; | |
var color; | |
var hexColor; | |
var layers; | |
for (var c = 0; c < selection.count(); c++) { | |
color = inventory.colors.getColorOf(selection[c]); | |
hexColor = [color hexValue] | |
referenceColors.push(hexColor); | |
} | |
// Loop through all pages, artboards, layers | |
while (page = [pages nextObject]) { | |
if (page.name != inventory.config.pageName){ | |
layers = [[page children] objectEnumerator]; | |
while (layer = [layers nextObject]) { | |
color = inventory.colors.getColorOf(layer); | |
if (color !== null) { | |
if (inventory.common.isIncluded(referenceColors, [color hexValue]) == 1) { | |
[layer select:true byExpandingSelection:true]; | |
count++; | |
} | |
} | |
} | |
} | |
} | |
[doc showMessage: "Selected " + count + " layers."]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment