3 Replies Latest reply on May 8, 2018 3:16 PM by MiloszSzatkowski

    Donwgrading UI script from PS CC to PS C6

    MiloszSzatkowski Level 1

      Hello everybody.

      I created kind of a big script that was working quite well without any dialog box on PS C6. I started implementing dialog box on a computer with PS CC. I was pleased with the result:

      01.jpg

       

      But after going back to other computers with PS C6, I cannot run this altered script anymore.

      I mean - it runs, but prompts following error:

      20180506_131752.jpg

      After running Debugger, all I got was "Window layout failed".

      Yes - script just terminates on "w.show ();" statement.

       

      The portion of code responsible for UI goes here:

       

      //choosePref is an array containing objects with data, that I didn't include to make it shorter

       

      var w = new Window ('dialog {orientation: "row", alignChildren: [" ", "top"]}',

          "Brytowanie grafiki | Graphic division", undefined, {closeButton: false});

       

          w.alignChildren = "right";

       

          var tab = w.add ("tabbedpanel");

          tab.alignChildren = ["fill", "fill"];

          tab.preferredSize = [350,300];

       

          var panels = [];

          var options = [];

       

          var ToverlapWithGraphic = "Uzyj laczenia z grafiki | Create overlap from graphic:";

          var TaddScaffolding = "Uzyj znacznikow laczenia    Use merging markers:";

          var Toptimal = "Uzywaj mniejszych brytow, gdy to tylko mozliwe | Use smaller divisions whenever possible:";

          var Toverlap = "Szerokosc overlapu | Graphics' overlap:";

          var Tmerger = "Szerokosc zgrzewu | Width of weld:";

          var TmaximumDivision = "Maksymalna szerokosc brytu | Maximal division width:";

          var TminimumDivision = "Minimalna szerokosc brytu | Minimal division width:";

          var ToptimalDivision = "Szerokosc optymalna minimalnego brytu | Optimal width for leftovers' fixing:";

          var Tsuffix = "Suffix:";

          var Tlines_Distance = "Pionowa odleglosc pomiedzy liniami znacznikow | Vertical distance between markers:";

          var TlineWidth = "Grubosc znacznika | Width of marker:";

          var TlineLongitude = "Szerokosc znacznika | How long is a marker:";

          var Tframe = "Grubosc obrysowania | Width of framing:";

       

          for (var i = 0; i < choosePref.length; i++) {

            panels.push( tab.add ("tab", undefined, choosePref[i].name) );

            panels[i].compareName = choosePref[i].name;

            panels[i].alignChildren = "fill";

            options[i] = panels[i].add ("panel", undefined, "Opcje lokalne | Local options");

            options[i].alignChildren = ["fill", "fill"];

       

            options[i].add("statictext", undefined, Toverlap);

            options[i].overlap = options[i].add("edittext", undefined, choosePref[i].overlap);

       

            options[i].add("statictext", undefined, Tmerger);

            options[i].merger =             options[i].add("edittext", undefined, choosePref[i].merger);

       

            options[i].add("statictext", undefined, TmaximumDivision);

            options[i].maximumDivision =    options[i].add("edittext", undefined, choosePref[i].maximumDivision);

       

            options[i].add("statictext", undefined, TminimumDivision);

            options[i].minimumDivision =    options[i].add("edittext", undefined, choosePref[i].minimumDivision);

       

            options[i].add("statictext", undefined, ToptimalDivision);

            options[i].optimalDivision =    options[i].add("edittext", undefined, choosePref[i].optimalDivision);

       

            options[i].add("statictext", undefined, Tframe);

            options[i].frameSize =    options[i].add("edittext", undefined, choosePref[i].frameSize);

       

            options[i].optimal =            options[i].add("checkbox", undefined, Toptimal);

                                              options[i].optimal.value = choosePref[i].optimal;

       

                                              options[i].add("statictext", undefined, Tsuffix);

            options[i].suffix =             options[i].add("edittext", undefined, choosePref[i].suffix);

       

       

            options[i].overlapWithGraphic = options[i].add("checkbox", undefined, ToverlapWithGraphic);

            options[i].overlapWithGraphic.value = choosePref[i].overlapWithGraphic;

       

            options[i].add("panel");

       

            options[i].addScaffolding =     options[i].add("checkbox", undefined, TaddScaffolding);

            options[i].addScaffolding.value = choosePref[i].addScaffolding;

       

            options[i].add("statictext", undefined, Tlines_Distance);

            options[i].lines_Distance =

            options[i].add("edittext", undefined, choosePref[i].lines_Distance);

       

            options[i].add("statictext", undefined, TlineWidth);

            options[i].lineWidth =          options[i].add("edittext", undefined, choosePref[i].lineWidth);

       

            options[i].add("statictext", undefined, TlineLongitude);

            options[i].lineLongitude =      options[i].add("edittext", undefined, choosePref[i].lineLongitude);

       

          }

       

          var tab2 = w.add ("tabbedpanel");

          tab2.alignChildren = ['fill','fill'];

          tab2.preferredSize = [300,700];

       

          var options2 = tab2.add ("panel", undefined, "Opcje globalne | Global options");

          options2.alignChildren = ['fill','fill'];

       

          // options2.closing = options2.add("checkbox", undefined, "Zamknij plik po brytowaniu | Close file after division");

       

          var buttonColor = options2.add ("button", undefined, "Wybierz kolor znacznikow | Choose marker color");

       

          var colorPanel = options2.add("panel {preferredSize: [500, 10]}", undefined, "Pole koloru");

          colorPanel.graphics.backgroundColor = w.graphics.newBrush (w.graphics.BrushType.SOLID_COLOR, [0.3, 0.3, 0.3]);

       

          var l_color = greyColorObj;

       

          buttonColor.onClick = function (){

            app.showColorPicker();

            l_color = app.foregroundColor.cmyk;

            colorPanel.graphics.backgroundColor = colorPanel.graphics.newBrush (w.graphics.BrushType.SOLID_COLOR, [

              mapRGB(app.foregroundColor.rgb.red,0,255,0,1), mapRGB(app.foregroundColor.rgb.green,0,255,0,1),

              mapRGB(app.foregroundColor.rgb.blue,0,255,0,1)]);

          }

       

          function mapRGB (num, in_min, in_max, out_min, out_max) {

            return (num - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;

          }

          var okButton = options2.add ("iconbutton", undefined, ScriptUI.newImage (File(new File((new File($.fileName)).parent +"/img.png"))));

       

          var cancelButton = options2.add ("button", undefined, "Anuluj ☕ Cancel", {name: "cancel"});

       

      var appStarted = false;

      var pref;

       

      okButton.onClick = function (){

          ///// -- !!!!!!!!!!! pass values to algorithm !!!!!!!!!!! -- /////

          for (var i = 0; i < choosePref.length; i++) {

            if (tab.selection.compareName.toString() == choosePref[i].name.toString()) {

              var tempIndex = i;

              pref = {};

       

                pref.compareName = tab.selection.compareName;

                pref.overlapWithGraphic = options[tempIndex].overlapWithGraphic.value;

                pref.addScaffolding = options[tempIndex].addScaffolding.value;

                pref.overlap = parseFloat(options[tempIndex].overlap.text);

                pref.merger = parseFloat(options[tempIndex].merger.text);

                pref.frameSize = parseFloat(options[tempIndex].frameSize.text);

                pref.maximumDivision = parseFloat(options[tempIndex].maximumDivision.text);

                pref.minimumDivision = parseFloat(options[tempIndex].minimumDivision.text);

                pref.optimalDivision = parseFloat(options[tempIndex].optimalDivision.text);

                pref.optimal = options[tempIndex].optimal.value;

                pref.suffix = options[tempIndex].suffix.text;

                pref.lines_Distance = parseFloat(options[tempIndex].lines_Distance.text);

                pref.lineWidth = parseFloat(options[tempIndex].lineWidth.text);

                pref.lineLongitude = parseFloat(options[tempIndex].lineLongitude.text);

                // pref.closing = options2.closing.value;

       

                appStarted = true;

                w.close();

            }

          }

      }

       

      cancelButton.onClick = function (){

        appStarted = false;

        w.close();

      }

       

      w.show ();

       

      If anyone wants to run full script - GitHub - MiloszSzatkowski/Graphic-division-plugin-photoshop

      The script divides graphics for printing.

       

      Does anyone have any clue ?

      Thank You for ANY help