Skip to content

Instantly share code, notes, and snippets.

@grefel
Created November 18, 2014 10:34
Show Gist options
  • Save grefel/3025f947c8c916603f27 to your computer and use it in GitHub Desktop.
Save grefel/3025f947c8c916603f27 to your computer and use it in GitHub Desktop.
Get String path for an #InDesign Style
var root = app.activeDocument;
var styleString = getStyleString(app.selection[0].appliedObjectStyle);
$.writeln(styleString);
function getStyleString(style) {
var nameArray = [style.name.replace(/:/g, '\\:')];
while (style.parent.constructor.name.indexOf("StyleGroup") > -1) {
style = style.parent;
nameArray.push(style.name.replace(/:/g, '\\:'));
}
if (nameArray.length == 1) return nameArray[0];
nameArray.reverse();
return nameArray.join(":");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment