rob-kistner
9/25/2017 - 2:26 PM

AI - Expand All

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();