8 Replies Latest reply on Nov 22, 2012 9:07 AM by Michael L Hale

    lensBlur

    Ghoulfool Level 1

      Is CS2 why does the following line not work and instead produces error 1242, illegal argument 1 (which is DepthMapSource.NONE)

       

      activeDocument.activeLayer.applyLensBlur(DepthMapSource.NONE, 0, false, Geometry.HEXAGON, 8, 0, 0, 0, 0, 0, NoiseDistribution.UNIFORM, false);
      

       

      Any ideas?

        • 1. Re: lensBlur
          c.pfaffenbichler Level 9

          I don’t have CS2 on this machine, so testing it for that version is not an option for me.

          But have you tried creating the appropriate Action Manager code with the ScriptingListener plug-in and wrapping that in a function?

          That’s usually faster than DOM-code anyway.

          1 person found this helpful
          • 2. Re: lensBlur
            JJMack Most Valuable Participant

            Reading javascript CS2 PS guide it looks like it should be something like this.

             

            var Lb = new LensBlurOptions;

            Lb.amount = 0;

            Lb.bladeCurvature = 0;

            Lb.brightness = 0;

            Lb.distribution = NoiseDistribution.UNIFORM;

            Lb.focalDistance = 0;

            Lb.invertDepthMap = false;

            Lb.monochromatic = false;

            Lb.radius = 15;

            Lb.rotation = 0;

            Lb.shape = Geometry.HEXAGON;

            Lb.source = DepthMapSource.NONE;

            Lb.threshold = 0;

            activeDocument.activeLayer.applyLensBlur(Lb);

            1 person found this helpful
            • 3. Re: lensBlur
              Ghoulfool Level 1

              JJMack - your code works fine,

              c.pfaffenbichler - I've already written the lens blur as a function (as taken from the ScriptListener) - it works, but it's not as pretty as JJMack's code <br>

              However, I still can't see what's wrong with my one liner It should be striaght forward.

              • 4. Re: lensBlur
                Mikaeru69 Level 3

                Your one liner works just fine in CS4; it is just that things have changed between CS2 and CS3.

                 

                From the PDF document: "Adobe Photoshop CS3 Javascript Scripting Reference" p. 34: Introduction - Bug fixes:

                 


                The LensBlurOptions object has been removed. All options for the Lens Blur filter now appear directly as parameters to the ArtLayer.applyLensBlur() method.
                • 5. Re: lensBlur
                  Ghoulfool Level 1

                  In the CS scripting guide it just says

                  The following classes have been added to the JavaScript interface....
                  
                  LensBlurOptions, which you use to specify options when applying the Lens Blur filter to a layer.
                  

                   

                  Which doesn't really help as :

                  works fine

                  app.activeDocument.layers[0].applyLensBlur()
                  

                  but

                   

                  app.activeDocument.layers[0].applyLensBlur(DepthMapSource.NONE,0, false, Geometry.HEXAGON, 8, 0, 0, 0, 0, 0, NoiseDistribution.UNIFORM, false);
                  

                   

                  Doesn't but that puts me back at square1. Unless I'm just very confused at this point

                  • 6. Re: lensBlur
                    JJMack Most Valuable Participant

                    If you need CS2 you code the old way using the lensbluroption object and the old applylensblur method. If cs3 or newer use the new applylensblur method. If you want to support all versions you need to detect which version of Photoshop is rumming and execute the correct script with the approate code for PS version running, or use the scriptlistener code function you came up with that may work in all versions of Photoshop.

                    1 person found this helpful
                    • 7. Re: lensBlur
                      Ghoulfool Level 1

                      Thanks JJMack - that makes sense

                      • 8. Re: lensBlur
                        Michael L Hale Level 5

                        Ghoulfool wrote:

                         

                        Is CS2 why does the following line not work and instead produces error 1242, illegal argument 1 (which is DepthMapSource.NONE)

                        I know that you have found the reason for this error with version prior to CS3 and it didn't have to do with the argument list. But arguments index from 0, not 1. So the error message was refering to the second argument. Just wanted to point that out in case you run into an error where the problem is an incorrrect argument you will know which one to change.