Copy link to clipboard
Copied
Hi, everyone.Hope you have a fantastic days.
In advance ,I'm still not so familiar speaking in English .
Sorry if i made some stupid mistake.
I have a question.
I'm trying coding some script to get swatch list and export to a text file .
this is for using for other project.
By googling, I could find how to get swatch names.
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID("capp"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
var desc = executeActionGet(ref);// get the app descriptor
var presetsList = desc.getList(stringIDToTypeID('presetManager'));// the presets list
var swatchDesc = presetsList.getObjectValue(1);// swatches is the second key
var nameList = swatchDesc.getList(charIDToTypeID("Nm "));// there is only one key in the swatch descriptor so get the list
var nameOfFirstSwatch = nameList.getString(0);// all the name list keys are strings data types so get the first swatch name
var nList = new Array();
for (var i=0;i<nameList.count;i++){
nList.push(nameList.getString(i)+"\n")
}
alert(nList)
But unfortunately this method couldn't get swatch "group" names.
Does any one knows how to get all swatch index?
By the way ,I'm using photoshop2022.
thanks all.
Copy link to clipboard
Copied
I couldn't get your code to work for swatch names.
Looking at the code that is generated when a new swatch group is created, I believe that you are looking for "swatchFolderClass"
var idmake = stringIDToTypeID( "make" );
var desc1530 = new ActionDescriptor();
var idnull = stringIDToTypeID( "null" );
var ref549 = new ActionReference();
var idswatchFolderClass = stringIDToTypeID( "swatchFolderClass" );
ref549.putClass( idswatchFolderClass );
desc1530.putReference( idnull, ref549 );
var idname = stringIDToTypeID( "name" );
desc1530.putString( idname, """myTest""" );
executeAction( idmake, desc1530, DialogModes.NO );
Copy link to clipboard
Copied
Thank you for reply.
Sorry I made some mistake at 6th line. They needed one more space for 4 characters ID
("Nm ")→("Nm ")
And also, I was looking for exactly this class "swatchFolderClass"
but I couldn't figure out how to use.
Couldn't find any Information in internet too..
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID("capp"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
var desc = executeActionGet(ref);// get the app descriptor
var presetsList = desc.getList(stringIDToTypeID('presetManager'));// the presets list
var swatchDesc = presetsList.getObjectValue(1);// swatches is the second key
var nameList = swatchDesc.getList(charIDToTypeID("Nm "));// there is only one key in the swatch descriptor so get the list
var nameOfFirstSwatch = nameList.getString(0);// all the name list keys are strings data types so get the first swatch name
var nList = new Array();
for (var i=0;i<nameList.count;i++){
nList.push(nameList.getString(i)+"\n")
}
alert(nList)