Skip to main content
carstenm23472936
Participant
August 25, 2023
Answered

UXP Script "SelectObject" does not work on images, pdfs, eps

  • August 25, 2023
  • 1 reply
  • 864 views

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.

This topic has been closed for replies.
Correct answer sttk3

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')) 

 

1 reply

Legend
August 25, 2023

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);
carstenm23472936
Participant
August 25, 2023

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.

sttk3Correct answer
Legend
August 25, 2023

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'))