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

Show custom shape panel!

Contributor ,
Nov 08, 2017 Nov 08, 2017

Hello Friend!

Is it possible to write a script that shows the panel so that it stays in the "Custom Shape Tool (U)" property bar? Unfortunately I could not do this with the ScriptingListener.

Screenshot_1.jpg

TOPICS
Actions and scripting
1.5K
Translate
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
Engaged ,
Nov 09, 2017 Nov 09, 2017

I assume that this and some commands from the properties bar of some tools are not accessed by scripts.

Translate
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
Community Expert ,
Nov 09, 2017 Nov 09, 2017

You are correct. There are a lot of things in PS that can't be accessed by scripting. Only workaround, that I can think of is to create your own UI or an extension panel with all the controls in it.

Translate
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
Contributor ,
Nov 10, 2017 Nov 10, 2017

https://forums.adobe.com/people/Chuck+Uebele  escreveu

You are correct. There are a lot of things in PS that can't be accessed by scripting. Only workaround, that I can think of is to create your own UI or an extension panel with all the controls in it.

Your workaround to create my own UI is great Chuck Uebele My biggest difficulty would be to have to manually add all the shapes whenever I add new shapes, cool would be if there was any way to do this automatically with thumbnail or a dropdownlist?

Translate
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
Community Expert ,
Nov 10, 2017 Nov 10, 2017

Yes, that would be a pain. You can try and check out xtools, as X has come up with scripts to access the preset manager, but I think it might only be the name, and not a visual icon for the shape.

xtools

I came across the same issue when I was trying to do some scripting with patterns, and wanted to add a list of them.

Translate
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
Contributor ,
Nov 10, 2017 Nov 10, 2017

Thanks to your help, I believe this is on the right track.

I checked the xtools page here, but I need to know which of the scripts in this collection

you may be able to access the Preset Manager.

I did a search here in the forum related to Preset Manager and found here something that is related to the clue you gave me.

#target photoshop;

function getToolPresetNames() {

     var ref = new ActionReference();   

    ref.putEnumerated( charIDToTypeID("capp"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );   

    var appDesc = executeActionGet(ref);   

    var List = appDesc.getList(stringIDToTypeID('presetManager'));  

    var presetNames=[];  

    var list = List.getObjectValue(7).getList(charIDToTypeID('Nm  '));

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

            var str = list.getString(i);

            presetNames.push(str); }

    return presetNames;

}

function select_preset(name)

    {

    try {

        var desc = new ActionDescriptor();

        var ref = new ActionReference();

        ref.putName( stringIDToTypeID( "toolPreset" ), name );

        desc.putReference( charIDToTypeID( "null" ), ref );

        executeAction( charIDToTypeID( "slct" ), desc, DialogModes.NO );

        ref = null;

        desc = null;

        }

    catch(e) { }

    }

picked = type_ahead ();

function type_ahead () {

    tools = getToolPresetNames();

    var w = new Window ('dialog {text: "preset selector", alignChildren: "fill"}');

    var entry = w.add ('edittext {active: true}');

    var list = w.add ('listbox', [0, 0, 190, 250], tools);

    list.selection = 0;

    entry.onChanging = function () {

                     var temp = this.text;

                     list.removeAll ();

                     for (var i = 0; i < tools.length; i++) {

                                 if (tools.toLowerCase().indexOf (temp) == 0) {

                                                        list.add ('item', tools);

                                                }

                     }

    }

    list.onChange = function () { select_preset( list.selection.text ); w.close(); }

    if (list.items.length > 0){

            list.selection = 0;

    }

    w.add ('button', undefined, 'Ok', {name: 'ok'});

    if (w.show () != 2){

    select_preset( list.selection.text )

    }

    w.close();

}

I believe that if u understand how to get the Default Manager, with the help of a friend here with more wisdom in Photoshop Scripting, you can try to fit this secript sub-replacing tools with Custon Shapes.

How to proceed?

Translate
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
Community Expert ,
Nov 10, 2017 Nov 10, 2017

I'm not familiar with with using xTools. xbytor2​ sometimes still looks at these forums. Perhaps he can shed some light on what you want to do.

