4 Replies Latest reply on Jun 26, 2009 1:28 PM by Randomsen

    fill color existential crisis

    Randomsen

      Today I found out the hard way that getting the object reference for a color by name is case insensitive, but setting the fill color by name IS case senstive. Unfortunately I was working with the swatch [None] so I had no idea!!! (by way of appearance

       

      In fact it was causing the property to be null, while still being able to have a fill tint value. Yet you can't set the fill color to be nothing?

       

      Is this a bug??

       

      Thanks,

       

      ~Mike

        • 1. Re: fill color existential crisis
          [Jongware] Most Valuable Participant

          So, what are you trying to accomplish?

          I've had some problems getting to the first few swatches (none, paper, black, reg.), but you can always access the swatch [None] by using app.activeDocument.swatches(0) where needed -- nothing of that troublesome name stuff.

          • 2. Re: fill color existential crisis
            Dave Saunders Level 4

            myDoc = app.documents.add();

            myPage = myDoc.pages[0];

            myRect = myPage.rectangles.add({geometricBounds:myPage.bounds});

            myRect.fillColor = myDoc.swatches[-1];

            myDoc.recompose();

            $.sleep(3000) // so you can see the fill;

            mySwatch = myDoc.swatches.item("None");

            myRect.fillColor = mySwatch;

             

             

            Dave

            • 3. Re: fill color existential crisis
              Randomsen Level 1

              **I realize now that this behavior was only encountered with cells,  rows, and  columns of tables, I apologize for not being more specific. It does in fact return an error when trying to set the fill color (to an invalid or non existent color) to all other objects I've tested so far.So this should be classified as a table specific issue.**  InDesign Version 5.0.4

               

              The true issue is...if you try to set the fill color to ("none"), is doesn't cause an error, instead sets the fill color as nothing.

              But if you were to try and set fill color as nothing with code...it returns an error

               

              "Invalid value for set property 'fill color'. Expected swatch or string, but received nothing."

               

              It just seems wrong to be able to have that property be set as nothing(by virtue of trying to set it with a color that does not exist)  and it not a return an error, but programatically not be able to set it to nothing yourself.

               


              Am i wrong to assume that if "None" is the default value, that it shoudn't be able to be null or nothing(at least without returning an error)?

               

              I mention the Case Sensitive and Non-Case Sensitive part because that added to the deception. To get the object reference of the "None" swatch can be accomplished both "none" and "None", but to directly set a fill color using "none", sets the fill color as null or nothing, not the "None" swatch.

               

              Hence the existential crisis....

               

              Thanks for your input .

               

              ~Mike

               

              Message was edited by: Randomsen**

              • 4. Re: fill color existential crisis
                Randomsen Level 1

                I know that this shouldn't work, my only concern is that it doesn't cause an error event.

                 

                In AS:

                 

                tell application "Adobe InDesign CS3"
                    set fill color of selection to "aswatchthatdoesntexist"
                    get fill color of selection
                end tell

                 

                returns nothing with a cell, row or column selected

                 

                In JS it returns a swatch object, but trying to access any properties of it returns the invalid object error
                myDoc = app.activeDocument;
                myCell = app.selection;
                myCell.fillColor = myDoc.swatches.item("aswatchthatdoesntexist");
                myCell.fillColor

                 

                 

                Thirdly, if you first set the fill color in one script run, and then in the second reference the fillColor object, it returns undefined

                 

                Run this first:

                 

                myDoc = app.activeDocument;
                myCell = app.selection;
                myCell.fillColor = myDoc.swatches.item("aswatchthatdoesntexist");
                myCell.fillColor

                 

                Run this second:


                myCell = app.selection;
                myCell.fillColor