Skip to main content
Inspiring
November 25, 2021
Answered

How to remove loaded brushes?

  • November 25, 2021
  • 1 reply
  • 1427 views

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)

 

This topic has been closed for replies.
Correct answer Kukurykus

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

 

1 reply

Kukurykus
Legend
November 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)
}
Marvin01Author
Inspiring
November 25, 2021

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.

 

Kukurykus
KukurykusCorrect answer
Legend
November 26, 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(sTT('delete'), dsc))