Copy link to clipboard
Copied
I have a library of text snippets in text frames.
I can place the asset on my page -- but my script is unable to access the text:
var myObj = myAsset.placeAsset(app.activeDocument); // works -- text frame placed on page
alert(myObj.contents); // undefined
the asset was created:
tf=app.activeDocument.pages[0].textFrames.add();
sel.duplicate(LocationOptions.AT_BEGINNING,tf);
asset= lib.store([tf]);
asset.name=name;
tf.remove();
I can manually select/copy the text in the asset - but I need to select and then duplicate the snippet in my main text.
Any idea why it's not working?
Thanks
Place method returns an array of placed objects. So even if object is an unique instance, you need to access it through the index of place array.
var placed = ….place ( … ) [0];
FWIW
Loic
Copy link to clipboard
Copied
Or is there some way to add just the text to a library without using a text frame?
Copy link to clipboard
Copied
Place method returns an array of placed objects. So even if object is an unique instance, you need to access it through the index of place array.
var placed = ….place ( … ) [0];
FWIW
Loic
Copy link to clipboard
Copied
What does placeAsset actually return?
Without experimenting, just looking at the documentation, it seems it returns an Array.
So perhaps this will work:
var myObj = myAsset.placeAsset(app.activeDocument)[0];
Ariel
Copy link to clipboard
Copied
Thanks to Loic.Aigon and TaW - that solved it
Find more inspiration, events, and resources on the new Adobe Community
Explore Now