Skip to main content
Inspiring
July 6, 2022
Answered

Disable Automatic Add to Swatches Upon Pasting

  • July 6, 2022
  • 3 replies
  • 1562 views

Hello peeps.

 

Is there any way I can simply paste something into InDesign WITHOUT it adding the colors to my swatch palette? Really annoying!


Thanks


E

This topic has been closed for replies.
Correct answer Laubender

Hi @EllaMaeMoonshiner ,

if you ever try my script code with copied elements in the clipboard, elements copied from Adobe Illustrator or InDesign, note the following:

 

The used colors are copied over to the target as unnamed ones. So you'd be able to restore them as named swatches with InDesign's menu command from the Swatches panel: Add Unnamed Colors. The original names will not be restored. InDesign will name the colors after their color values. Beware, that in that process any unnamed HSB color will be restored with a wrong name. Could be an InDesign bug.

 

Technically you are good to go with process colors.

 

Warning:

Not so with spot colors.

Spots will be converted to unnamed process colors in CMYK with 100% for every channel.

So I changed my posted code so that spot colors will be ignored for now.

 

Regards,
Uwe Laubender
( Adobe Community Professional )

3 replies

LaubenderCommunity ExpertCorrect answer
Community Expert
July 8, 2022

Hi @EllaMaeMoonshiner ,

if you ever try my script code with copied elements in the clipboard, elements copied from Adobe Illustrator or InDesign, note the following:

 

The used colors are copied over to the target as unnamed ones. So you'd be able to restore them as named swatches with InDesign's menu command from the Swatches panel: Add Unnamed Colors. The original names will not be restored. InDesign will name the colors after their color values. Beware, that in that process any unnamed HSB color will be restored with a wrong name. Could be an InDesign bug.

 

Technically you are good to go with process colors.

 

Warning:

Not so with spot colors.

Spots will be converted to unnamed process colors in CMYK with 100% for every channel.

So I changed my posted code so that spot colors will be ignored for now.

 

Regards,
Uwe Laubender
( Adobe Community Professional )

Community Expert
July 7, 2022

Hi @EllaMaeMoonshiner ,

would it help if this could be accomplished in a three-step process?

 

[1] First paste the artwork to a new InDesign document

[2] Run a script that unnames all named colors like the one below:

ChangeAllNamedColorsToUnnamedColors.jsx

[3] Copy/paste the result to the target document.

 

The script is written in ExtendScript (JavaScript) for InDesign.

Cannot tell, if it will work for all kinds of colors that come over by pasting artworks from Illustrator to InDesign. Just tested with a small sample of RGB process colors that were added to the Swatches panel.

 

You can undo the script's action in one go.

 

 

/**
* @@@BUILDINFO@@@ ChangeAllNamedColorsToUnnamedColors.jsx !Version! Thu Jul 07 2022 18:47:55 GMT+0200
*/

/*
	See discussion at Adobe InDesign User Forum:
	
	Disable Automatic Add to Swatches Upon Pasting
	EllaMaeMoonshiner, Jul 06, 2022
	https://community.adobe.com/t5/indesign-discussions/disable-automatic-add-to-swatches-upon-pasting/td-p/13053280
	
	Is there any way I can simply paste something into InDesign WITHOUT it adding the colors to my swatch palette? Really annoying!
	
	
	Uwe Laubender:
	The answer is yes.
	
	Copy the artwork from Illustrator to a new document.
	Run this script below.
	Copy the result to the target document.
	
*/

( function()
{

app.scriptPreferences.userInteractionLevel = UserInteractionLevels.INTERACT_WITH_ALL;

app.doScript
(

	unnameAllColorsOfDocument, 
	ScriptLanguage.JAVASCRIPT, 
	[],
	UndoModes.ENTIRE_SCRIPT, 
	"Unname ALL colors of document | SCRIPT"

);

function unnameAllColorsOfDocument()
{
	if( app.documents.length == 0 ){ return };
	var doc = app.documents[0];
	var colorsArray = doc.colors.everyItem().getElements();

	for( var n=0; n<colorsArray.length; n++ )
	{
		try
		{
			var colorName = colorsArray[n].name;
			if( colorName == "" ){ continue };
			// SPOT COLORS WILL BE IGNORED:
			if( colorsArray[n].model == ColorModel.SPOT ){ continue };
			
			var unnamedColor = doc.colors[-1].duplicate();
			unnamedColor.properties = colorsArray[n].properties;
			colorsArray[n].remove( unnamedColor );
			
		}catch(e){};
	};

};

}() )

 

 

The code is based on an idea by @Trevor: who started this discussion in 2011, it then continued in 2014 and 2017:

 

Coloring a Font with a RGB etc. without adding the color to the document swatches.
Trevor:, Sep 21, 2011
https://community.adobe.com/t5/indesign-discussions/coloring-a-font-with-a-rgb-etc-without-adding-the-color-to-the-document-swatches/td-p/3655060

 

 

Regards,
Uwe Laubender
( Adobe Community Professional )

 

EDITED CODE because of issues with spot colors.

rob day
Community Expert
Community Expert
July 7, 2022

Hi Uwe, that’s really good. I wonder if you could avoid removing all of the existing swatches by including the paste in the script and getting the swatches from the resulting selection. Something like this?

 

var doc = app.documents[0];
//assumes the clipboard has the copied Illustrator items 
app.paste();
//get the selection’s page items
var s = doc.selection[0].allPageItems;
//get an array of fill and stroke colors
var colorsArray = [];
for (var i = 0; i < s.length; i++){
    colorsArray.push(s[i].fillColor)
    colorsArray.push(s[i].strokeColor)
};  

//remove the swatches added from the AI paste
//I don’t think the AI colors come in unnamed?
var unnamedColor;
for( var n=0; n<colorsArray.length; n++ ){
    try{
        unnamedColor = doc.colors[-1].duplicate();
        unnamedColor.properties = colorsArray[n].properties;
        colorsArray[n].remove( unnamedColor );
    }catch(e){};
};
Community Expert
July 7, 2022

Hi Rob,

yes, that's one idea. Thinking about it…

 

Another idea :

Store all ID numbers of all existing colors before doing app.paste().

That could be an object or an associative array. Then after the app.paste() you'll loop the array of colors and check if a certain ID number is in the associative array. If not, try to turn that color into an unnamed one.

 

Regards,
Uwe Laubender
( Adobe Community Professional )

Steve Werner
Community Expert
Community Expert
July 7, 2022

You're not providing us much information. What application are you copying (another INDD file), a graphic from Illustrator, a graphic from Photoshop?). Please give us more details.

 

Also: Please tell us what operating system (exactly) you're running. Please tell us (exactly) what InDesign version you're using.

Inspiring
July 7, 2022

Hello Steve. Thanks for your reply.

So: running OS 11.6.7 on an iMac Pro with the recent version of InDesign.
When I paste vector grahics from Illustrator, all of the colours in those graphics end up in my swatches palette. I'd like the option of choosing which colours I add there - not to have it done automatically.

Is there a way around this?

 

Thanks

E.

Brad @ Roaring Mouse
Community Expert
Community Expert
July 7, 2022

No.

Any spot colours in Illustrator are added. This is ncessary behaviour.

However, if you don't want spot colours, don't use them in your Illustraor file... edit the spot colours in that file to process instead.

Also, you should be PLACING your Illustrator files, not copy/pasting