• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
1

How to remove loaded brushes?

Participant ,
Nov 25, 2021 Nov 25, 2021

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)

 

TOPICS
Actions and scripting

Views

497

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 2 Correct answers

LEGEND , Nov 25, 2021 Nov 25, 2021
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)
}

Votes

Translate

Translate
LEGEND , Nov 25, 2021 Nov 25, 2021

Thanks to r-binSelect/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
...

Votes

Translate

Translate
Adobe
LEGEND ,
Nov 25, 2021 Nov 25, 2021

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)
}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Nov 25, 2021 Nov 25, 2021

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.

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 25, 2021 Nov 25, 2021

Copy link to clipboard

Copied

Thanks to r-binSelect/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))

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Nov 29, 2021 Nov 29, 2021

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Nov 29, 2021 Nov 29, 2021

Copy link to clipboard

Copied

I never paid attention before, but:

sTT('brushes') ==sTT('brush')

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 29, 2021 Nov 29, 2021

Copy link to clipboard

Copied

So like 'grain' & 'green' or 'paint' & 'point'.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Nov 29, 2021 Nov 29, 2021

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

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 29, 2021 Nov 29, 2021

Copy link to clipboard

Copied

LATEST

Some strings are formal, so you can use any other name and the code will still work correctly.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines