• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Photoshop CC 2018 Freezes When Running Scripts

Participant ,
Nov 06, 2017 Nov 06, 2017

Copy link to clipboard

Copied

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;

}

TOPICS
Actions and scripting

Views

1.4K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Community Expert ,
Nov 06, 2017 Nov 06, 2017

Copy link to clipboard

Copied

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

}

app.preferences.rulerUnits = orig_ruler_units; // Reset units to original settings

JJMack

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Nov 06, 2017 Nov 06, 2017

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 06, 2017 Nov 06, 2017

Copy link to clipboard

Copied

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

JJMack

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Nov 06, 2017 Nov 06, 2017

Copy link to clipboard

Copied

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!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 06, 2017 Nov 06, 2017

Copy link to clipboard

Copied

LATEST

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

}

app.preferences.rulerUnits = orig_ruler_units; // Reset units to original settings

Capture.jpg

JJMack

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines