Highlighted

Error: The layer cannot contain text.

New Here ,
Aug 17, 2020

Copy link to clipboard

Copied

Using a script I create an Artboard and add a layer to the artLayers. In the next step I change the kind of the new layer to LayerKind.TEXT. 

This throws and exception "The layer cannot contain text".

 

var textLayerRef = artboard.artLayers.add();
textLayerRef.kind = LayerKind.TEXT;
 
Even the following code is failing with the same error
app.activeDocument.artLayers.add()
app.activeDocument.activeLayer.kind = LayerKind.TEXT
 
Any clue whats wrong?
 
TOPICS
Actions and scripting, Problem or error

Views

57

Likes

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

Error: The layer cannot contain text.

New Here ,
Aug 17, 2020

Copy link to clipboard

Copied

Using a script I create an Artboard and add a layer to the artLayers. In the next step I change the kind of the new layer to LayerKind.TEXT. 

This throws and exception "The layer cannot contain text".

 

var textLayerRef = artboard.artLayers.add();
textLayerRef.kind = LayerKind.TEXT;
 
Even the following code is failing with the same error
app.activeDocument.artLayers.add()
app.activeDocument.activeLayer.kind = LayerKind.TEXT
 
Any clue whats wrong?
 
TOPICS
Actions and scripting, Problem or error

Views

58

Likes

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
Aug 17, 2020 0
Adobe Community Professional ,
Aug 17, 2020

Copy link to clipboard

Copied

Some buggy feature if ArtBoard is present. Write about the bug on the feedback site.
Workaround
app.activeDocument.artLayers.add()

try { app.activeDocument.activeLayer.kind = LayerKind.TEXT } catch(e) { /*alert("WTF!");*/ }
app.activeDocument.activeLayer.kind = LayerKind.TEXT

 

UPD.

If we call the script twice in a row, we will see in the history that the text layer has been deleted. Those, you cannot create two text layers in a row. Another bug.
 

Likes

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
Reply
Loading...
Aug 17, 2020 1
New Here ,
Aug 21, 2020

Copy link to clipboard

Copied

Workaround:

 

I create a dummy group in the document root and create all text layers there and then move it to the correct/expected Artboard.

 

var dummyGroup = app.activeDocument.layerSets.add();

var textLayerRef =dummyGroup.artLayers.add();
textLayerRef.kind = LayerKind.TEXT;
// Text props
var textItemRef = textLayerRef.textItem;
 
textItemRef.contents = "Loreum Ipsum";
.
.
app.activeDocument.activeLayer.move(parentArtboardInstance, ElementPlacement.INSIDE);
dummyGroup.remove();

Likes

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
Reply
Loading...
Aug 21, 2020 0