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

how to get list type descriptor value ?

Community Beginner ,
Aug 11, 2023 Aug 11, 2023

Copy link to clipboard

Copied

Mahadi_hasan_0-1691761918215.png


Since we can get key from object using getkey() function,
is there any way to get the value from LISTTYPE descriptor value.

I'm actually trying to get the adjustment layer info.
 https://community.adobe.com/t5/photoshop-ecosystem-discussions/action-manager-scripting/m-p/11160326... .

This the thread where from i got inspired.. but @JazzY-y did not mention anything about LISTTYPE and ENUMERATEDTYPE value.

TOPICS
Actions and scripting , Windows

Views

198
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 ,
Aug 20, 2023 Aug 20, 2023

Copy link to clipboard

Copied

LATEST

Maybe this can help get you started. 

// get keys for type layer’s style;
// based on code by michael l hale;
// 2023, use it at your own risk;
if (app.documents.length > 0) {
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") ); 
var layerDesc = executeActionGet(ref);
var aList = layerDesc.getList(stringIDToTypeID("adjustment"));
var listStuff = evaluateList (aList);
for (var m = 0; m < listStuff.length; m++) {
	checkDesc2 (listStuff[m])
};
var listStuff2 = evaluateList (listStuff[0].getList(stringIDToTypeID("adjustment")))
for (var n = 0; n < listStuff2.length; n++) {
	checkDesc2 (listStuff2[n])
};
};
////// based on code by michael l hale //////
function checkDesc2 (theDesc) {
var c = theDesc.count;
var str = '';
for(var i=0;i<c;i++){ //enumerate descriptor's keys
	str = str + 'Key '+i+' = '+typeIDToStringID(theDesc.getKey(i))+': '+theDesc.getType(theDesc.getKey(i))+'\n'+getValues (theDesc, i)+'\n';
	};
alert("desc\n\n"+str);
};
////// check //////
function getValues (theDesc, theNumber) {
switch (theDesc.getType(theDesc.getKey(theNumber))) {
case DescValueType.ALIASTYPE:
return theDesc.getPath(theDesc.getKey(theNumber));
break;
case DescValueType.BOOLEANTYPE:
return theDesc.getBoolean(theDesc.getKey(theNumber));
break;
case DescValueType.CLASSTYPE:
return theDesc.getClass(theDesc.getKey(theNumber));
break;
case DescValueType.DOUBLETYPE:
return theDesc.getDouble(theDesc.getKey(theNumber));
break;
case DescValueType.ENUMERATEDTYPE:
return (typeIDToStringID(theDesc.getEnumerationValue(theDesc.getKey(theNumber)))+"_"+typeIDToStringID(theDesc.getEnumerationType(theDesc.getKey(theNumber))));
break;
case DescValueType.INTEGERTYPE:
return theDesc.getInteger(theDesc.getKey(theNumber));
break;
case DescValueType.LISTTYPE:
return theDesc.getList(theDesc.getKey(theNumber));
break;
case DescValueType.OBJECTTYPE:
return (theDesc.getObjectValue(theDesc.getKey(theNumber))+"_"+typeIDToStringID(theDesc.getObjectType(theDesc.getKey(theNumber))));
break;
case DescValueType.RAWTYPE:
return theDesc.getReference(theDesc.getData(theNumber));
break;
case DescValueType.REFERENCETYPE:
return theDesc.getReference(theDesc.getKey(theNumber));
break;
case DescValueType.STRINGTYPE:
return theDesc.getString(theDesc.getKey(theNumber));
break;
case DescValueType.UNITDOUBLE:
return (theDesc.getUnitDoubleValue(theDesc.getKey(theNumber))+"_"+typeIDToStringID(theDesc.getUnitDoubleType(theDesc.getKey(theNumber))));
break;
default: 
break;
};
};
////// get list values //////
function evaluateList (aList) {
var listStuff = new Array;
for (var x = 0; x < aList.count; x++) {
var theType = aList.getType(x);
switch (theType) {
case DescValueType.ALIASTYPE:
listStuff.push( aList.getPath(x));
break;
case DescValueType.BOOLEANTYPE:
listStuff.push( aList.getBoolean(x));
break;
case DescValueType.CLASSTYPE:
listStuff.push( aList.getClass(x));
break;
case DescValueType.DOUBLETYPE:
listStuff.push( aList.getDouble(x));
break;
case DescValueType.ENUMERATEDTYPE:
listStuff.push( aList.getEnumerationValue(x));
break;
case DescValueType.INTEGERTYPE:
listStuff.push( aList.getInteger(x));
break;
case DescValueType.LISTTYPE:
listStuff.push( aList.getList(x));
break;
case DescValueType.OBJECTTYPE:
listStuff.push( (aList.getObjectValue(x)));
break;
case DescValueType.RAWTYPE:
listStuff.push( aList.getReference(x));
break;
case DescValueType.REFERENCETYPE:
listStuff.push( aList.getReference(x));
break;
case DescValueType.STRINGTYPE:
listStuff.push( aList.getString(x));
break;
case DescValueType.UNITDOUBLE:
listStuff.push( aList.getUnitDoubleValue(x));
break;
default: 
break;
};
};
return listStuff
};

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