Copy link to clipboard
Copied
I was able to select the library item in a document using `app.libraries.item(0)` but how do I get all the elements(text frames) inside the library
Copy link to clipboard
Copied
You would check all the assets in your library.
Copy link to clipboard
Copied
this is how I am selecting a specific library
```
```
but how to get all the elements in that specific library?
Copy link to clipboard
Copied
Seems like you should be selecting the library you want with:
var lib = app.libraries.itemByName("LIB_NAME");
From there, you can get all assets in that library with:
var assets = lib.assets;
From there, you can loop through the assets and check if they are text assets with:
for (var i = 0; i < assets.length; i++) {
if (assets[i].assetType = AssetType.TEXT_TYPE) {
assets[i].select();
}
}
More on the Asset DOM is here: https://www.indesignjs.de/extendscriptAPI/indesign-latest/#Asset.html#d1e298313
Copy link to clipboard
Copied
Hi Brian,
AssetType is one idea. But one could doubt if the right assetType is applied to the right object.
Further: What happens if you store two or more objects in one asset?
I think one could only filter a text frame out of library assets if you place the asset.
asset.placeAsset() will return an array of objects. Loop the array and you know what it does contain.
var doc = app.documents.add();
var assetsArray = app.libraries[0].assets.everyItem().getElements();
for( var n=0; n<assetsArray.length; n++)
{
var placedAssetArray = assetsArray[n].placeAsset( doc );
for( var a=0; a<placedAssetArray.length; a++ )
{
$.writeln( n +"\t"+ a +"\t"+ placedAssetArray[a].constructor.name );
};
};
// Tidy up:
doc.close( SaveOptions.NO );
Regards,
Uwe Laubender
( ACP )
Copy link to clipboard
Copied
Good idea. I will purport to not having worked with assets, but placing and looping through it sounds like a good approach. Thanks for building it out further (and my knowledge base 🙂 )
Copy link to clipboard
Copied
Hi Brian,
my code snippet currently is using only one new document for placing the assets.
If one likes to actually use the assets it could be better to do one new document for every array of assets.
Why? Because there could be conflicts between incoming styles, custom named colors and styles and custom named colors that are already inside the document one like to place an asset.
It's easier to solve such conflicts if you start from scratch with a new document and move a placed asset over to the target document.
Regards,
Uwe Laubender
( ACP )