2 Replies Latest reply on Mar 31, 2010 3:46 PM by pbear*

    Setting the property Pattern Length for Dashed/DottedStrokeStyle [JS CS4]

    pbear* Level 1

      I have attempted to create a custom stroke style. There is a property in the interface called Pattern Length which doesn't seem to have a counterpart in the InDesign CS4 (6.0) Object Model (DashedStrokeStyle entry):


      Style as created in InDesign:


      My code. First part to try and read a style's properties and see what InDesign uses (I know it's Dotted vs. Dashed, but the properties for these two types follow the same paradigm). Second part to create a custom style:

      var thisDoc = app.activeDocument;
      var thisPage = thisDoc.pages[0];

      // Reading an existing style:
      var thisPremadeStrokeStyle = thisDoc.dottedStrokeStyles.item("Crazy Dots");

      // outputs: resolve("/document[@name=\"test strokes.indd\"]/

      // outputs: dotted-stroke-style[@name=\"Crazy Dots\"]")

      // outputs: [object DottedStrokeStyle]

      // outputs: undefined

      // Writing a new custom stroke style
      thisDoc.dashedStrokeStyles.add({name:"Crazy Dashes"});
      var thisNewStrokeStyle = thisDoc.dashedStrokeStyles.item("Crazy Dashes");

      //thisNewStrokeStyle.patternLength = "0.5i";
      //   Object does not support the property or method "patternLength"
      //thisNewStrokeStyle.length = "0.5i";
      //   Object does not support the property or method "length"
      //thisNewStrokeStyle.range = "0.5i";
      //   Object does not support the property or method "range"
      // ???
      thisNewStrokeStyle.dashArray = [0,0.0625, 0.125,0.125, 0.375,0.125];
      thisNewStrokeStyle.strokeCornerAdjustment = StrokeCornerAdjustment.DASHES_AND_GAPS;


      Style as created with the above code:


      The document I want to make is done entirely programmatically. I'm willing to create the styles in InDesign first, export to a StrokeStyles file and import back again to a programmatically created document (though there are problems with that approach), but wanted to see if there was some other solution first.