-
script to create text layer with specified properties
Hi,
I need to write a script which will create a text layer that:
– is positioned in the lower left corner
– displays the comp name
– is white, with drop shadow, a specific font and size
It all works fine until I get to the text properties and then I keep getting “unable to execute script at line #. undefined is not an object. I’ve tried both Bard and ChatGPT to help me figure this out but to no avail. Here’s what I’ve got
var compName = app.project.activeItem.name;
var textLayer = app.project.activeItem.layers.addText(“”); // Create with empty initial text
var myTextDocument = new TextDocument(textLayer);
myTextDocument.text = compName;
myTextDocument.textProperty.fontSize = 30; // Set point size
myTextDocument.textProperty.fillColor = [255, 255, 255]; // Set color to white
textLayer.property(“Position”).setValue([50, app.project.activeItem.height – 50]);
var dropShadow = textLayer.effects.addEffect(“Drop Shadow”);
dropShadow.setProperty(“Color”, [0, 0, 0]);
dropShadow.setProperty(“Opacity”, 50);
dropShadow.setProperty(“Blur Radius”, 5);
app.project.activeItem.selectedLayers = [textLayer];
Thanks for any help.