-
1. Re: Please help. How to remove some of index reference?
pkahrel Mar 20, 2013 10:09 AM (in response to olfar)try {
app.activeDocument.indexes[0].topics.everyItem().remove();
} catch (_) {
}
-
2. Re: Please help. How to remove some of index reference?
olfar Mar 20, 2013 11:06 AM (in response to pkahrel)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!
-
3. Re: Please help. How to remove some of index reference?
Martin Fischer Feb 20, 2014 12:18 AM (in response to pkahrel)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
-
4. Re: Please help. How to remove some of index reference?
Marc Autret Feb 20, 2014 12:42 AM (in response to Martin Fischer)Hi Martin,
I'm afraid it's an old (mis)known issue: http://forums.adobe.com/message/3832867#3832867
@+
Marc
-
5. Re: Please help. How to remove some of index reference?
Trevorׅ Feb 20, 2014 1:06 AM (in response to Marc Autret)Hi Marc,
Way, way, way off the topic but ..
Can you have a look at my generic function
checkForObjectByLabelin this post http://forums.adobe.com/message/6138724#6138724 and let me know if you would have done in significantly different
Thanks
Trevor
-
6. Re: Please help. How to remove some of index reference?
Martin Fischer Feb 20, 2014 1:46 AM (in response to Marc Autret)Hi Marc,
thank you.
So we will have to live with all those dead (sub)topics.
Martin
-
7. Re: Please help. How to remove some of index reference?
pkahrel Feb 20, 2014 2:19 AM (in response to Martin Fischer)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
-
8. Re: Please help. How to remove some of index reference?
Martin Fischer Feb 20, 2014 3:05 AM (in response to pkahrel)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
-
9. Re: Please help. How to remove some of index reference?
pkahrel Feb 20, 2014 3:30 AM (in response to Martin Fischer)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
-
10. Re: Please help. How to remove some of index reference?
Martin Fischer Feb 20, 2014 3:53 AM (in response to pkahrel)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
-
11. Re: Please help. How to remove some of index reference?
pkahrel Feb 20, 2014 4:46 AM (in response to Martin Fischer)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
-
12. Re: Please help. How to remove some of index reference?
Martin Fischer Feb 20, 2014 4:58 AM (in response to pkahrel)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
-
13. Re: Please help. How to remove some of index reference?
Martin Fischer Feb 20, 2014 5:19 AM (in response to Martin Fischer)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
-
14. Re: Please help. How to remove some of index reference?
pkahrel Feb 20, 2014 5:24 AM (in response to Martin Fischer)> 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



