Page 1 of 1

How to Get current toolPreset name jsx

Posted: Sat Jan 27, 2018 7:55 pm
by dog
How do I get the name of the active sTID("toolPreset")?

I imagine it’s similar to getting the currently active tool name:

Code: Select all

cTID = function(s) {	return app.charIDToTypeID(s)}
sTID = function(s) { return app.stringIDToTypeID(s)}
function get_tool() {
var ref = new ActionReference()
ref.putEnumerated(cTID("capp"), cTID("Ordn"), cTID("Trgt"))
return typeIDToStringID(executeActionGet(ref).getEnumerationType(sTID('tool')))
}
alert(get_tool())
If the active sTID('tool') name is 'paintbrushTool', the active sTID("toolPreset") name may be something like "Charcoal low flow".

I’ve tinkered and looked around but haven’t made any progress. I'd be grateful for any help.

There was a discussion on this over here: https://forums.adobe.com/message/10048743#10048743 but the answer looks too verbose for what I’m thinking.

In case it’s helpful, here is how I’ll use this name to reset the tool preset at the end of the script (as the actions change it)

Code: Select all

function set_tool_preset(name_obtained_at_start_of_script) {
var desc1 = new ActionDescriptor()
var ref1 = new ActionReference()
ref1.putName(sTID("toolPreset"), name)
desc1.putReference(cTID('null'), ref1)
executeAction(cTID('slct'), desc1, DialogModes.NO)
}
P.S. I don’t mean the brush tip shape name (which is an aspect of a brush tool preset)

Re: How to Get current toolPreset name jsx

Posted: Fri Feb 02, 2018 7:38 am
by txuku
Bonjour

On the forum you have THIS ! :)

Re: How to Get current toolPreset name jsx

Posted: Fri Feb 09, 2018 1:12 pm
by dog
Hi txuku, Thank you for the link! That’s mostly regarding getting / setting the active type of tool (e.g. brush), rather than getting / setting the current preset of the active tool (e.g. charcoal brush) which is what I am interested in.

Re: How to Get current toolPreset name jsx

Posted: Sat Feb 10, 2018 4:43 am
by Kukurykus
You didn't want to use my script from a site you linked in your post then try other approach, however you don't have choise, as that you want to get isn't available for most Brush Presets, otherwise why you think we write a little complex workarounds for you, if the solution could be obvious to do it a way you'd like?

If you want to use it just go to Edit / Preferences / General and fill "History Log" box, tick "Save Log Items To Metadata" radio button, and select "Detailed" from "Edit Log Items" dropdown list. Now each time you select brush preset and run this script it will alert you last one used, even if you already unselected that from Brush Presets List.

Code: Select all

if (documents.length && (prf = preferences).useHistoryLog
&& prf.saveLogItems == SaveLogItemsType.METADATA
&& prf.editLogItems == EditLogItemsType.DETAILED) {
(function(){
with(p = new PhotoshopSaveOptions()) {
annotations = alphaChannels = layers
= embedColorProfile = spotColors = 0
}
activeDocument.saveAs(f = File('~/desktop/.psd'), p, 1)
f.encoding = 'binary', f.open('r'), c = f.read().toSource()
r = / brush \\u00E2\\u0080\\u009.{0,50}(?=\\u00E2)/g
f.close(); if (cBrush = c.match(r)) {b = cBrush[cBrush.length -1]
alert('Current Brush Preset: ' + b.slice(25))} f.remove()
})()
}

Re: How to Get current toolPreset name jsx

Posted: Sat Feb 17, 2018 1:12 pm
by dog
Hi Kukurykus! Sorry for the delay in responding. Thank you very much for your script! This will be great!

Re: How to Get current toolPreset name jsx

Posted: Thu Feb 22, 2018 5:21 pm
by Kukurykus
Posts on this forum are accepted with delay, so I see yours after few days :) I'm glad to know this time you can use it :)