Negative strokeDashOffset

2 min readDec 11, 2023

The Stroke panel lets you set the width of dashes and the gap between them. In scripts and plug-ins, there is the strokeDashOffset property that also specifies the start distance. There are no controls for this property in the Adobe Illustrator interface.

The numeric range of strokeDashOffset is not documented, so the developer can use negative values. Sergey Nikolaev found a bug — when expanding dashed strokes with negative offset (Expand or Outline Stroke), a long rectangle appears instead of dashes.

The second problem is that the negative strokeDashOffset is reset to zero when the file is reopened, instead of remaining the number specified in the script. That is, the range is not limited in the ExtendScript, but strokes with an distance less than zero are not saved in a vector file.


For a negative value, you can calculate a positive value by knowing the sum of all dashes and gaps. Visually, the dashed line remains the same, but the file retains the information, and when the stroke is expanded, the rectangles are equal to the dashes.

var obj = app.selection[0];
if (obj.strokeDashOffset < 0){
var total = 0;
for (var i = 0; i < obj.strokeDashes.length; i++) {
total += obj.strokeDashes[i];
while (obj.strokeDashOffset < 0) {
obj.strokeDashOffset += 2 * total;

Replacing a negative value with a positive strokeDashOffset was added to the VectorScribe v5.2.2 plugin by the Astute Graphics and to the Nudge plugin by Rick Johnson. Vote on Uservoice to fix the Illustrator bug.




Sergey Osokin. Product Illustrator, Icon Designer, Script Developer (Ai, Ps). Writing about bugs and tricks in Adobe Illustrator scripts