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

How to Select Inverse via a Script

Engaged ,
Sep 30, 2022 Sep 30, 2022

Copy link to clipboard

Copied

Good Morning Everyone,

 

I'm wondering how I can go about Selecting Inverse within a Script.

 

Thanks for your help with this!

TOPICS
Scripting

Views

417

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

Enthusiast , Sep 30, 2022 Sep 30, 2022
app.executeMenuCommand("Inverse menu item");

Votes

Translate

Translate
Adobe
Enthusiast ,
Sep 30, 2022 Sep 30, 2022

Copy link to clipboard

Copied

app.executeMenuCommand("Inverse menu item");

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 ,
Sep 30, 2022 Sep 30, 2022

Copy link to clipboard

Copied

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 ,
Sep 30, 2022 Sep 30, 2022

Copy link to clipboard

Copied

LATEST

@jduncan 's solution is the best one.. For the sake of completeness, here's the worst solution i could come up with on the spot:

 

https://www.youtube.com/watch?v=6TgC1jWDQOs

 

 

function selectInverse ()
	{
		var nonSelectedItems = [];
		for ( var x = 0; x < app.activeDocument.pageItems.length; x++ )
		{
			alert( "Checking item " + x + " of " + app.activeDocument.pageItems.length );
			alert( "Testing whether item " + x + " is selected" );
			if ( !confirm( "Do you want to continue?" ) ) return;
			if ( app.activeDocument.pageItems[ x ].selected == false )
			{
				alert( "Item " + x + " is not selected" );
				alert( "Adding item " + x + " to array of non-selected items" );
				if ( !confirm( "Do you want to continue?" ) ) return;
				app.activeDocument.pageItems[ x ].note = x;
				nonSelectedItems.push( app.activeDocument.pageItems[ x ] );
			}
			else
			{
				alert( "Item " + x + " is selected" );
				alert( "This item will be deselected." );
				if ( !confirm( "Do you want to continue?" ) ) return;
			}
			app.redraw();
		}

		alert( "Successfully added all non-selected items to array" );
		alert( "Deselecting all items" );

		for ( var x = 0; x < app.activeDocument.pageItems.length; x++ )
		{
			alert( "Deselecting item " + x + " of " + app.activeDocument.pageItems.length );
			if ( !confirm( "Do you want to continue?" ) ) return;
			app.activeDocument.pageItems[ x ].selected = false;
			app.redraw();
		}

		alert( "Successfully deselected all items" );


		for ( var x = 0; x < app.activeDocument.pageItems.length; x++ )
		{
			alert( "Checking item " + x + " to see whether it should be selected." );
			if ( !confirm( "Do you want to continue?" ) ) return;
			for ( var y = 0; y < nonSelectedItems.length; y++ )
			{
				alert( "Checking item " + x + " against item " + y + " of non selected items array" );
				if ( !confirm( "Do you want to continue?" ) ) return;
				if ( app.activeDocument.pageItems[ x ] === nonSelectedItems[ y ] )
				{
					alert( "Item " + x + " is the same as item " + y + " in the non-selected items array" );
					alert( "Selecting item " + x );
					if ( !confirm( "Do you want to continue?" ) ) return;
					app.activeDocument.pageItems[ x ].selected = true;
				}
				else
				{
					alert( "Item " + x + " is not the same as item " + y + " in the non-selected items array" );
					alert( "Item " + x + " will not be selected" );
					if ( !confirm( "Do you want to continue?" ) ) return;
				}
			}
		}
	}
	selectInverse();

 

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