从多层应用的斜角和浮雕效果中获取值?

时间:2019-07-07 14:43:53

标签: javascript photoshop photoshop-script

我在下面创建了此功能,以从应用的斜角和浮雕效果获取一些值,例如阴影角阴影高度

Deploy canceled

我现在想做的是做同样的事情,但要多层。就像下面的这个功能一样处理图层的颜色。我尝试了几件事,但是我的知识水平没有帮助。有想法吗?

alert("Angle: " + getBevelAndEmbossValues()[0] + "\nAltitude: " + getBevelAndEmbossValues()[1]);  

function getBevelAndEmbossValues()  
{    
    try  
    {    
        var ref = new ActionReference();    
        ref.putEnumerated( charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );     
        var desc = executeActionGet(ref).getObjectValue(stringIDToTypeID('layerEffects')).getObjectValue(stringIDToTypeID('bevelEmboss'));    
        return [desc.getUnitDoubleValue(stringIDToTypeID('localLightingAngle')),  
                desc.getUnitDoubleValue(stringIDToTypeID('localLightingAltitude'))];  
    }  
    catch(e)  
    {  
        alert(e);  
    }    
};

1 个答案:

答案 0 :(得分:0)

好吧,我终于设法解决了!!这是我的解决方案...如果有人有更好的选择...

var layers = getLayersData();
alert (layers.length + ' layers found!!!' ,  'Message');

function getLayersData()
{
    var lyrs = [];
    var layers = 1;
    while (true)
    {
        ref = new ActionReference();
        ref.putIndex(charIDToTypeID('Lyr '), layers);

        try{var desc = executeActionGet(ref);}catch (err){break;};

        var lyr = {};
        lyr.type = desc.getInteger(stringIDToTypeID("layerKind"));
        lyr.name = desc.getString(charIDToTypeID("Nm  "));
        lyr.id = desc.getInteger(stringIDToTypeID("layerID"));

        if (lyr.type == '4')
        {                            
            ref.putEnumerated( charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
            if(desc.hasKey(stringIDToTypeID('layerEffects')))
            {
                if(desc.getBoolean (stringIDToTypeID('layerFXVisible')))
                {
                    desc = desc.getObjectValue(stringIDToTypeID('layerEffects'));
                    if(desc.hasKey(stringIDToTypeID('bevelEmboss')))
                    {
                        desc = desc.getObjectValue(stringIDToTypeID('bevelEmboss'));
                        if(desc.hasKey(stringIDToTypeID('localLightingAngle')))
                        {
                            var BevelAndEmbossAngle = desc.getUnitDoubleValue(stringIDToTypeID('localLightingAngle'));
                            if(BevelAndEmbossAngle == '90')
                            {
                                lyrs.push(lyr);
                            }
                        }
                    }
                }
            }

        };
        layers++;            
    };
    return lyrs;
};