Copy link to clipboard
Copied
I need a way to generate index markers/entries within InDesign based on content that has been added in InCopy. I need this becasue InCopy users can't add Index Markers. One type of content they can add is Notes. Can I use these to generate index markers?
N.b. I have figured a way for InCopy users to add character styles to words I can then generate a simple keyword index based on these. However I now need to be able to cater for sub level topics, cross references to other topics in the index and equivalent terms, and the character style method won't suffice.
Any advice/tips on other methods to create indexes based on IC content would be useful.
Thanks
I'm using InCopy CS6 and InDesign CS6.
Copy link to clipboard
Copied
Hi,
well let's say your notes contents includes the word that follows the note (which should get a topic in the index) you could act like this example:
var currDoc = app.activeDocument,
allStories = currDoc.stories,
l = allStories.length;
//adding a index cause I don't have one 😉
currDoc.indexes.add();
while(l--){
currStory = allStories
; allNotes = currStory.notes;
n = allNotes.length;
while(n--){
currNote = allNotes
; //get InsertionPoint of the note
iP = currNote.insertionPoints[0];
//get the topic = note contents
nC = currNote.texts[0].contents;
//add topic to index
currTopic = currDoc.indexes[0].topics.add(nC);
//add pageReference to source which is iP
currTopic.pageReferences.add(iP)
}
}
Copy link to clipboard
Copied
Me again 😉
couldn't test with InCopy but I hope those lines will create a note if some text is selected. contents of the note = the selected text. create a shortcut to the script.
#target InCopy
try{
currSel = app.selection[0];
currContent = currSel.texts[0].contents;
newNote = currSel.parentStory.notes.add(LocationOptions.BEFORE, currSel.insertionPoints[0]);
newNote.texts[0].contents = currContent;
}catch (e){
alert(e)
}
changed the first script slightly. Note it's still just a example of how it could work:
var currDoc = app.activeDocument,
allStories = currDoc.stories,
l = allStories.length;
//checking for at least one existing index ...
if(!currDoc.indexes[0].isValid){
currDoc.indexes.add();
}
while(l--){
currStory = allStories
; allNotes = currStory.notes;
n = allNotes.length;
while(n--){
currNote = allNotes
; noteContents = currNote.texts[0].contents
//create the source
currSource = currStory.characters.itemByRange(currNote.insertionPoints[0].index, currNote.insertionPoints[0].index + noteContents.length);
currTopic = currDoc.indexes[0].topics.add(noteContents);
//this is by default PageReferenceType.CURRENT_PAGE ... changes optionally
currTopic.pageReferences.add(currSource)
currDoc.indexes[0].update();
currNote.remove();
}
}
Hope it'll be of some help
Hans-Gerd Claßen