Script to get brush group when getting brush name
Hi, firstly I'm only tagging because that was recommended in a previous post and it got a hit almost immediately after a couple of days lingering. If it's considered pestering then let me know...and I won't do it so often 😉
Tags : @jazz-y , @c.pfaffenbichler , @r-bin , @Stephen Marsh
I use the script below to get brush names in Photoshop. I've just come across a case of duplicate brush names and have two questions:
1. Having done some testing it seems Photoshop will create a new brush group and append a suffix when there are duplicates. However the brush name remains the same. Is this correct?
2. If the above is correct how does Photoshop know which brush to load when a brush is selected? ScriptListener only seems to note the brush name. There must be a unique ID somewhere?
2. Is there any way of getting the brush group name along with the brush name in the script below (or any other script)?
//script start
var names = getPresetList(0);
function getPresetList(presetIndex)
{
// presetIndex: 0 to 7
// 0: Brushes
// 1: Swatches
// 2: Gradients
// 3: Styles
// 4: Patterns
// 5: Contours
// 6: Custom Shapes
// 7: Tools
var presetNames = [];
var ref = new ActionReference();
ref.putProperty(stringIDToTypeID("property"), stringIDToTypeID("presetManager"));
ref.putEnumerated(stringIDToTypeID("application"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
var desc = executeActionGet(ref);
var list = desc.getList(stringIDToTypeID("presetManager"));
var nameList = list.getObjectValue(presetIndex).getList(stringIDToTypeID("name"));
for (var nameIndex = 0; nameIndex < nameList.count; nameIndex++)
{
var n = nameList.getString(nameIndex);
presetNames.push(n);
}
return presetNames;
};
//script end