Translate
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
Guide ,
Nov 10, 2017 Nov 10, 2017

Here is an example of getting the list.

alert(getCustomShapeList().join("\n"));

function getCustomShapeList(){

var desc, shapeList, ref, Names;

ref = new ActionReference();

ref.putProperty( charIDToTypeID("Prpr"), stringIDToTypeID("presetManager") );

ref.putEnumerated( charIDToTypeID("capp"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );

desc = executeActionGet(ref);

shapeList = desc.getList(stringIDToTypeID("presetManager")).getObjectValue(6).getList(charIDToTypeID("Nm  ")); 

Names = new Array();

for (var z = 1; z<shapeList.count;z++){

try{

Names.push(shapeList.getString(z));

}catch(e){alert(e);return;}

}

return Names;

};

Translate
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
Contributor ,
Nov 10, 2017 Nov 10, 2017

Thank you Chuck Uebele once again for the tip, I think it's a little bit to finish.

Hi SuperMerlin I changed this excerpt:

  1. function getToolPresetNames() { 
  2.      var ref = new ActionReference();     
  3.     ref.putEnumerated( charIDToTypeID("capp"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );     
  4.     var appDesc = executeActionGet(ref);     
  5.     var List = appDesc.getList(stringIDToTypeID('presetManager'));    
  6.     var presetNames=[];    
  7.     var list = List.getObjectValue(7).getList(charIDToTypeID('Nm  ')); 
  8.     for (var i = 0; i < list.count; i++) {    
  9.             var str = list.getString(i); 
  10.             presetNames.push(str); } 
  11.     return presetNames; 
  12. }

That is why!

  1. function getCustomShapeList(){ 
  2. var desc, shapeList, ref, Names; 
  3. ref = new ActionReference(); 
  4. ref.putProperty( charIDToTypeID("Prpr"), stringIDToTypeID("presetManager") ); 
  5. ref.putEnumerated( charIDToTypeID("capp"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );  
  6. desc = executeActionGet(ref); 
  7. shapeList = desc.getList(stringIDToTypeID("presetManager")).getObjectValue(6).getList(charIDToTypeID("Nm  "));   
  8. Names = new Array(); 
  9. for (var z = 1; z<shapeList.count;z++){ 
  10. try
  11. Names.push(shapeList.getString(z)); 
  12. }catch(e){alert(e);return;} 
  13. return Names; 
  14. }; 

This added the Shapes list to the project but nothing happens when I select any item from the list. What would be missing and how did you get access to the managed Shapes?

Translate
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
Guide ,
Nov 10, 2017 Nov 10, 2017

The access to the preset manager only gets you a readonly list.

getObjectValue(Number)

///////////////////////////// presetManager

// 0: Brushes

// 1: Swatches

// 2: Gradients

// 3: Styles

// 4: Patterns

// 5: Contours

// 6: Custom Shapes

// 7: Tools

You might be able to create presets to the ones you want? but not directly

Translate
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
Contributor ,
Nov 10, 2017 Nov 10, 2017

Hi super SuperMerlin I get it, maybe you did not understand me.

I was able to add your script to my project. It added the list with all the existing forms in my user interface, however I did not get in practice to do the same work while selecting any way through the list.

If you test this script, you will see that all existing forms have appeared in the Interface list and if you select any item, you will notice that it did not happen ie the form does not change. Could you test?

#target photoshop; 

/////Written by SuperMerlin!

function getCustomShapeList(){ 

var desc, shapeList, ref, Names; 

ref = new ActionReference(); 

ref.putProperty( charIDToTypeID("Prpr"), stringIDToTypeID("presetManager") ); 

ref.putEnumerated( charIDToTypeID("capp"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );  

desc = executeActionGet(ref); 

shapeList = desc.getList(stringIDToTypeID("presetManager")).getObjectValue(6).getList(charIDToTypeID("Nm  "));   

Names = new Array(); 

for (var z = 1; z<shapeList.count;z++){ 

try{ 

Names.push(shapeList.getString(z)); 

}catch(e){alert(e);return;} 

return Names; 

};

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

 

function select_preset(name) 

    { 

    try { 

        var desc = new ActionDescriptor(); 

        var ref = new ActionReference(); 

        ref.putName( stringIDToTypeID( "toolPreset" ), name ); 

        desc.putReference( charIDToTypeID( "null" ), ref ); 

        executeAction( charIDToTypeID( "slct" ), desc, DialogModes.NO ); 

        ref = null; 

        desc = null; 

        } 

    catch(e) { } 

    } 

 

 

picked = type_ahead (); 

 

function type_ahead () { 

    tools = getCustomShapeList(); 

    var w = new Window ('dialog {text: "preset selector", alignChildren: "fill"}'); 

    var entry = w.add ('edittext {active: true}'); 

    var list = w.add ('listbox', [0, 0, 190, 250], tools); 

    list.selection = 0; 

    entry.onChanging = function () { 

                     var temp = this.text; 

                     list.removeAll (); 

                     for (var i = 0; i < tools.length; i++) { 

                                 if (tools.toLowerCase().indexOf (temp) == 0) { 

                                                        list.add ('item', tools); 

                                                } 

                     } 

 

 

    } 

 

 

    list.onChange = function () { select_preset( list.selection.text ); w.close(); } 

 

 

    if (list.items.length > 0){ 

            list.selection = 0; 

    } 

    w.add ('button', undefined, 'Ok', {name: 'ok'}); 

 

 

    if (w.show () != 2){ 

    select_preset( list.selection.text ) 

    } 

    w.close(); 

}

Translate
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
Guide ,
Nov 11, 2017 Nov 11, 2017

That is because you are trying to select a tool preset, and that will not work, here I have the function just to return.

#target photoshop; 

function getCustomShapeList(){

var desc, shapeList, ref, Names;

ref = new ActionReference();

ref.putProperty( charIDToTypeID("Prpr"), stringIDToTypeID("presetManager") );

ref.putEnumerated( charIDToTypeID("capp"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );

desc = executeActionGet(ref);

shapeList = desc.getList(stringIDToTypeID("presetManager")).getObjectValue(6).getList(charIDToTypeID("Nm  ")); 

Names = new Array();

for (var z = 1; z<shapeList.count;z++){

try{

Names.push(shapeList.getString(z));

}catch(e){alert(e);return;}

}

return Names;

};

     

     

function select_preset(name) 

        { 

            return;

            //this function will not work with shapes !

        try { 

            var desc = new ActionDescriptor(); 

            var ref = new ActionReference(); 

            ref.putName( stringIDToTypeID( "toolPreset" ), name ); 

            desc.putReference( charIDToTypeID( "null" ), ref ); 

            executeAction( charIDToTypeID( "slct" ), desc, DialogModes.NO ); 

            ref = null; 

            desc = null; 

            } 

        catch(e) { } 

        } 

    picked = type_ahead (); 

    function type_ahead () { 

        tools = getCustomShapeList(); 

        var w = new Window ('dialog {text: "preset selector", alignChildren: "fill"}'); 

        var entry = w.add ('edittext {active: true}'); 

        var list = w.add ('listbox', [0, 0, 190, 250], tools); 

        list.selection = 0; 

        entry.onChanging = function () { 

                         var temp = this.text; 

                         list.removeAll (); 

                         for (var i = 0; i < tools.length; i++) { 

                                     if (tools.toLowerCase().indexOf (temp) == 0) { 

                                                            list.add ('item', tools); 

                                  } 

                         } 

        } 

        list.onChange = function () { select_preset( list.selection.text ); w.close(); } 

        if (list.items.length > 0){ 

                list.selection = 0; 

        } 

        w.add ('button', undefined, 'Ok', {name: 'ok'});    

        if (w.show () != 2){ 

        select_preset( list.selection.text ) 

        } 

        w.close(); 

    } 

Translate
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
Contributor ,
Nov 11, 2017 Nov 11, 2017
LATEST

I understood, unfortunately it will not work with forms! This is frustrating! Here I close this post

Thank you for trying to help me SuperMerlin

Translate
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