An interesting question for scripters. Select does not work. Bug or feature?
I normally avoid working with selections in the script, so I haven't noticed such an error yet.
I found this question in another forum.
Selecting a TextFrame created in the script does not work as desired.
This is the code used:
var myDoc = app.activeDocument;
var topLay = myDoc.layers.add();
topLay.name = 'LABEL';
var txt = topLay.textFrames.add();
txt.name = 'LABEL Text';
txt.contents = "inhalt";
topLay.textFrames[0].selected = true;
Result (text frame seems to be selected but is not)
-->


-----------------------------------------------------------------------------------------------------------------
Possible remedies after some quick tests:
1) (Because it is only the only element in the newly created layer) Change the last line to:
topLay.hasSelectedArtwork = true;
works right away in this case.
-->

2) If the document is closed and reopened in the script, the TextFrame can also be selected correctly (this was only a test, however, as it is not practical).
3) If the selection is deselected in the script and then called up again, it works without any problems.
var myDoc = app.activeDocument;
var topLay = myDoc.layers.add();
topLay.name = 'LABEL';
var txt = topLay.textFrames.add();
txt.name = 'LABEL Text';
txt.contents = "inhalt";
topLay.textFrames[0].selected = true;
myDoc.selection = null;
topLay.textFrames[0].selected = true;
Can you understand this? Do you have an explanation for this?
---------------------------------------------------------------------------------
Tagging only
@CarlosCanto @Charu Rajput @m1b @femkeblanco @jazz-y @Sergey Osokin

