Skip to content

Instantly share code, notes, and snippets.

@rob-kistner
Last active October 18, 2017 03:04
Show Gist options
  • Select an option

  • Save rob-kistner/05e3cafcb9dccb33cf0950d89710a665 to your computer and use it in GitHub Desktop.

Select an option

Save rob-kistner/05e3cafcb9dccb33cf0950d89710a665 to your computer and use it in GitHub Desktop.
Runs through 4 commands to expand a group of shapes with mixed fills & strokes to a single group of fills. This will essentially subtract all the overlapping areas to allow for a single fill shape at the end. Useful for creating a one color icon with a single path that has stroke knockouts.
function main() {
// errors feedback
var errs = [];
// Expand Appearance
try {
errs.push('Expand Appearance...ok\n');
app.executeMenuCommand('expandStyle');
} catch (e) {
errs.push(e + '\n');
report(errs);
}
// Expand
try {
errs.push("Expand...ok\n")
app.executeMenuCommand('Expand3');
} catch (e) {
errs.push(e + '\n');
report(errs);
}
// Live Paint...Make
try {
errs.push("Live Paint > Make...ok\n");
app.executeMenuCommand('Make Planet X');
} catch (e) {
errs.push(e + '\n');
report(errs);
}
// Live Paint...Expand
try {
errs.push("Live Paint > Expand...ok\n")
app.executeMenuCommand('Expand Planet X');
} catch (e) {
errs.push(e + '\n');
report(errs);
}
// Everything worked, give feedback
alert("All objects expanded.")
}
function report(errs) {
errs.join("");
alert(errs);
}
main();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment