7 Replies Latest reply on Nov 12, 2016 11:37 AM by Sergey Kritskiy

    AM-code executes dreadfully slow

    Sergey Kritskiy Level 1

      Dear everyone,

       

      I have one user, on his machine (Windows10 on a i5 skylake Lenovo Thinkpad Yoga + PS CC14) AM code executes awfully slow.

       

      For example, this takes 0.04s on my old machine and 20s on his

      var ref = new ActionReference();
      ref.putEnumerated(charIDToTypeID("capp"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt"));
      var appDesc = executeActionGet(ref);
      

       

      Does anyone know what could be the reason?

      Thanks,

      Sergey

        • 1. Re: AM-code executes dreadfully slow
          DBarranca Level 4

          Might depend on the number of Fonts he has installed, or stuff like that.

          As a rule (and when possible! which is not always the case) prepend the app descriptor get with the prop you're interested into, so that you're retrieving that only, e.g.

           

          // DO
          var ref = new ActionReference ();
          ref.putProperty (stringIDToTypeID ("property"), stringIDToTypeID ("interpolationMethod"));
          ref.putEnumerated (stringIDToTypeID ("application"), stringIDToTypeID ("ordinal"), stringIDToTypeID ("targetEnum"));
          var interpolationDesc = executeActionGet (ref);
          var theInterpolationMethod = typeIDToStringID (interpolationDesc.getEnumerationValue (stringIDToTypeID ("interpolationMethod")));
          alert (theInterpolationMethod);
          
          // DON'T
          var ref = new ActionReference();
          ref.putEnumerated( charIDToTypeID("capp"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") ); 
          var applicationDesc = executeActionGet(ref);
          var theInterpolationMethod = typeIDToStringID(applicationDesc.getEnumerationValue(stringIDToTypeID('interpolationMethod')));
          alert (theInterpolationMethod);
          

           

          Hope this helps!

           

          Davide

          1 person found this helpful
          • 2. Re: AM-code executes dreadfully slow
            Sergey Kritskiy Level 1

            Thanks Davide!

            I need to get an object

             

                        var ref = new ActionReference();
                        ref.putEnumerated(charIDToTypeID("capp"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt"));
                        var appDesc = executeActionGet(ref);
                        var curToolOpt = appDesc.getObjectValue(stringIDToTypeID('currentToolOptions'));
            

             

            And If I understand correctly, I can't make this faster than getting the whole 'capp' thing

            • 3. Re: AM-code executes dreadfully slow
              SuperMerlin Level 5

              In this case you need to use "tool" to get "currentToolOptions"

               

              var ref = new ActionReference();  
              ref.putProperty (stringIDToTypeID ("property"), stringIDToTypeID ("tool"));
              ref.putEnumerated (stringIDToTypeID ("application"), stringIDToTypeID ("ordinal"), stringIDToTypeID ("targetEnum"));  
              var appDesc = executeActionGet(ref).getObjectValue(stringIDToTypeID("currentToolOptions")); 
              
              
              1 person found this helpful
              • 4. Re: AM-code executes dreadfully slow
                Sergey Kritskiy Level 1

                Thanks, SuperMerlin, exactly what I need!

                May I ask you, how can I find certain property stringID? Like with tool in this example? Because I have some other objects I'm getting from 'capp'

                • 5. Re: AM-code executes dreadfully slow
                  SuperMerlin Level 5

                  Try the one that should work first if not you have to experiment with other values.

                  • 6. Re: AM-code executes dreadfully slow
                    Sergey Kritskiy Level 1

                    I'm sorry I don't think I understood. The one that should work...?

                    • 7. Re: AM-code executes dreadfully slow
                      Sergey Kritskiy Level 1

                      Ah, I got it. Sorry for spam!