Here's a function that will delete a tool preset by name and do so without selecting the preset.
Code: Select all//usage:
//deleteToolPreset("Air Brush");
function deleteToolPreset(name){
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID("capp"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
var appDesc = executeActionGet(ref);
var pmList = appDesc.getList(stringIDToTypeID("presetManager"));
var nameList = pmList.getObjectValue(7).getList(charIDToTypeID('Nm '));
for (var index = 0; index < nameList.count; index++){
if (nameList.getString(index) == name){
index++;
var idDlt = charIDToTypeID( "Dlt " );
var desc2 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var list1 = new ActionList();
var ref2 = new ActionReference();
var idtoolPreset = stringIDToTypeID( "toolPreset" );
ref2.putIndex( idtoolPreset, index );
list1.putReference( ref2 );
desc2.putList( idnull, list1 );
executeAction( idDlt, desc2, DialogModes.NO );
break;
}
else {}
}
}
Delete Tool Preset by Name
Re: Delete Tool Preset by Name
Hello,
I have tried to implement the code in hostscript.jsx and still does not work. And does getObjectValue(7) is a preset numbered 7th in order, and what if it is 10th, will it still be deleted?
Please help me on this because I am lost.
By the way I know it is old post, but it's worth to be here, especially if someone answers my question.
Thanks
I have tried to implement the code in hostscript.jsx and still does not work. And does getObjectValue(7) is a preset numbered 7th in order, and what if it is 10th, will it still be deleted?
Please help me on this because I am lost.
By the way I know it is old post, but it's worth to be here, especially if someone answers my question.
Thanks
Re: Delete Tool Preset by Name
Bonjour
You create a new predefined form and copy its name
You paste this name into the script
Line 2
And an alert line 14
That works well !
You create a new predefined form and copy its name
You paste this name into the script
Line 2
Code: Select all
DeleteToolPreset ("Brush tool test0 2") // "test0") // "Air Brush");
And an alert line 14
Code: Select all
alert (index)
Re: Delete Tool Preset by Name
Hi txuku,
Thanks for your answer, is this what you mean?
P.S. I placed dashes in the code where I made changes according to your answer so you can easily find them:
Thanks for your answer, is this what you mean?
P.S. I placed dashes in the code where I made changes according to your answer so you can easily find them:
Code: Select all
//usage:
deleteToolPreset("MyBrush"); ------
function deleteToolPreset(name){
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID("capp"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
var appDesc = executeActionGet(ref);
var pmList = appDesc.getList(stringIDToTypeID("presetManager"));
var nameList = pmList.getObjectValue(7).getList(charIDToTypeID('Nm '));
for (var index = 0; index < nameList.count; index++){
if (nameList.getString(index) == name){
alert(index); ----------
var idDlt = charIDToTypeID( "Dlt " );
var desc2 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var list1 = new ActionList();
var ref2 = new ActionReference();
var idtoolPreset = stringIDToTypeID( "toolPreset" );
ref2.putIndex( idtoolPreset, index );
list1.putReference( ref2 );
desc2.putList( idnull, list1 );
executeAction( idDlt, desc2, DialogModes.NO );
break;
}
else {}
}
}
Re: Delete Tool Preset by Name
Bonjour
I remove the new forms I have created by means of this function !
Is not that your case?
I remove the new forms I have created by means of this function !
Is not that your case?

Re: Delete Tool Preset by Name
Hi txuku,txuku wrote:Bonjour
I remove the new forms I have created by means of this function !
Is not that your case?
I am totally lost now, please if you feel like editing the above code so I can understand exactly what you mean.
Thank you
Re: Delete Tool Preset by Name
Bonjour
What is the name of the new forms you create in English ?
What is the name of the new forms you create in English ?
Re: Delete Tool Preset by Name
Hi,
I actually messed something up in main.js and corrected the problem, actually the solution is to uncomment line 2 and everything is working fine now. Thanks again txuku, you helped me alot as I really understand now what you wanted to tell me all the time. My apollogies.
I actually messed something up in main.js and corrected the problem, actually the solution is to uncomment line 2 and everything is working fine now. Thanks again txuku, you helped me alot as I really understand now what you wanted to tell me all the time. My apollogies.