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

Scripting , how to get swatch group names?

Explorer ,
Jan 10, 2022 Jan 10, 2022

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.

TOPICS
Windows

Views

331
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 ,
Jan 10, 2022 Jan 10, 2022

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

 

 

Votes

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
Explorer ,
Jan 10, 2022 Jan 10, 2022

Copy link to clipboard

Copied

LATEST

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)

 

 

Votes

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