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

how to get brush name?

Engaged ,
Feb 18, 2019 Feb 18, 2019

Copy link to clipboard

Copied

i had been getting the name of  part of the brush.but some of brush name unable to get.the code as fallow:

var param = get_brush_param(); 

// examples 

// show all (almost all) brush props 

 

alert(obj_to_str(param), "currentTool options"); 

function obj_to_str(obj){var str = ""; for (var p in obj) if(obj.hasOwnProperty(p))try{str+=p+"::"+obj

+"\n";}catch(e){};

      logInfo( str);

    return str;} 

 

 

////////////////////////////////////////////////////////////////// 

function get_brush_param() 

    { 

    try { 

        var r = new ActionReference(); 

        r.putProperty(stringIDToTypeID("property"), stringIDToTypeID("tool")); 

        r.putEnumerated(stringIDToTypeID("application"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum")); 

 

        var d = executeActionGet(r); 

 

        var options = d.getObjectValue(stringIDToTypeID("currentToolOptions"));   

 

        var ret = new Object(); 

 

   //  try { var brush = options.getObjectValue(charIDToTypeID("CrpO")); } catch(e) { alert("Current tool not brush!"); return ret; }  

     try { var brush = options.getObjectValue(stringIDToTypeID("brush")); } catch(e) { alert("Current tool not brush!"); return ret; }  

 

  // alert( options.count);

  //  alert( brush.count);

     

 

        for (var i = 0; i < brush.count; i++) 

            { 

            var key = brush.getKey(i); 

            var type = brush.getType(key); 

 

            var val = undefined; 

 

            switch (type)  

                { 

                case DescValueType.BOOLEANTYPE:    val = brush.getBoolean(key); break; 

                case DescValueType.DOUBLETYPE:     val = brush.getDouble(key);  break;   

                case DescValueType.INTEGERTYPE:    val = brush.getInteger(key); break; 

                case DescValueType.ENUMERATEDTYPE: val = typeIDToStringID(brush.getEnumerationValue(key)); break; 

                case DescValueType.UNITDOUBLE:     val = brush.getUnitDoubleValue(key); break; // not quite right 

                  case DescValueType.STRINGTYPE: val = brush.getString(key); break;  

              //  case DescValueType.REFERENCETYPE: val = getReference(brush.getReference(key)); break;  

                default: val =  brush.getType(key).toString();

                } 

             

            if (val != undefined)  

                { 

                var name = typeIDToStringID(key); 

                if (!name) name = typeIDToCharID(key); 

 

                if (typeof(val) == "string") 

                    eval("ret." + name +"='"+val+"'");  

                else 

                    eval("ret." + name +"="+val);  

                } 

            }                 

 

        return ret; 

        } 

    catch (e) { alert(e); } 

    } 

function logInfo(Txt){ 

var file = new File(Folder.desktop + "/too_brush1.txt"); 

file.open("w", "TEXT", "????"); 

file.seek(0,2); 

$.os.search(/windows/i)  != -1 ? file.lineFeed = 'windows'  : file.lineFeed = 'macintosh'; 

file.writeln(Txt); 

file.close(); 

}; 

this is successful.

QQ截图20190219103505.png

this is fail,i can't get the name.

QQ截图20190219101828.pngQQ图片20190219104336.png

TOPICS
Actions and scripting

Views

1.2K

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
Adobe
Community Expert ,
Feb 18, 2019 Feb 18, 2019

Copy link to clipboard

Copied

There are different types of Brushes your code seem to handle normal brushed with tound tips.  There are also sample tipped brushes, Mixer Brushes and special bush types.  In other words you code does not have support  for all posible Photosop brush types. There are also Many bursh type tools in Photoshop.

Different brush type have different attributes

JJMack

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
Engaged ,
Feb 18, 2019 Feb 18, 2019

Copy link to clipboard

Copied

each preset brushes has a name,so  could we get the name?

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
Engaged ,
Feb 18, 2019 Feb 18, 2019

Copy link to clipboard

Copied

r-bin

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
People's Champ ,
Feb 19, 2019 Feb 19, 2019

Copy link to clipboard

Copied

It turns out that not all brushes have a property "name".

I do not know how to solve this problem. Maybe later I'll see what can be done.

In this thread Select/refer to brushes by name within brush sets by name

there is an attempt to find out the name of the brush.

See functions alert_curr_brush() and alert_curr_brush_v2().

But for you, most likely, it will not work.

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
Engaged ,
Feb 19, 2019 Feb 19, 2019

Copy link to clipboard

Copied

Thank you so much in advance and have a nice day.

is this a method that Getting the current preset brushes?

https://forums.adobe.com/message/10046190#10046190

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
Engaged ,
Feb 19, 2019 Feb 19, 2019

Copy link to clipboard

Copied

the example you offer  try to  running  in CC2017 is fail,but CC2019 is ok,

Is there a way to run CC2017?

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
People's Champ ,
Feb 21, 2019 Feb 21, 2019

Copy link to clipboard

Copied

LATEST

I have not yet found how to find the name of the current brush.
But I found another bug (feature, crap) of Photoshop (CS6 and CC2018 at least)
Rename your brush, which supposedly has the name "Spatter 14 pixels" into another one and try to run the script on the definition of the brush::name property. You will be disappointed

PS. What script are you talking about that works in 2018 and does not work in 2017?

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