Note的parent或storyOffset属性的类型取决于注释是从Text还是从Story获得的。为什么?在不知道它来自哪里的情况下,如何在Note上干净利落地处理这个问题?
以下脚本暴露了这种情况。
// INDESIGN CS6 8.1 VERSION
var doc = app.documents.add();
doc.pages.item(0).textFrames.add();
var story = doc.stories[0];
story.insertionPoints[0].contents = "x";
story.insertionPoints[0].notes.add();
var range = story.texts.itemByRange(story.characters.item(0),
story.characters.item(1));
alert( story .notes[0].parent.constructor.name); // "InsertionPoint"
alert( range .notes[0].parent.constructor.name); // "Array"
alert( story .notes[0].storyOffset.constructor.name); // "InsertionPoint"
alert( range .notes[0].storyOffset.constructor.name); // "Array"// INCOPY CS6 8.1 VERSION
app.documents.add();
var story = app.selection[0].parentStory;
story.insertionPoints[0].contents = "x";
story.insertionPoints[0].notes.add();
var range = story.texts.itemByRange(story.characters.item(0),
story.characters.item(1));
alert( story .notes[0].parent.constructor.name); // "InsertionPoint"
alert( range .notes[0].parent.constructor.name); // "Array"
alert( story .notes[0].storyOffset.constructor.name); // "InsertionPoint"
alert( range .notes[0].storyOffset.constructor.name); // "Array"发布于 2016-04-29 21:26:40
你必须测试你想要处理的每个父构造函数。有关Text对象的类层次结构,请参见documentation。例如,使用如下函数:
var isText = function(text) {
var c = text.constructor;
return c === Paragraph || c === Line || c === Word
|| c === Text || c === TextStyleRange || c === Story
|| c === InsertionPoint || c === TextColumn;
}
isText(story.notes[0].parent) // => truehttps://stackoverflow.com/questions/36568224
复制相似问题