Copy link to clipboard
Copied
Sometimes I need to use an old indesign document to make another book. It is easy and fast. You do not need to define footnotes, running headers, master pages etc.
I always have the problem with books that had index inside.
It is easy to remove an old text from the document and fill in a new text.
But if an old document had index, such reference like "see" "see also" etc. still remains unremoved (undeleted).
The are stil listed in the index palette.
And I don't know how can I remove them automatically from my old document before I import a new text to it.
Probably someone of you can write such simple script which can remove all index reference (or particularly such as "see" and see also") from the empty InDesign document.
I mean empty indesign document that is document without body text inside.
Thank you in advance for your help and sorry for my poor English.
try {
app.activeDocument.indexes[0].topics.everyItem().remove();
} catch (_) {
}
Copy link to clipboard
Copied
try {
app.activeDocument.indexes[0].topics.everyItem().remove();
} catch (_) {
}
Copy link to clipboard
Copied
Thank you very much Peter, it is works.
And thank you for all your scripts which help me a lot in my everyday work.
Best regards!
Copy link to clipboard
Copied
app.activeDocument.indexes[0].topics.everyItem().remove();works very well to remove() every topic – at the first level.
But how to remove a topic at the second level (subtopic).
With the following code I fail to remove a subtopic.
#target InDesign
main();
function main()
{
var _index = (app.documents.firstItem().indexes.length > 0) ? app.documents.firstItem().indexes.firstItem() : app.documents.firstItem().indexes.add();
_index.topics.add({name:'topic'});
_index.topics.itemByName('topic').topics.add({name:'subtopic'});
if (_index.topics.itemByName('topic').topics.itemByName('subtopic').isValid)
try
{
// no success
_index.topics.itemByName('topic').topics.itemByName('subtopic').remove();
//~ _index.topics.firstItem().topics.firstItem().remove();
//~ _index.topics.firstItem().topics.everyItem().remove();
// success
//~ _index.topics.everyItem().remove();
//~ _index.topics.itemByName('topic').remove();
}
catch(e)
{
alert( e);
}
}
How to remove 'unused' subtopics (such with no topics and no references) only?
Martin
Copy link to clipboard
Copied
Hi Martin,
I'm afraid it's an old (mis)known issue: http://forums.adobe.com/message/3832867#3832867
@+
Marc
Copy link to clipboard
Copied
Hi Marc,
Way, way, way off the topic but ..
Can you have a look at my generic function
checkForObjectByLabel
in this post http://forums.adobe.com/message/6138724#6138724 and let me know if you would have done in significantly different
Thanks
Trevor
Copy link to clipboard
Copied
Hi Marc,
thank you.
So we will have to live with all those dead (sub)topics.
Martin
Copy link to clipboard
Copied
Hi Martin,
The laborious workaround is to re-create the topic without the subtopic. If you really really want to get rid of those unused second-level topics, and I know you do, then that's the way to do it.
Peter
Copy link to clipboard
Copied
Dear Peter,
ah, an interesting workaround.
I will have to think about it.
But it will dryving me crazy. 😉
From a csv-file I have to add many crossreferences to topics and these crossreferences have to get a sort order (as the customer likes it).
These 'sorted' crossreferences are realized by adding subtopics to the related topic with zero-width-space (\u200B) as their name.
To these unvisible suptopics (for the crossreferences) a sortorder can get applied.
Before the crossreferences are added from a csv-file once again, the earlier added crossreferences – and so the subtopics – should be removed.
That will take an effort with your approach because
first there are a lot of subtopics for crossreferences with zero-width-space that should be removed and
second there are a lot of subtopics for pagereferences of the parent topic that should be kept untouched.
Thank you
Martin
Copy link to clipboard
Copied
Just to make sure that I understand correctly. Without intervention, cross-references would be sorted like this:
HDS moderators
see G. Singelmann
see M. Fischer
But what you want is this:
HDS moderators
see M. Fischer
see G. Singelmann
Is that the idea?
Peter
Copy link to clipboard
Copied
Not quite ...
In your 'limping' example 😉
HDS moderators
→ M. Fischer
→ H. Haessler
U. Plattner 8, 12, 21
K. Rübsamen 1, 12, 27
→ G. Singelmann
Chr. Steffens 17, 19, 29
see also anybody
see also people
see also unknown mod
There are different types of crossreferences.
Some crossreferences are grouped like in your example with no subtopic for pagereferences between them.
But sometimes certain crossreferences should be placed in order to other subtopics (with pagereferences).
The präfix of the sorted crossreferences will be different from that one of the 'normal' crossreferences (here '→' and 'see also').
Martin
Copy link to clipboard
Copied
Oh, I see. A workaround could be the following:
1. Add a text frame somewhere, can be on any document page. Give it a name (say, 'xrefs') so you can find it easily later.
2. Add the special cross-references (Fischer, Haessler, Singelmann) by creating normal page references in that text frame 'xrefs'.
3. When you're ready to generate the index, add a page at the end of the document. Store the page number.
4. Move the 'xrefs' text frame to the last page.
5. In the paragraph style used for the index, add a GREP style that hides that page number (by applying a character style that sets 0.1 points type size and 1% horizontal scale).
6. Generate the index.
7. Delete the 'xrefs' frame.
By deleting the 'xrefs' frame, those topics become unused for InDesign, and you can now use the Index panel's 'Remove Unused Topics' function:
app.menuActions.itemByID(78087).invoke();
Peter
Copy link to clipboard
Copied
What an interesting approach!
But it would be a lot of work for me now to rebuild the complete script.
The script works very well for me and my customer and the only thing I have been looking for is a solution to delete the unused topics (see above).
So I like your last line:
app.menuActions.itemByID(78087).invoke();
Oh my, I should have seen it before.
This all I need at this time.
Thank you very much!
Martin
Copy link to clipboard
Copied
Dear Peter,
It looks like the topics-palette needs to get the focus before it is possible to invoke that menu action.
But why not take use of the indexes command removeUnusedTopics() instead? 😉
That works pretty good.
Martin
Copy link to clipboard
Copied
> But why not take use of the indexes command removeUnusedTopics() instead?
Indeed, why not! Hadn't realised it was there. Thanks for pointing that out.
Peter
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more