Hi All,
I've been using this javascript to batch replace specific swatches. It works great in CS6 but I get the following error message in CC. Any help much appreciated. Thanks!
Message:
Error 1200: an illustrator error occurred: 1346458189 ('MRAP)
Line:76
-> if (fillColor.spot.name == 'Orange TEMP') fillColor = replaceColor1;
Script:
var destFolder, sourceFolder, files, fileType, sourceDoc, targetFile, svgSaveOpts;
// Select the source folder.
sourceFolder = Folder.selectDialog( 'Select the folder with Illustrator files you want to convert to SVG', '~' );
// If a valid folder is selected
if ( sourceFolder != null )
{
files = new Array();
fileType = prompt( 'Select type of Illustrator files to you want to process. Eg: *.ai', ' ' );
// Get all files matching the pattern
files = sourceFolder.getFiles( fileType );
if ( files.length > 0 )
{
// Get the destination to save the files
destFolder = sourceFolder;
for ( i = 0; i < files.length; i++ )
{
sourceDoc = app.open(files[i]); // returns the document object
// Call function getNewName to get the name and file to save the SVG
var doc = app.activeDocument;
clearLayerOverrides(doc);
function clearLayerOverrides(doc){
var layers=doc.layers;
for(var i=0;i<layers.length;i++){
if (!layers[i].visible){
layers[i].visible=true;
}
if (layers[i].locked){
layers[i].locked=false;
}
}
getInfoC = app.activeDocument.pageItems;
for ( a = 0; a < getInfoC.length; a++ )
{
try {
getInfoC4 = getInfoC[a];
getInfoC4.locked = false;
} catch (e) {}
}
}
app.paste()
app.cut()
targetFile = recoloring();
sourceDoc.save();
sourceDoc.close();
}
}
else
{
alert( 'No matching files found' );
}
}
function recoloring()
{
var docRef = app.activeDocument;
with (docRef) {
var replaceColor1= swatches.getByName('New Orange 123').color;
for (var i = 0; i < pathItems.length; i++) {
with (pathItems[i]) {
if (filled == true && fillColor instanceof SpotColor) {
if (fillColor.spot.name == 'Orange TEMP') fillColor = replaceColor1;
}
if (stroked == true && strokeColor instanceof SpotColor) {
if (strokeColor.spot.name == 'Orange TEMP') strokeColor = replaceColor1;
}
}
}
for (var j = 0; j < stories.length; j++) {
with (stories[j]) {
for (var k = 0; k < characters.length; k++) {
with (characters[k].characterAttributes) {
if (fillColor instanceof SpotColor) {
if (fillColor.spot.name == 'Orange TEMP') fillColor = replaceColor1;
}
if (strokeColor instanceof SpotColor) {
if (strokeColor.spot.name == 'Orange TEMP') strokeColor = replaceColor1;
}
}
}
}
}
}
var docRef = sourceDoc;
with (docRef) {
var replaceColor3= swatches.getByName('New Blue HCT').color;
for (var i = 0; i < pathItems.length; i++) {
with (pathItems[i]) {
if (filled == true && fillColor instanceof SpotColor) {
if (fillColor.spot.name == 'Blue TEMP') fillColor = replaceColor3;
}
if (stroked == true && strokeColor instanceof SpotColor) {
if (strokeColor.spot.name == 'Blue TEMP') strokeColor = replaceColor3;
}
}
}
for (var j = 0; j < stories.length; j++) {
with (stories[j]) {
for (var k = 0; k < characters.length; k++) {
with (characters[k].characterAttributes) {
if (fillColor instanceof SpotColor) {
if (fillColor.spot.name == 'Blue TEMP') fillColor = replaceColor3;
}
if (strokeColor instanceof SpotColor) {
if (strokeColor.spot.name == 'Blue TEMP') strokeColor = replaceColor3;
}
}
}
}
}
}
}