Copy link to clipboard
Copied
Hi everyone,
I've encountered a problem with the "SelectObjects" UXP-Sample Script. If I run the script with either "Images", "PDFs" or "EPSs" (and nothing else) selected it returns an error. Of course it still selects frames with images etc. if I choose "Rectangles" to select and no error would be returned but that's not what I want.
Does anyone know, why the UXP-script is not working like the it should?
Btw: I've attached the error message from my german version of InDesign.
And yes, the ExtendScript version runs fine (like ist does for years) but I'm interested in the UXP-version for potential integration in a small plugin.
Thanks in advance
C.M.
Sorry, I just stopped the error. I checked it out in detail after that.
The fact that Rectangle does not have the images, epss, pdfs properties was the reason it was ignored.
This part
if((myIsInArray(myPageItem.getElements()[0].constructorName, myObjectTypes) == true) ||
((myIsInArray("images", myObjectTypes) == true) && (myPageItem.images.length == 1))||
((myIsInArray("epss", myObjectTypes) == true) && (myPageItem.epss.length == 1))||
((myIsInArray("pdfs", myObjectTypes) == true) && (myPag
...
Copy link to clipboard
Copied
When the target item does not exist, it seems that a special object called NothingEnum.NOTHING must be passed to the select command. Currently an empty array is specified, which is causing the error.
This part
parent.select(myObjectsToSelect, myInDesign.SelectionOptions.replaceWith);
should be like this
if(myObjectsToSelect.length <= 0) {
myObjectsToSelect = myInDesign.NothingEnum.NOTHING;
}
parent.select(myObjectsToSelect, myInDesign.SelectionOptions.replaceWith);
Copy link to clipboard
Copied
Thanks sttk3!
I gave it a try but still no luck on selecting the desired objects (images, pdfs etc.) on my end yet. At least the error message doesn't apear anymore. Did you succesfully test the modified version? If so, I might have done something wrong.
C.M.
Copy link to clipboard
Copied
Sorry, I just stopped the error. I checked it out in detail after that.
The fact that Rectangle does not have the images, epss, pdfs properties was the reason it was ignored.
This part
if((myIsInArray(myPageItem.getElements()[0].constructorName, myObjectTypes) == true) ||
((myIsInArray("images", myObjectTypes) == true) && (myPageItem.images.length == 1))||
((myIsInArray("epss", myObjectTypes) == true) && (myPageItem.epss.length == 1))||
((myIsInArray("pdfs", myObjectTypes) == true) && (myPageItem.pdfs.length == 1))
should be like this
if((myIsInArray(myPageItem.getElements()[0].constructorName, myObjectTypes) == true) ||
((myIsInArray("images", myObjectTypes) == true) && (myPageItem.allGraphics[0].constructorName == 'Image'))||
((myIsInArray("epss", myObjectTypes) == true) && (myPageItem.allGraphics[0].constructorName == 'EPS'))||
((myIsInArray("pdfs", myObjectTypes) == true) && (myPageItem.allGraphics[0].constructorName == 'PDF'))
Copy link to clipboard
Copied
Well, what should I say. It works perfectly. Many thanks again, sttk3!
Actually a quite obvious one and I kind of guessed it but my scriptings skills still might lack some polishing.
C.M.