欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

【photoshop Action Manager】动作管理器 - 获取数据

程序员文章站 2022-05-19 15:52:50
...

一、脚本分析

 数据获取,比如获取图层信息用layer

 r1.putEnumerated( s2t("layer"), s2t("ordinal"),s2t("targetEnum") );

 可用枚举:

application(应用)

document(文档)

layer(图层)
 channel(通道)
path(路径)
historyState(历史记录)
snapshotClass(快照)
transform(*变换)
contentLayer(文本图层)
adjustmentLayer(调整图层)

具体信息可以替换进去获取。

/***********************************************************************************
    可用枚举:
 channel
document
historyState
layer
snapshotClass
transform
application
contentLayer
adjustmentLayer
path
******************************************************************************/
var r1 = new ActionReference();
 var d1 = new ActionDescriptor();
 r1.putEnumerated( s2t("layer"), s2t("ordinal"),s2t("targetEnum") );
 d1 = executeActionGet(r1);
 checkDesc(d1);
 
 
/******************函数***************************************************************/
function t2s(t) { return typeIDToStringID(t) }
function s2t(t) { return stringIDToTypeID(t) }
 
 function checkDesc(desc) {
 var c = desc.count,
str = '';
 for (var i = 0; i < c; i++) {
str += 'Key ' + i + ' = ' + t2s(desc.getKey(i)) + ': ' + desc.getType(desc.getKey(i)) + ' = ' + getValues(desc, i) + '\n';
 };
 $.writeln(str);
 alert(str);
 };
 
 function getValues(desc, keyNum) {
var kTypeID = desc.getKey(keyNum);
 switch (desc.getType(kTypeID)) {
 case DescValueType.OBJECTTYPE:
return (desc.getObjectValue(kTypeID) + "_" + t2s(desc.getObjectType(kTypeID)));
 break;
 case DescValueType.LISTTYPE:

 return desc.getList(kTypeID);
 break;
 case DescValueType.REFERENCETYPE:
 return desc.getReference(kTypeID);
 break;
 case DescValueType.BOOLEANTYPE:
return desc.getBoolean(kTypeID);
 break;
 case DescValueType.STRINGTYPE:
 return desc.getString(kTypeID);
 break;
 case DescValueType.INTEGERTYPE:
 return desc.getInteger(kTypeID);
 break;
 case DescValueType.LARGEINTEGERTYPE:
 return desc.getLargeInteger(kTypeID);
 break;
 case DescValueType.DOUBLETYPE:
 return desc.getDouble(kTypeID);
break;
 case DescValueType.ALIASTYPE:
 return desc.getPath(kTypeID);
 break;
 case DescValueType.CLASSTYPE:
 return desc.getClass(kTypeID);
 break;
 case DescValueType.UNITDOUBLE:
 return (desc.getUnitDoubleValue(kTypeID) +"_" + t2s(desc.getUnitDoubleType(kTypeID)));
 break;
 case DescValueType.ENUMERATEDTYPE:
 return (t2s(desc.getEnumerationValue(kTypeID)) +
 "_" + t2s(desc.getEnumerationType(kTypeID)));
 break;
 case DescValueType.RAWTYPE:
 var tempStr = desc.getData(kTypeID);
 var rawData = new Array();
for (var tempi = 0; tempi < tempStr.length; tempi++) {
 rawData[tempi] = tempStr.charCodeAt(tempi);
 }
return rawData;
 break;
default:
 
 break;
};
 };

【photoshop Action Manager】动作管理器 - 获取数据