3 Replies Latest reply on Feb 18, 2015 12:25 AM by c.pfaffenbichler

    Is there a way to get all properties of layer with layerkind(text or solidfill)?

    dhavalmashruwala

      how to get the all the properties related to particular layer kind. like if layer kind is TEXT then it should give object returning font size , font text style, font color, co-ordinates,etc and if layerkind is SOLIDFILL it should return object having background color, opacity ??

        • 1. Re: Is there a way to get all properties of layer with layerkind(text or solidfill)?
          c.pfaffenbichler Level 9
          if layerkind is SOLIDFILL it should return object having background color

          Why "background color"?

           

          AM or DOM?

          • 2. Re: Is there a way to get all properties of layer with layerkind(text or solidfill)?
            dhavalmashruwala Level 1

            i mean color of layer and all related properties.

             

            both AM or DOM will do.

             

            DOM preferable.

            • 3. Re: Is there a way to get all properties of layer with layerkind(text or solidfill)?
              c.pfaffenbichler Level 9

              DOM preferable.

              Tthen I suppose you may have to create a lot of if- or try-clauses.

               

              With AM code it should be easier (and faster).

              This could serve as an example – for every ActionDescriptor that turns up you could apply the function again.

              // based on code by michael l hale;
              // 2015, use it at your own risk;
              #target "photoshop-70.032"
              if (app.documents.length > 0) {
              var ref = new ActionReference();
              ref.putEnumerated( charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
              var layerDesc = executeActionGet(ref);
              checkDesc2 (layerDesc);
              if (layerDesc.hasKey(stringIDToTypeID("textKey")) == true) {
              checkDesc2 (layerDesc.getObjectValue(stringIDToTypeID("textKey")))
              }
              };
              //////
              ////// 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.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.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;
              };
              };