6 Replies Latest reply on Jul 22, 2009 2:36 PM by Laubender

    JS CS4: strokeDashAndGap question

    John Kallios Level 2

      var myOutsideGuide_Left = app.activeDocument.pages[0].graphicLines.add (app.activeDocument.layers.item ("Die"));
      myOutsideGuide_Left.geometricBounds = ["0 in", "3 in", "10 in", "3 in"];
      myOutsideGuide_Left.strokeDashAndGap = ["3 p", "3 p","3 p","3 p"];
      myOutsideGuide_Left.strokeColor = app.activeDocument.colors.item("Black");

       

      "myOutsideGuide_Left.strokeDashAndGap = ["3 p", "3 p","3 p","3 p"];" this line errors out and I'm stumped at what I'm missing.

       

      Insight is greatly appreciated.

       

      Thank you,

       

      John

        • 1. Re: JS CS4: strokeDashAndGap question
          [Jongware] Most Valuable Participant

          myOutsideGuide_Left.strokeType = "Dashed";

           

          It seems you can only set the dash properties if the line is tagged as 'being dashed' in the first place!

          • 2. Re: JS CS4: strokeDashAndGap question
            John Kallios Level 2


            Thank you very much for taking the time to help with novice questions. It is greatly appreciated.

             

            To recap:

             

            (the following is for other uninitiate like me)

            var myOutsideGuide_Left = app.activeDocument.pages[0].graphicLines.add (app.activeDocument.layers.item ("Die"));
            myOutsideGuide_Left.geometricBounds = ["0 in", "3 in", "10 in", "3 in"];
            myOutsideGuide_Left.strokeType = "Dashed";
            myOutsideGuide_Left.strokeDashAndGap = ["3 p", "3 p","3 p","3 p"];
            myOutsideGuide_Left.strokeColor = app.activeDocument.colors.item("Black");

             

            Not using "myOutsideGuide_Left.strokeDashAndGap = ["3 p", "3 p","3 p","3 p"];" will use the default of whatever dash and gap is recorded in the stroke palette "Dashed" setting.

             

            Thanks again for the help!

            • 3. Re: JS CS4: strokeDashAndGap question
              [Jongware] Most Valuable Participant
              ... whatever dash and gap is recorded in the stroke palette "Dashed" setting ..

               

              I was wondering about that. This will still fail on other language versions of InDesign (because "Dashed" will be "Gestrichelt" or something like that), but I can only find one way of setting a line to a dashed style without knowing the name: loop over all stroke styles and use the first one that has a property "dashArray". Seems a bit ... troublesome?

              • 4. Re: JS CS4: strokeDashAndGap question
                Laubender Adobe Community Professional & MVP

                Hi, Jongware!

                 

                $ID/

                 

                does it:

                 

                myOutsideGuide_Left.strokeType = "$ID/Dashed";

                 

                I tested that line on a German version of InDesign CS4 6.0.3 and InDesign CS3 5.0.4 on Mac OS X 10.5.7.

                Without "$ID/" there was an error.

                 

                Greetings,

                 

                Uwe

                • 5. Re: JS CS4: strokeDashAndGap question
                  [Jongware] Most Valuable Participant

                  Hi Uwe,

                   

                  Thanks for posting that! It seems this invokes the built-in auto-translator, and having an English version only, no way I could have found that out, or even could've checked if it worked ...

                   

                  Theun (aka [Jongware])

                  • 6. Re: JS CS4: strokeDashAndGap question
                    Laubender Adobe Community Professional & MVP

                    Hi, Theun!

                     

                    Search for "$ID/" or "Localization" in the pdf or html-documentation of the InDesign CS4 SDK:

                     

                    Feature development with Scripting.pdf

                    p12 "Localization"

                     

                    or to clarify the issue:

                    ar42s03s05.html

                     

                    see also:

                    idml-specification.pdf

                    p224 "IDML Example 62. Default StrokeStyles"

                     

                    Greetings,

                    Uwe