Copy link to clipboard
Copied
I'm able to load patterns in a way where I can choose to load them appending to the current patterns or not.
When I want to update the patterns, I load the first pattern with appending on false, and the rest on true, resulting in the removal of all previous patterns, and loading the new ones.
I edited this pattern functions to work with brushes, the only thing that isn't working like it is with patterns is the appending function. It will always append, even on false.
Resulting in duplicate brush sets.
Is it posible to remove "all" brushes?
function cTID(s){
return app.charIDToTypeID(s);
};
function sTID(s){
return app.stringIDToTypeID(s);
};
function actionManagerLoadBrushFile(file, append){
// append: true / false
var d1 = new ActionDescriptor();
var r1 = new ActionReference();
r1.putProperty(cTID('Prpr'), sTID('brush'));
r1.putEnumerated(sTID('application'), sTID('ordinal'), cTID('Trgt'));
d1.putReference(sTID('null'), r1);
d1.putPath(cTID('T '), file);
d1.putBoolean(cTID('Appe'), append);
executeAction(cTID('setd'), d1, DialogModes.NO );
}
var brushFile = new File("/C/Brushes/Brushes.abr");
actionManagerLoadBrushFile(brushFile, false)
sTT = stringIDToTypeID; function brshs() {
(ref = new ActionReference()).putEnumerated
(sTT('application'), sTT('ordinal'), sTT('target'))
return executeActionGet(ref).getList(sTT('presetManager'))
.getObjectValue(0).getList(sTT('name')).count
}
while(brshs()) {
(ref = new ActionReference()).putIndex(sTT('brush'), 1);
(dsc = new ActionDescriptor()).putReference(sTT('null'), ref)
executeAction(sTT('delete'), dsc)
}
Thanks to r-bin: Select/refer to brushes by name within brush sets by name
sTT = stringIDToTypeID; (ref = new ActionReference())
.putProperty(sTT('property'), sTT('brushes')), ref.putClass(sTT('application'))
brshs = eval('('+ executeActionGet(ref).getString(sTT('brushes')) + ')').brushes
while(brshs.length) (nme = brshs.shift().name) != 'private brushes'
&& ((ref = new ActionReference()).putName(sTT('brush'), nme),
(dsc = new ActionDescriptor()).putReference(sTT('null'), ref),
executeAction(sT
...
Copy link to clipboard
Copied
sTT = stringIDToTypeID; function brshs() {
(ref = new ActionReference()).putEnumerated
(sTT('application'), sTT('ordinal'), sTT('target'))
return executeActionGet(ref).getList(sTT('presetManager'))
.getObjectValue(0).getList(sTT('name')).count
}
while(brshs()) {
(ref = new ActionReference()).putIndex(sTT('brush'), 1);
(dsc = new ActionDescriptor()).putReference(sTT('null'), ref)
executeAction(sTT('delete'), dsc)
}
Copy link to clipboard
Copied
Not sure how you do it, but works perfectly as always!
Would it be posible to remove all patterns except when they are in a specific folder name? I gues this would be a real challenge..
This way I could update all patterns except when people have made a "private brushes" folder, and won't be deleted.
Copy link to clipboard
Copied
Thanks to r-bin: Select/refer to brushes by name within brush sets by name
sTT = stringIDToTypeID; (ref = new ActionReference())
.putProperty(sTT('property'), sTT('brushes')), ref.putClass(sTT('application'))
brshs = eval('('+ executeActionGet(ref).getString(sTT('brushes')) + ')').brushes
while(brshs.length) (nme = brshs.shift().name) != 'private brushes'
&& ((ref = new ActionReference()).putName(sTT('brush'), nme),
(dsc = new ActionDescriptor()).putReference(sTT('null'), ref),
executeAction(sTT('delete'), dsc))
Copy link to clipboard
Copied
Thank you so much! Works perfect!
I have made a useful set of easy to read functions for managing brushes, some based on the code you provided. By sharing this, maybe I can help someone else out this way...
- actionManagerDeleteAllBrushes()
- actionManagerDeleteAllBrushesExclude(groupName)
- actionManagerDeleteBrushGroup(groupName)
- actionManagerLoadedBrushGroups()
- actionManagerLoadedBrushes()
- actionManagerLoadBrushFile(file)
Attachment included
Copy link to clipboard
Copied
I never paid attention before, but:
sTT('brushes') ==sTT('brush')
Copy link to clipboard
Copied
So like 'grain' & 'green' or 'paint' & 'point'.
Copy link to clipboard
Copied
Yes
align == alignment
antiAlias == antiAliasedPICTAcquire
backgroundLayer == backgroundLevel
blackGenerationType == blackGenerationCurve
blackLevel == blackLimit
blacks == blocks
blurMethod == blurMore
brightnessEvent == brightnessContrast
brushDetail == brushesDefine
brush == brushes
calculation == calculations
colorPalette == coloredPencil
constant == constrain
centerCropMarks == conteCrayon
shapeCurveType == shapingCurve
center == contrast
controlColorChartreuse == controlColorType
createDroplet == createDuplicate
custom == customPattern
customPalette == customPhosphors
darken == darkness
angleUnit == degreesUnit
desaturate == destWhiteMax
distort == distortion
distort == distribute
distort == distribution
fileInfo == fillInverse
generalPreferences == generalPrefs
grainStippled == graySetup
graininess == greens
grain == green
gradientClassEvent == gridMinor
good == guide
historyPreferences == historyPrefs
historyState == historyStateSourceType
floatType == IEEE64BitFloatingPoint
imageCachePreferences == imagePoint
interfaceIconFrameDimmed == interlace
interfaceIconFrameDimmed == interpolation
interfaceIconFrameDimmed == intersect
interfaceWhite == intersectWith
JPEG == JPEGFormat
lightDirection == lightDirectional
lightOmni == lightenOnly
lightSource == lightSpot
lens == lines
floatType == longFloat
integer == longInteger
magenta == magentas
NTSC == NTSCColors
maximum == maximumQuality
numberOfLayers == numberOfLevels
pencilEraser == pencilWidth
perspective == perspectiveIndex
inherits == pInherits
pluginPicker == pluginPrefs
paint == point
posterization == posterize
generalPreferences == preferencesClass
previewMacThumbnail == previewMagenta
radius == reds
RGBSetup == RGBSetupSource
scratchDisks == screenDot
shadingIntensity == shadowIntensity
sharpen == sharpness
sharpenEdges == shearEd
IEEE32BitFloatingPoint == shortFloat
sInt16 == shortInteger
integer == sInt32
comp == sInt64
IEEE32BitFloatingPoint == sMFloat
sInt16 == sMInt
spot == spotColor
separationSetup == sprayedStrokes
in == stampIn
saturation == start
strokeLength == strokeLocation
splitChannels == supplementalCategories
null == target
char == textType
textClickPoint == textureCoverage
textureFile == textureFill
TIFF == TIFFFormat
toggleOptionsPalette == toggleOthers
transparencyGamutPreferences == transparencyGridSize
transparencyGamutPreferences == transparencyGrid
transferSpec == transparencyShape
transferSpec == transparencyStop
transparency == transparent
magnitude == uInt32
userMaskEnabled == userMaskOptions
Copy link to clipboard
Copied
Some strings are formal, so you can use any other name and the code will still work correctly.