Copy link to clipboard
Copied
Hi.
To check the deletable paths, I need to collect the contents of some documents. I'm only looking for graphic objects.
The following script works in principle (if I search the paths individually), only at one point the error message is output: "null is not an object".
var myDoc = app.activeDocument;
var myPaths = Array();
var eachGrafic = myDoc.allGraphics.length;
var myGraphics = myDoc.allGraphics;
for(i=0; i<eachGrafic; i++){
if(app.activeDocument.allGraphics.itemLink.filePath != null) {
//~ app.select(app.activeDocument.allGraphics);
//~ alert(app.activeDocument.allGraphics.itemLink.filePath)
myPaths.push(myGraphics.itemLink.filePath)
}
}
alert(myPaths);
There are no hidden objects or layers. What could be the reason?
Hi cmoke73 ,
there could be graphics in the document where no itemLink is there.
Pixels perhaps that are pasted from e.g. PhotoShop.
Screenshot from my German InDesign:
"Ebenen" means "Layers"
"Ebene 1" means "Layer 1"
"<eingefügte Grafik>" means "<pasted Graphic>"
"Verknüpfungen" means "Links"
In the sample document shown above there is one pasted bunch of pixels from PhotoShop.
allGraphics array length is 1.
...app.documents[0].allGraphics[0].itemLink ; // Returns null
app.documents[0].allGraphics[0].itemLi
Copy link to clipboard
Copied
Hi,
Without seeing the document I am not sure why your code is raising an error.
Although you could use this as it should return all the graphics in the document.
var myGraphics = app.activeDocument.pages.everyItem().pageItems.everyItem().graphics.everyItem().getElements();
Feel free to post the document to a file sharing site and we can take a look at why your code is not working.
Regards
Malcolm
Copy link to clipboard
Copied
Hi Malcolm!
Thank you for replying. Now I recognized the script is working with an other document, with even more content. So I have no idea why or why not. Unfortunately I cannot share the document. It´s from the company I´m working at and it is not allowed.
Copy link to clipboard
Copied
Hi cmoke73 ,
there could be graphics in the document where no itemLink is there.
Pixels perhaps that are pasted from e.g. PhotoShop.
Screenshot from my German InDesign:
"Ebenen" means "Layers"
"Ebene 1" means "Layer 1"
"<eingefügte Grafik>" means "<pasted Graphic>"
"Verknüpfungen" means "Links"
In the sample document shown above there is one pasted bunch of pixels from PhotoShop.
allGraphics array length is 1.
app.documents[0].allGraphics[0].itemLink ; // Returns null
app.documents[0].allGraphics[0].itemLink.filePath ; // Throws an error: Null is not an object
So always check, if itemLink == null before going on with any property of itemLink.
Regards,
Uwe
Copy link to clipboard
Copied
Hallo Uwe.
Danke für den Hinweis!
So I tried nearly the same to avoid the error:
if (app.documents[0].allGraphics[0].itemLink.filePath != null) {
...
}
But your hint was the salvation.
Thank you.
Copy link to clipboard
Copied
Nearly the same?
Hm. No. 🙂
Best,
Uwe
Find more inspiration, events, and resources on the new Adobe Community
Explore Now