Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
I assume that this and some commands from the properties bar of some tools are not accessed by scripts.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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.
I came across the same issue when I was trying to do some scripting with patterns, and wanted to add a list of them.
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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;
};
Copy link to clipboard
Copied
Thank you Chuck Uebele once again for the tip, I think it's a little bit to finish.
Hi SuperMerlin I changed this excerpt:
- 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;
- }
That is why!
- 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;
- };
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?
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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();
}
Copy link to clipboard
Copied
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();
}
Copy link to clipboard
Copied
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
Find more inspiration, events, and resources on the new Adobe Community
Explore Now