• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

Community Beginner ,
Aug 25, 2023 Aug 25, 2023

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.

TOPICS
Bug , Scripting , UXP Scripting

Views

454

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Aug 25, 2023 Aug 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) && (myPag
...

Votes

Translate

Translate
Community Expert ,
Aug 25, 2023 Aug 25, 2023

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 25, 2023 Aug 25, 2023

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 25, 2023 Aug 25, 2023

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

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 25, 2023 Aug 25, 2023

Copy link to clipboard

Copied

LATEST

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines