This content has been marked as final.
Show 2 replies
-
1. Re: Is there a script that will generate Index Markers based on Notes?
-hans- Feb 1, 2013 10:58 AM (in response to davehaigh)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[l]; allNotes = currStory.notes; n = allNotes.length; while(n--){ currNote = allNotes[n]; //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) } } -
2. Re: Is there a script that will generate Index Markers based on Notes?
-hans- Feb 2, 2013 1:58 AM (in response to -hans-)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[l]; allNotes = currStory.notes; n = allNotes.length; while(n--){ currNote = allNotes[n]; 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

