Mobile app version of vmapp.org
Login or Join
Reiling762

: Automating file export with different colored objects and file names I’ve been working with Illustrator CC 2014 on a floor map for a ~400 rooms building. To allow visitors to find rooms more

@Reiling762

Posted in: #AdobeIllustrator #Automation #Cc2014 #IllustratorScripting

I’ve been working with Illustrator CC 2014 on a floor map for a ~400 rooms building. To allow visitors to find rooms more quickly, I wanted to generate a series of images with highlighted rooms. The rooms are mostly rectangles with their object name corresponding with their room number.

In short, I need some sort of procedure that does the following tasks:


Change colour of object
Export to PNG using the object name within the file name
Change colour back
Go on to the next object


I have no problem with steps 1, 3 and 4 using Automating tasks, but cannot figure out how to do step 2.

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Reiling762

1 Comments

Sorted by latest first Latest Oldest Best

 

@Cugini998

I have done this exact same thing here's my script:
#target illustrator

var path_prefix=("d:/temp/floormap_")
var layer = app.activeDocument.layers.getByName("rooms");

function exportFileToPNG8(dest) {
if ( app.documents.length > 0 ) {
var exportOptions = new ExportOptionsPNG8();
var type = ExportType.PNG8;
var fileSpec = new File(dest);
exportOptions.colorCount = 32;
exportOptions.transparency = false;
app.activeDocument.exportFile( fileSpec, type, exportOptions );
}
}

for (var i=0; i < layer.pageItems.length; i++){
var item = layer.pageItems[i];
if(item.typename === "GroupItem"){
var room_name = item.pageItems[0].contents;
item.pageItems[1].hidden = false;
exportFileToPNG8(path_prefix+room_name+".png")
item.pageItems[1].hidden = true;
}
}


In order to use you must ensure that you have a layer named rooms and under rooms you have a group for each room with the name of the room topmost and the layer to show hide after that hidden. Remeber to rename the path prefix.



Image 1: example of layer organization

The script is a bit fragile so if text is not first and the group has no second item it will fail. Here is the general outline of how the script works:



Image 2: state diagram of script

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme