4 Replies Latest reply on Jul 2, 2016 2:27 AM by CarlosCanto

    StrokeDashes... possible in vbscript?

    clutch-cargo

      After several days researching all I could on adding dashes via a script I came up with no definitive answer.  So is it possible?  Has anyone got dashes to work in ascript?  After many trial-n-errors, what I have concluded (and hopefully I am wrong) is:

      1. Not possible to create dashes using an Action.

      2. Not possible to create dashes using an a Graphics Style (when using the Graphic Style in a script)

      3. No effect using something like 'CurrentPath.StrokeDashes = [15,10,13,8,9]' (nothing happens)

       

      The only thing that looked promising was Carlos stated back in 2014 :

       

      '  yes, before you start making paths, set the default stroke like this

      var idoc = app.activeDocument; 

      var ipath = idoc.selection[0]; // select your path 

      alert(ipath.strokeDashes.toSource()); // read the current dash/gap settings 

      ipath.strokeDashes = [2,3,2,1]; // change it to your needs 

       

      idoc.defaultStrokeDashes = [2,3,2,1];

       

      So Carlos, if this indeed works do you have an equivalent for vbscript?  I am not actually creating paths but editing paths already that have been created if that makes a difference.  Again, using VBscriupt with Illustrator CS6.

       

      Any help, suggestions would be most appreciated!

        • 1. Re: StrokeDashes... possible in vbscript?
          Silly-V Adobe Community Professional

          Actually, you can use an action to apply dashes. Record a stroke-setting action and dissect the .aia file you save for the necessary string. Here is a screenshot of such an action recorded, as well as the .aia string with some of the items I've decoded using a hex-decoder such as here: Convert Hexadecimal To String Online

          The implementation of this working yet convoluted approach is to construct this string dynamically using your script and to use the action-loading/playing functions to load, play and potentially discard these actions.

          2016-07-01 14_47_39-Untitled-5_ @ 347% (RGB_GPU Preview).png2016-07-01 14_45_57-.png

           

          And here is this action's .aia string:

           

          /version 3

          /name [ 4

            54657374 (Test)

          ]

          /isOpen 1

          /actionCount 1

          /action-1 {

            /name [ 6

            446173686573 (Dashes)

            ]

            /keyIndex 0

            /colorIndex 0

            /isOpen 1

            /eventCount 1

            /event-1 {

            /useRulersIn1stQuadrant 0

            /internalName (ai_plugin_setStroke)

            /localizedName [ 10

            536574205374726f6b65 (Set Stroke)

            ]

            /isOpen 1

            /isOn 1

            /hasDialog 0

            /parameterCount 10

            /parameter-1 {

            /key 2003072104

            /showInPalette -1

            /type (unit real)

            /value 1.0

            /unit 592476268

            }

            /parameter-2 {

            /key 1667330094

            /showInPalette -1

            /type (enumerated)

            /name [ 8

            4275747420436170 (Butt Cap)

            ]

            /value 0

            }

            /parameter-3 {

            /key 1836344690

            /showInPalette -1

            /type (real)

            /value 10.0

            }

            /parameter-4 {

            /key 1785686382

            /showInPalette -1

            /type (enumerated)

            /name [ 10

            4d69746572204a6f696e (Miter Join)

            ]

            /value 0

            }

            /parameter-5 {

            /key 1684825454

            /showInPalette -1

            /type (integer)

            /value 3

            }

            /parameter-6 {

            /key 1685284913

            /showInPalette -1

            /type (unit real)

            /value 12.0

            /unit 592476268

            }

            /parameter-7 {

            /key 1685284914

            /showInPalette -1

            /type (unit real)

            /value 4.0

            /unit 592476268

            }

            /parameter-8 {

            /key 1685284915

            /showInPalette -1

            /type (unit real)

            /value 12.0

            /unit 592476268

            }

            /parameter-9 {

            /key 1684104298

            /showInPalette -1

            /type (boolean)

            /value 0

            }

            /parameter-10 {

            /key 1634494318

            /showInPalette -1

            /type (enumerated)

            /name [ 6

            43656e746572 (Center)

            ]

            /value 0

            }

            }

          }

          • 2. Re: StrokeDashes... possible in vbscript?
            clutch-cargo Level 1

            Well I must admit Silly. This is a very creative work-around you suggest here.  I recorded my needed action, and saved the .aia file.  I popped it into Notepad++ and it looks very similar to yours.  But here I need some clarification:

             

            1. Should I just plug this into my script and it will work?

            2. I am using VBscript.  I take it this would need to be converted or is there a way to tell VBscript to now use javascript at that point?

            2. The purpose of the Hex to String is to merely see what I have or must I actually convert parts of it before I can use it as part of my script?  When I dropped it into the app it just me a ton of "???'s".  Obviously don't know what I am doing here, ha!

            • 3. Re: StrokeDashes... possible in vbscript?
              Silly-V Adobe Community Professional

              Let me try to answer:

               

              1.To plug this into your script, I believe you can store the entire string as a variable and replace only certain parts in it that you need. In case of the dashes information, this is more 'advanced' than I've ever cared to go for until now, so I'm not sure what all the stuff there means. But you can pretty much tell that these parts are all of the stuff having to do with the dashes in my particular example:

              /parameter-5 { ( 3 dashes , # on end of parameters increases by 1 )

                /key 1684825454

                /showInPalette -1

                /type (integer)

                /value 3

                }

                /parameter-6 { ( 1st dash )

                /key 1685284913 ( this number increases by 1 )

                /showInPalette -1

                /type (unit real)

                /value 12.0

                /unit 592476268 ( this unit stays the same )

                }

                /parameter-7 { ( 1st gap )

                /key 1685284914

                /showInPalette -1

                /type (unit real)

                /value 4.0

                /unit 592476268

                }

                /parameter-8 { ( 2nd dash )

                /key 1685284915

                /showInPalette -1

                /type (unit real)

                /value 12.0

                /unit 592476268

                }

              You'd just have to construct this whole thing like you need, and then write it to the file system, and then make Illustrator read it.

               

              2. I don't know VBScript very well, and know nothing of the VBScript commands, but I think they can load and play actions - I think they used to be only able to do so in Applescript and VBScript until JS came added with the ability in CS6.

               

              3. I just wanted to explain the hex string is in hex format because if you make your own action string, you may one day need to be able to create this as part of your workflow. Otherwise it's just so you can compare and tell what you see in the actions panel with the stuff in the text editor. Another thing with those encoded string names is the number immediately above them in their block will have the integer number of the characters expected to be found in the string. So in this case:

              /localizedName [ 10

                536574205374726f6b65

                ]

              the encoded word is "Set Stroke" which is comprised of 10 characters.

              And, the stuff I put into ( parentheses bold ) is just my own notes, and in no way belong inside the action string.

              • 4. Re: StrokeDashes... possible in vbscript?
                CarlosCanto Adobe Community Professional & MVP
                3. No effect using something like 'CurrentPath.StrokeDashes = [15,10,13,8,9]' (nothing happens)

                the above snippet works perfectly here...in javascript.

                 

                if you want to use vb, the equivalent is

                CurrentPath.StrokeDashes = Array(15, 10, 13, 8, 9)