The function I use takes around 0.2 secs to create the style if it doesn’t exist and around .08 secs if it does:
var doc = app.activeDocument;
var ps = makeParaStyle(doc, "myDat", "dat1@A@B@C")
ps.properties = {fillColor:"Black", fillTint:50}
$.writeln($.hiresTimer * .00000001)
//0.19232576 sec if the style does not exist
//0.08543395 sec if the style already exists
/**
* Makes a new named group and paragraph style
* @ param the document to add the group and style to
* @ param group name
* @ param style name
* @ return the new aragraph style
*/
function makeParaStyle(d, gn, n){
var g;
if (d.paragraphStyleGroups.itemByName(gn).isValid) {
g = d.paragraphStyleGroups.itemByName(gn);
} else {
g = d.paragraphStyleGroups.add({name:gn});
}
if (g.paragraphStyles.itemByName(n).isValid) {
return g.paragraphStyles.itemByName(n);
} else {
return g.paragraphStyles.add({name:n});
}
}
... View more