8 Replies Latest reply: Apr 21, 2014 6:56 AM by sandamanca RSS

    Pull/Get Data/Value from User Input Window

    sandamanca Community Member

      I'm trying to do something that should be be quite basic for a programer, but unfortunately unfortunately being a designer I'm having a heck of a time with this.  Having spent hours searching and trying different things I thought of posting the problem.  I have the feeling I'm not the first designer struggling with this.

       

      I'm trying to pull input data from a window and pass it on to a variable.  In the script I do a couple of purge(), and I'm not sure if that will clear the user input values during the script, but this is thinking ahead...

       

      I need values to do:

       

      layer.translate(X, Y) // If I'm not wrong this needs to be a - string

      bitsaveoptions.method = ChanelScreen; //from drop down menu

      bitsaveoptions.angle = KAngle //  If I'm not wrong this needs to be a - integer

      bitsaveoptions.frequency = ChanelFrequency; //  If I'm not wrong this needs to be a - integer

      bitsaveoptions.resolution = ChanelResolution; //  If I'm not wrong this needs to be a - integer

      bitsaveoptions.shape = BitmapHalfToneType.ROUND; //from drop down menu

       

      I know that there are different ways to retrieve the data from a window .selection .value and maybe others but I can't seem to pull the data out of from the user input

       

      Any advice would be greatly appreciated. 

       

      Thanks.

       

      PS I'm working with Photoshop CS5

       

      This is what I have so far.

       

      // =========== Ruler to Millimiters

      app.preferences.rulerUnits = Units.MM;

       

       

      var doc = app.activeDocument;

      var layer = doc.activeLayer;

      var dropdownlistArray = new Array();// The array of drop down lists.

      var chosen_action = null;

       

      var ScreenShapeArray= new Array(

      'Round',

      'Eliptical'

      );

       

      var WinContent =

      "dialog{\

          orientation: 'column', \

          alignChildren: ['fill', 'top'],  \

          preferredSize:[300, 130], \

          text: 'Export Settings',  \

          margins:15, \

          \

              Coordinates: Panel {\

              orientation: 'column', \

              text: 'Chanels Shifts', \

              margins:15, \

              alignChildren: 'right',\

                  KChanelX: Group{\

                  st: StaticText { text: 'X:' }, \

                  te: EditText { text: '15', characters: 4, justify: 'right'} \

                  st2: StaticText { text: 'mm' }, \

                  } \

                  KChanelY: Group{\

                  st: StaticText { text: 'Y:' }, \

                  te: EditText { text: '10', characters: 4, justify: 'right'} \

                  st2: StaticText { text: 'mm' }, \

                  }\

              }\

          bottomGroup: Group{\

              cancelButton: Button { text: 'Cancel', properties:{name:'cancel'}, size: [120,24], alignment:['right', 'center'] }, \

              applyButton: Button { text: 'Apply', properties:{name:'ok'}, size: [120,24], alignment:['right', 'center'] }, \

      }\

      }"

       

      // ======== Create window object

      var win = new Window(WinContent);

       

      // ======== Display Window

      win.show();

      var X =parseInt(win.Coordinates.KChanelX.te.selection);

      var Y =parseInt(win.Coordinates.KChanelY.te.selection);

       

       

      alert (X); // Here I get NaN

      alert (Y); // Here I get NaN

       

       

      if (typeof(X) === "undefined" || typeof(Y) === "undefined" ){

      layer.translate(X+"mm", "-"+Y+"mm");

      }else {

      alert ("here"); // Always end-up here regardles of canling or acepting the default values

         };

        • 1. Re: Pull/Get Data/Value from User Input Window
          c.pfaffenbichler Community Member

          Please try

          alert (win.Coordinates.KChanelX.te.text);

          alert (win.Coordinates.KChanelY.te.text);

          • 2. Re: Pull/Get Data/Value from User Input Window
            pixxxel schubser Community Member

            You haven't a selection in an edittext field. Like c.pfaffenbichler said - you get your X and your Y is

             

            var X = win.Coordinates.KChanelX.te.text;
            

             

            and so on:

             

            var X = parseInt(win.Coordinates.KChanelX.te.text); // or
            var X = Number(win.Coordinates.KChanelX.te.text);
            

             

            Have fun

             

            • 3. Re: Pull/Get Data/Value from User Input Window
              c.pfaffenbichler Community Member

              What is the Script intended to achieve ultimately?

              • 4. Re: Pull/Get Data/Value from User Input Window
                JJMack Community Member

                Your also not testing how the window was dismisssed and your if statement look wrong

                 

                // ======== Display Window

                if (win.show() == 1) {

                 

                          var X =(win.Coordinates.KChanelX.te.text);

                          var Y =(win.Coordinates.KChanelY.te.text);

                 

                          if ( !isNaN(X)  && !isNaN(Y) ) { layer.translate(X+"mm" , +Y+"mm"); }

                          else { alert ("here"); };  // not numeric

                          }

                else { alert("User Cancelled"); }

                • 5. Re: Pull/Get Data/Value from User Input Window
                  sandamanca Community Member

                  .text

                   

                  Is what I was looking for!

                   

                  Not being so programming savvy, and not knowing the proper terminolgy makes things way harder.

                   

                  You asked what the script is for:

                   

                  I'm creating an interface to save multiple file from a master file.

                  1. Set the bitmap conversion presets (res, screen type, shape, lpi, angle), for the desired chanels to export, set the pages in the book that will be produced, number of signatures, as well as pages per signature.

                  2. Create tiffs for every chanlel and move the chanel according to the presets tied to the signature the page belongs to in the book.

                  3. Reassemble the chanels into one file for viewning and use the tifs for print.

                   

                  Total I will have:

                   

                  Myfile_C.tif //Cyan

                  Myfile_M.tif //Magenta

                  Myfile_Y.tif //Yellow

                  Myfile_K.tif //Black

                  Myfile_col.psd //CMY chanels reassembled

                  Myfile_sep.psd //CMYK chanels reassembled

                   

                  Why am I doing all this? I'm working on a comic that will simulate a silver age comic book and I need the look of that time, with off registration plates. But I also need to see the final result of the shift and keep things constant for each plate as I'm working on the separate pages, so series of presets are a must for me.

                   

                  If the result of the interface is somewhat acceptable I'll post it.

                   

                  Thanks for the help I really apperciate it.

                  • 6. Re: Pull/Get Data/Value from User Input Window
                    sandamanca Community Member

                    JJMack,

                     

                     

                    Thanks for the bit you posted, I'm still working on getting my head wrapped around that.  I'm presently using a  while function but I'm not fully understanding how it's doing the deed it works fine but me know understanding the logic makes things more complicated. Your approach is a lot more simple to follow for my limited knowledge.

                     

                     

                        while (!done) {

                          // ======== Display Window

                          var x = win.show();

                          if (x == 0 || x == 2) {

                            // =======Cancel is pressed

                            win.canceled = true;

                            done = true;

                          } else if (x == 1) {

                            done = true;

                            {

                        // =============execute the process

                        var CChanelTransX =win.CChanel.CChanelX.te.text;

                        var CChanelTransY =win.CChanel.CChanelY.te.text;

                        alert ("TranslateY = "+ CChanelTransY);

                        layerMove.translate(CChanelTransX+"mm", "-"+CChanelTransY +"mm");

                        alert ("Processed");

                          }

                       }

                    • 7. Re: Pull/Get Data/Value from User Input Window
                      c.pfaffenbichler Community Member

                      Just to make sure:

                      Myfile_C.tif //Cyan

                      Myfile_M.tif //Magenta

                      Myfile_Y.tif //Yellow

                      Myfile_K.tif //Black

                      are bitmap (1bit) images with a sufficient effective resolution (usually around 1200ppi in the case of offset printing)? (edited)

                      • 8. Re: Pull/Get Data/Value from User Input Window
                        sandamanca Community Member

                        Thanks for thinking ahead.

                         

                        Yes, I'm exportiong at 1200ppi native resolution of the working document.