I am making a Photoshop script which gets every layer with Bevel and Emboss effect and then doing some actions. I have make this function so to get layers data...

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

            var d1 = executeActionGet(ref);  
            var d2 = executeActionGet(ref);  
            var d3 = executeActionGet(ref);  
            var d4 = executeActionGet(ref);  
            catch (err)  

        var c2t = function (s){return app.charIDToTypeID(s);};  
        var s2t = function (s){return app.stringIDToTypeID(s);};  
        var lyr = {};  

        lyr.type = d1.getInteger(s2t("layerKind"));  
        lyr.name = d1.getString(c2t("Nm  "));  
        lyr.id = d1.getInteger(s2t("layerID"));  

        if (checkbox1.value == true)  
            ref.putEnumerated( c2t("Lyr "), c2t("Ordn"), c2t("Trgt") );  
            if (d1.hasKey(s2t('layerEffects')))  
                d1 = d1.getObjectValue(s2t('layerEffects'));  
                lyr.scale = d1.getUnitDoubleValue(s2t('scale'));  

                if (d1.hasKey(s2t('bevelEmboss')))  
                    d1 = d1.getObjectValue(s2t('bevelEmboss'));  
                        lyr.enabled = d1.getBoolean(s2t('enabled'));  
                        lyr.present = d1.getBoolean(s2t('present'));  
                        lyr.showInDialog = d1.getBoolean(s2t('showInDialog'));  
                        lyr.highlightMode = typeIDToStringID(d1.getEnumerationValue(s2t('highlightMode')));  
                    d2 = d1.getObjectValue(s2t('highlightColor'));  
                        lyr.red_hlc = d2.getDouble(s2t('red'));  
                        lyr.grn_hlc = d2.getDouble(s2t('green'));  
                        lyr.blue_hlc = d2.getDouble(s2t('blue'));  
                        lyr.highlightOpacity = d1.getUnitDoubleValue(s2t('highlightOpacity'));  
                        lyr.shadowMode = typeIDToStringID(d1.getEnumerationValue(s2t('shadowMode')))  
                    d3 = d1.getObjectValue(s2t('shadowColor'));  
                        lyr.red_sdc = d3.getDouble(s2t('red'));  
                        lyr.grn_sdc = d3.getDouble(s2t('green'));  
                        lyr.blue_sdc = d3.getDouble(s2t('blue'));  
                        lyr.shadowOpacity = d1.getUnitDoubleValue(s2t('shadowOpacity'));  
                        lyr.bevelTechnique = typeIDToStringID(d1.getEnumerationValue(s2t('bevelTechnique')));  
                        lyr.bevelStyle = typeIDToStringID(d1.getEnumerationValue(s2t('bevelStyle')));  
                        lyr.useGlobalAngle = d1.getBoolean(s2t('useGlobalAngle'));  
                        lyr.localLightingAngle = d1.getUnitDoubleValue(s2t('localLightingAngle'));  
                        lyr.localLightingAltitude = d1.getUnitDoubleValue(s2t('localLightingAltitude'));  
                        lyr.strengthRatio = d1.getUnitDoubleValue(s2t('strengthRatio'));  
                        lyr.blur = d1.getUnitDoubleValue(s2t('blur'));  
                        lyr.bevelDirection = typeIDToStringID(d1.getEnumerationValue(s2t('bevelDirection')));  
                    d4 = d1.getObjectValue(c2t('TrnS'));  
                        lyr.TrnSName = d4.getString(s2t('name'));  
                        lyr.antialiasGloss = d1.getBoolean(s2t('antialiasGloss'));  
                        lyr.softness = d1.getUnitDoubleValue(s2t('softness'));  
                        lyr.useShape = d1.getBoolean(s2t('useShape'));  
                        lyr.useTexture = d1.getBoolean(s2t('useTexture'));  
    return lyrs;  

...and then this function so to list those layers into a Dropdownlist.

function onChangeDropdownlist1()  
    var layerData = getLayersData();  
    var layerNames=[];  
    for(var a in layerData){if(layerData[a].type == dropdownlist1.selection.index){layerNames.push(layerData[a].name);};};  
    if (checkbox2.value == true){layerNames = UniqueSortedList(layerNames);};  
    for(var z in layerNames){dropdownlist2.add("item", layerNames[z]);};  
    dropdownlist2.selection = 0;  
    if (dropdownlist2.selection == null){edittext1.text = "";};  

What I am trying to do now, is to add the ability to get this list but in relation to the group name!!! Any idea how can I do this?

  • you can use app.activeDocument.layerSets.getByName("GroupName")! – Mr.Online Aug 9 '19 at 8:19
  • @DesignPhoenix and how can this apply into my code? :( – Simonetos The Greek Aug 10 '19 at 5:40
  • as far as I can understand your code successfully grab the layers with bevel right and you want to push the group of the layer with bevel right? if it's so than just use that above line which will find the group with specific name and then you can get child by ...layerSets.layers which will give you child layer. well I'm unclear on question though :( – Mr.Online Aug 12 '19 at 11:50
  • @DesignPhoenix my code as it is now, "finds" every layer which have bevel and emboss effect and then gets effect's values. What I want to do is to find every layers which have bevel and emboss effect etc but into a specific group folder!!! In other words, I am looking for a way to get every layers parent group... – Simonetos The Greek Aug 14 '19 at 8:41
  • 1
    you got it wrong bro XD if you want to push the groups then dont do lyrs.push(lyr); rather than that just create a new array from start like var grps = []; and then before pushing lyr you can push the parent by grps.push(lyr.parent); and then you'll have to loop only in grps; read more details on groups by searching LayerSet in official reference :) – Mr.Online Aug 16 '19 at 3:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.