Skip to main content
Loic.Aigon
Legend
June 18, 2010
Question

Is that a CS5 bug (app.findObjectPreferences.fillColor)

  • June 18, 2010
  • 5 replies
  • 6653 views

Hi,

I wanted to go and make a findObject request through scripting. My intention is to find objects with "None" fill color.

So I wrote :

with(app.findObjectPreferences){

fillColor="None";

}

app.findObject() and that returns 0 occurences.

As I have "None" filled objects, I didn't understand why Indesign didn't find them and looked into the find object dialog box to see what is going on.

It appears that the specified color is not None but non specific color.

So I picked "None" in the UI and just request the name of that color via scripting

alert(app.findObjectPreferences.fillColor.name);

Obviously, it should return me "None" but it gave me "C=0 M=0 Y=100 K=0"...

And indeed if I give :

with(app.findObjectPreferences){

fillColor="C=0 M=0 Y=100 K=0";

}

The UI dialog displays "None".

Why Pure Yellow is None ?

Loic

This topic has been closed for replies.

5 replies

m1b
Community Expert
Community Expert
March 10, 2023

Hi all, I'm still seeing this bug in ID 18.2. I couldn't find the bug in uservoice, so I created one.

Please vote for it here.

- Mark

Community Expert
April 13, 2021

FWIW: After all these years the situation has not changed.

 

A possible solution for working with findObjectPreferences.fillColor, changeObjectPreferences.fillColor is to build a findChangeQuery XML file, load it and do changeObject() on a document or on page items. Here some sample code where the file ReplaceFillColor.xml exists in the appropriate folder inside InDesign's preferences:

app.loadFindChangeQuery( "ReplaceFillColor", SearchModes.OBJECT_SEARCH );
app.documents[0].changeObject();

 

More on this in a similar discussion we had in 2020 and where some posts were added recently:

 

Am facing this error, try to find object fill color.
Balaji Murugesan, Jun 25, 2020

https://community.adobe.com/t5/indesign/am-facing-this-error-try-to-find-object-fill-color/td-p/11238876

 

Regards,
Uwe Laubender

( ACP )

Inspiring
June 21, 2010

This works: [Oops -- see following two messages for the truth]

doc = app.documents[0]; app.findObjectPreferences.fillColor = NothingEnum.nothing; myFinds = doc.findObject();

I wonder if CS4 has the same problem?

Yes it does. But the above code works in it, too.

Dave

Marc Autret
Legend
June 21, 2010

Hi Dave,

Are you sure that using NothingEnum.nothing actually works? I think your code will purely unset the fillColor property, so the findObject() method will probably disregard fillColor and return any object whatever its color... But Loic's script needs to match [None] only.

@+

Marc

Inspiring
June 21, 2010

Ah, you're right Marc.

Sorry folks, that code doesn't work (except in the case where all objects have no fill, which was the case when I "tested" the code.

The problem appears to be that the property is set to accept application-level swatches, which is useless because they're not in use in the document. So, this:

app.findObjectPreferences.fillColor = app.swatches[0];

"works" in the narrow sense that it executes but it does you no good because the following find command doesn't find the page items with the corresponding document swatch.

Interesting. This also "works" in the same way:

app.findObjectPreferences.fillColor = "None";

The swatch it picks up belongs to the application, as this demonstrates:

app.findObjectPreferences.fillColor = "None"; $.writeln(app.findObjectPreferences.fillColor.parent);

So, it looks like the only way to go is find them all and filter out the ones you want (or don't want, depending on how you interpret the word "filter").

Dave

Marc Autret
Legend
June 21, 2010

Anyway this *does not* answer to Loic's original question.

app.findObjectPreferences.fillColor seems to have a serious bug (in CS4 and CS5). Apparently we cannot set this property to the actual None swatch by scripting... Does anybody have a workaround?

@+

Marc

Harbs.
Legend
June 21, 2010

I don't know about workarounds, but at least I've called this to the attention of some folks at Adobe...

Probably the best you're going to be able to do will be using a loop to examine the fillColor yourself. I don't recall ever scripting find/change of objects (using findObject() or changeObject() ). I've never felt the need to. Looping through all the objects in a document and examining them yourself is generally pretty quick.

Harbs

Harbs.
Legend
June 18, 2010

try: app.findObjectPreferences.fillColor = doc.colors.item(0);

Harbs

Community Expert
June 21, 2010

@Harbs:

I ran the following test to get a list of the default colors and their names.

for(n=0;n<app.colors.length;n++){
    $.writeln("IndexNumber: "+n+"       color.name: "+app.colors.name);
    };

Result:

IndexNumber: 0       color.name: Black
IndexNumber: 1       color.name: C=0 M=0 Y=100 K=0
IndexNumber: 2       color.name: C=0 M=100 Y=0 K=0
IndexNumber: 3       color.name: C=100 M=0 Y=0 K=0
IndexNumber: 4       color.name: C=100 M=90 Y=10 K=0
IndexNumber: 5       color.name: C=15 M=100 Y=100 K=0
IndexNumber: 6       color.name: C=75 M=5 Y=100 K=0
IndexNumber: 7       color.name: Cyan
IndexNumber: 8       color.name: Magenta
IndexNumber: 9       color.name: Paper
IndexNumber: 10       color.name: Registration
IndexNumber: 11       color.name: Yellow
IndexNumber: 12       color.name:
IndexNumber: 13       color.name:

So doc.colors.item(0) should get "Black", but the script threw an error. I tried doc.color.item(0).name and that gave me fill color "Unknown color".
Next I tested the following line:

app.findObjectPreferences.fillColor = app.activeDocument.colors[1].name;

That finally gave me the desired fill color "None".
Very strange to get a read out of C=0 M=0 Y=100 K=0 when asking for colors[1].name.
I tested other index values. One should asume that setting fillColor to colors[9].name would yield a fill color [Paper]. But not so. I got "Unknown color". Instead colors[5].name did the trick.

If we take a closer look at the list above colors[12] and [13]  seem to have a empty name like that: ""

"Reasonable" index numbers to use were:
[1] => fillColor [None]
[5] => fillColor [Paper]
[6] => fillColor [Registration]
[11] => fillColor [Black]

What's going on here?

Tested with InDesign CS5 German version 7.0.1.

Tried the same with InDesign CS4 6.0.5 but got only one "hit" at all. Got "Unknown color" also on index 1,5,6. With index 11 I was successful to get fillColor [Black].

Uwe

Harbs.
Legend
June 21, 2010

This is really weird, but either way, the correct way to get a reference to the "None" color is to use the swatches collection.

The same goes for the rest of the saved colors.

doc.swatches[0] is always "None".

Harbs