Copy link to clipboard
Copied
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");
$.writeln(thisPremadeStrokeStyle);
// outputs: resolve("/document[@name=\"test strokes.indd\"]/
$.writeln(thisPremadeStrokeStyle.toSource());
// outputs: dotted-stroke-style[@name=\"Crazy Dots\"]")
$.writeln(thisPremadeStrokeStyle.getElements());
// outputs: [object DottedStrokeStyle]
$.writeln(thisPremadeStrokeStyle.getElements().properties);
// 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.
It may not just be a coincidence that your 0.0625+0.125+0.125+0.375+0.125 adds up to 0.8125?
I'm thinking, if you enter those values in the UI and then change 0.1825 to its double value 0.3625, you will see your individual array values will have doubled as well.
Copy link to clipboard
Copied
It may not just be a coincidence that your 0.0625+0.125+0.125+0.375+0.125 adds up to 0.8125?
I'm thinking, if you enter those values in the UI and then change 0.1825 to its double value 0.3625, you will see your individual array values will have doubled as well.
Copy link to clipboard
Copied
InDesign CS4 (6.0) Object Model says:
The pattern of dashes and gaps, in the format [dash length1, gap length1, dash length2, gap length2]. Define up to ten values.
That was it. I guess this is a place where the visual interface diverges from the javascript interface. I was expecting "Start" "Length" as in the dialog. Thanks!
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more