How to Get current toolPreset name jsx

Anyone, especially newbies, asking for help with Photoshop Scripting and Photoshop Automation - as opposed to those contributing to discussion about an aspect of Photoshop Scripting

Moderators: xbytor, DavideBarranca, Paul MR

dog
Posts: 3
Joined: Sat Jan 27, 2018 6:36 pm

How to Get current toolPreset name jsx

Postby dog » Sat Jan 27, 2018 7:55 pm

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)

User avatar
txuku
Posts: 62
Joined: Thu Jan 01, 1970 12:00 am

Re: How to Get current toolPreset name jsx

Postby txuku » Fri Feb 02, 2018 7:38 am

Bonjour

On the forum you have THIS ! :)

dog
Posts: 3
Joined: Sat Jan 27, 2018 6:36 pm

Re: How to Get current toolPreset name jsx

Postby dog » Fri Feb 09, 2018 1:12 pm

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.

User avatar
Kukurykus
Posts: 156
Joined: Mon Jul 25, 2016 12:36 pm

Re: How to Get current toolPreset name jsx

Postby Kukurykus » Sat Feb 10, 2018 4:43 am

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()
})()
}
Attachments
Brush Preset.rar
(664 Bytes) Downloaded 52 times

dog
Posts: 3
Joined: Sat Jan 27, 2018 6:36 pm

Re: How to Get current toolPreset name jsx

Postby dog » Sat Feb 17, 2018 1:12 pm

Hi Kukurykus! Sorry for the delay in responding. Thank you very much for your script! This will be great!

User avatar
Kukurykus
Posts: 156
Joined: Mon Jul 25, 2016 12:36 pm

Re: How to Get current toolPreset name jsx

Postby Kukurykus » Thu Feb 22, 2018 5:21 pm

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


Return to “Help Me”

Who is online

Users browsing this forum: No registered users and 3 guests