5 Replies Latest reply on Nov 6, 2017 11:04 PM by JJMack

    Photoshop CC 2018 Freezes When Running Scripts

    gdwd Level 1

      I have two simple scripts that split one text layer into multiple text layers. One creates a new text object for every character, one creates a new text object for every word (characters separated by a space). These scripts functioned as intended in previous versions of Photoshop. With the 2018 update, Photoshop will sometimes lock up when I use these scripts, necessitating a force close with Task Manager.

       

      Here is an example. Text layer before script:

      2017-11-06 17_56_09-Untitled-1 @ 100% (Lorem ipsum, RGB_8) _.png

      Text layers after script (intended):

      2017-11-06 17_56_29-Untitled-1 @ 100% (Lorem, RGB_8) _.png

      Text later after script (Photoshop freezes):

      2017-11-06 17_56_40-Untitled-1 @ 100% (Lorem ipsum, RGB_8) _.png

      When Photoshop freezes, toolbar, menu, and tool buttons can be clicked, but do not do anything. The layer panel is completely frozen, which I think might be related to the cause. Text becomes selected, cannot be unselected. No layers are created, the base layer is just edited. This issue does not always occur; it seems more likely to happen the longer Photoshop has been open.

       

      Was something changed in the 2018 update with regard to scripting? If so, what do I have to change to fix my script? Or is there some problem with Photoshop itself?

       

      Here is the script being used:

       

      doc = app.activeDocument;
      layer = doc.activeLayer;
      
      
      var text = layer.textItem.contents;
      var textArray = text.split(" ") || text.split("/r");
      
      
      var pos = layer.textItem.position;
      var sze = layer.textItem.size;
      var DPI = app.activeDocument.resolution;
      
      
      layer.textItem.contents = textArray[0];
      layer.name = textArray[0];
      
      
      for (var k=1; k<textArray.length; k++){
          tmp = layer.duplicate();
          tmp.textItem.position = [pos[0]+(Number(sze)*Number(DPI)*k*.015), pos[1]];
          tmp.textItem.contents = textArray[k];
      }
      
        • 1. Re: Photoshop CC 2018 Freezes When Running Scripts
          JJMack Most Valuable Participant

          Does the help

           

          var orig_ruler_units = app.preferences.rulerUnits;
          app.preferences.rulerUnits = Units.PIXELS; // Set the ruler units to PIXELS
          
          doc = app.activeDocument;  
          layer = doc.activeLayer;  
            
          var text = layer.textItem.contents;  
          var textArray = text.split(" ") || text.split("/r");  
            
          var pos = layer.textItem.position;  
          var sze = layer.textItem.size;  
          var DPI = app.activeDocument.resolution;  
          
          layer.textItem.contents = textArray[0];  
          layer.name = textArray[0];  
          
          for (var k=1; k<textArray.length; k++){  
              tmp = layer.duplicate();  
              tmp.textItem.position = [pos+(Number(sze)*Number(DPI)*k*.015), pos[1]];  
              tmp.textItem.contents = textArray[k];  
          } 
          
          app.preferences.rulerUnits = orig_ruler_units; // Reset units to original settings 
          
          • 2. Re: Photoshop CC 2018 Freezes When Running Scripts
            gdwd Level 1

            Unfortunately that change doesn't prevent the crash from happening. Oddly enough, it seems like any time the script would cause a freeze, "app.preferences.rulerUnits = Units.PIXELS;" opens the units preferences screen instead of just doing it.

            • 3. Re: Photoshop CC 2018 Freezes When Running Scripts
              JJMack Most Valuable Participant

              What OS are you using.  If Photoshop crashes post the crash report.  If Photoshop hangs what is it hanging on?  I needed to add units pixels because the script would fail to add text to the duped text layers. position was most likely off. Photoshop CC 2018 on my Windows 10 machine never crashed or hung.  The text layers added were empty and the original text layer was edited to the first word..

              Capture.jpg

              • 4. Re: Photoshop CC 2018 Freezes When Running Scripts
                gdwd Level 1

                Very sorry about the inconvenience, but I believe I isolated the problem to another script that I use very often (often enough that I forgot it was a script). That script was unintentionally setting "DialogModes.NO". I have no idea how that lead to all my problems, or why it only happened after updating to 2018, but fixing that also fixed my split script. Thanks!

                • 5. Re: Photoshop CC 2018 Freezes When Running Scripts
                  JJMack Most Valuable Participant

                  I still feel the  units.pixel is required and its you position statement need fixing I do not know JavaScript I just hack at it some. I do not understand you positioning statement math I hack a bit on that statement.

                      tmp.textItem.position = [Number(pos[0])+(Number(sze)*Number(DPI)*k*.032), Number(pos[1])];  

                  var orig_ruler_units = app.preferences.rulerUnits;
                  app.preferences.rulerUnits = Units.PIXELS; // Set the ruler units to PIXELS
                  
                  doc = app.activeDocument;  
                  layer = doc.activeLayer;  
                    
                  var text = layer.textItem.contents;  
                  var textArray = text.split(" ") || text.split("/r");  
                    
                  var pos = layer.textItem.position;  
                  var sze = layer.textItem.size;  
                  var DPI = app.activeDocument.resolution;  
                  
                  layer.textItem.contents = textArray[0];  
                  layer.name = textArray[0];  
                    
                  for (var k=1; k<textArray.length; k++){  
                      tmp = layer.duplicate();  
                      tmp.textItem.position = [Number(pos[0])+(Number(sze)*Number(DPI)*k*.032), Number(pos[1])];  
                      tmp.textItem.contents = textArray[k];  
                  } 
                  
                  app.preferences.rulerUnits = orig_ruler_units; // Reset units to original settings 
                  

                   

                  Capture.jpg