June 03rd 2016 08:00:26am
Welcome to Free Function Friday episode 36 getLabelColorNames. Today we look at how to retrieve the label color names from the preferences file. The label names you get will match the same names listed when clicking a project item or a composition layer label icon.
You can use this list as source for a drop down menu of your own creation for example. I touched on a possible use in the layersAtCurTime tutorial a few weeks back. You could even repurpose nearly all of the Fast Marker Creator script to make a fast labeler version.
Source Code:
alert(getLabelColorNames());
function getLabelColorNames(){
var count = 1;
var labelColors = new Array();
labelColors.push("None");
while(app.preferences.havePref("Label Preference Text Section 5", "Label Text ID 2 # "+count.toString(), PREFType.PREF_Type_MACHINE_INDEPENDENT) == true){
labelColors.push(app.preferences.getPrefAsString("Label Preference Text Section 5", "Label Text ID 2 # "+count.toString(), PREFType.PREF_Type_MACHINE_INDEPENDENT));
count++;
}
if(labelColors.length > 0){
return labelColors;
}else{
return null;
}
}