-
1. Re: "No Such Element". Intro to scripting.
Michael L Hale Jul 22, 2013 5:06 PM (in response to spdorsey6969)If you look at that PDF again you will see that you copied an Illustrator script. Each app has it's own Object Model. There are some overlaps but you are better off using the Photoshop JavaScript Ref.PDF for the Photoshop Object Model. For example Photoshop layers doesn't have an add method, only artLayers and layerSets have it. And Photoshop doesn't have a textFrame class. Instead it has artLayers with the kind property set to LayerKind.TEXT.
Here is how you could do the same thing in Photoshop.
var myDoc = app.documents.add();
var myLayer = myDoc.artLayers.add();
myLayer.kind = LayerKind.TEXT;
myLayer.textItem.contents = "Hello world!"
-
2. Re: "No Such Element". Intro to scripting.
spdorsey6969 Jul 23, 2013 10:20 AM (in response to Michael L Hale)Oh wow. I didn't even see that. Thanks.
I can see how your script works. I think the hardest part of this is going to be learning the syntax. I'm bad with languages.
I appreciate the reply.
-
3. Re: "No Such Element". Intro to scripting.
Michael L Hale Jul 23, 2013 11:37 AM (in response to spdorsey6969)It can take a while to learn what 'something.somethingElse.somethingDifferent' means.But it really isn't that hard and I think you will find it easy to learn with a little practice.
So in a Photoshop script;
app means the Photoshop object( the program itself )
app.documents means the documents property of app. That contains a collection of document object.
app.documents.add() means the add method of documents. It is used to create a new document( add to the documents collection ). Note add does except arguments so you can control how the document is created.
artLayers is a docment object property that contains a collection of artLayer in the document. Note that a document object will also have layers and layerSets properties. layerSets is a collection of layerSet objects and layers is a collection that has both artLayer and layerSets objects.
artLayer.add() adds an artLayer. It doesn't have any arguments so you can't set the type of layer when creating.
artLayer.kind is a property for the layer's type. Using the Object Model you can only set the kind property to text and then only with an empty layer.
artLayer.textItem is property only a text layer will have. There you can set the contents, font, color, position, etc for the text layer.

