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