CreativePro Forum
Join our community of graphic designers, publishers, and production artists from around the world. Our members-only forum is a great place to discuss challenges and find solutions!
- You must be logged in to reply to this topic.Login
Clear Overrides Throughout Document on Particular Object StyleObject
Tagged: clear overrides, javascript, object style
- This topic has 27 replies, 9 voices, and was last updated 5 years, 2 months ago by
Rombout Versluijs.
-
AuthorPosts
-
-
May 12, 2017 at 9:34 am #94594
Masood Ahmad
ParticipantHi,
I was looking for a JavaScript that can remove the Overrides throughout the InDesign Document on a particular Object Style.
Let’s say I have an Object Style named: “myDropShadow”, applied to multiple frames and images throughout the Document. Some of these elements have manual overrides done by a user. I would like to use the Script to remove any manual overrides for my shadow object style.
While searching the net, I got this JavaScript from ID-Extras.com:
// Clear All Overrides
// Written by TAW. (c) 2014 by Bookraft Solutions, Israel (Id-Extras.com)
// Please do not delete this copyright notice.
//
var myOverrideType = OverrideType.ALL;
// var myOverrideType = OverrideType.CHARACTER_ONLY;
// var myOverrideType = OverrideType.PARAGRAPH_ONLY;
var allStories = app.activeDocument.stories.everyItem();
// Remove overrides from all stories
try{
allStories.clearOverrides(myOverrideType);
}
catch (e){alert ("No stories!")}
// Remove overrides from all footnotes
try{
allStories.footnotes.everyItem().texts.everyItem().clearOverrides(myOverrideType);
}
catch (e){alert ("No footnotes!")}
// Remove overrides from all table
try{
allStories.tables.everyItem().cells.everyItem().paragraphs.everyItem().clearOverrides(myOverrideType);
}
catch (e){alert ("No tables!")}
alert("Overrides cleared!");This works but only on the Character/Paragraph Styles.
There is a discussion here as well but that too covers the text styles:
https://creativepro.com/remove-all-local-formatting-globally.phpCan anyone help me tweak this script to work on a particular object style.
Thanks in advance.
-
May 12, 2017 at 10:04 am #94596
Chad Beery
ParticipantYou can use Object Find/Change to do this by looking for the object style and replacing it with the same style.
-
May 12, 2017 at 10:29 am #94600
Masood Ahmad
ParticipantHi Chad, Thanks for reminding me of that. Is this somehow be scripted?
-
May 12, 2017 at 10:41 am #94602
Chad Beery
ParticipantI’m guessing it could be but my script writing skills are limited.
-
-
May 12, 2017 at 11:09 am #94605
Masood Ahmad
ParticipantNo issues Chad,we are on the same boat.
Can anyone provide me a one-liner script to achieve the goal.
-
May 12, 2017 at 11:44 am #94607
Kai Rübsamen
MemberThis cannot be done with one line.
var oStyle = app.activeDocument.objectStyles.itemByName("b"); app.findObjectPreferences = app.changeObjectPreferences = null; app.findObjectPreferences.appliedObjectStyles = oStyle; var fund = app.activeDocument.findObject(); app.findObjectPreferences = app.changeObjectPreferences = null; for (var f = 0; f < fund.length; f++) { fund[f].applyObjectStyle(oStyle, true); }
-
May 12, 2017 at 3:02 pm #94628
Michel Allio for FRIdNGE
ParticipantHi Kai,
Sure? =D
var O = app.activeDocument.pageItems.everyItem().getElements(), S = app.activeDocument.objectStyles.item(“s”), P = O.length; while (P–) if (O[P].appliedObjectStyle == S) O[P].applyObjectStyle(S);
One-single-line Script!
(^/)
Masood: I see you saw my comment about for free scripts! =D
-
May 12, 2017 at 3:07 pm #94629
Michel Allio for FRIdNGE
ParticipantShorter:
var D = app.activeDocument, O = D.pageItems.everyItem().getElements(), S = D.objectStyles.item(“s”), P = O.length; while (P–) if (O[P].appliedObjectStyle == S) O[P].applyObjectStyle(S);
(^/) =D
-
May 13, 2017 at 2:32 am #94631
Kai Rübsamen
MemberMichel, a line is determinated at least by a “;” So your short line have 2 lines ;-)
But: The goal in scripting is, to write readable scripts. If this is your style, putting everything in one line, avoid the use of parentheses, then this is no good practice.
And: If you work with pageItems.everyItem(), you will not get every items!
Kai
-
May 14, 2017 at 5:46 am #94638
Michel Allio for FRIdNGE
ParticipantHi Kai,
1/ It’s your personal interpretation of what is “a line”! No worry for me! ;-)
2/ My code is totally readable! [about this point, I suggest you to take a look to the Great Master Marc Autret’s artwork!]. Especially, not sure adding or not parentheses everywhere would be more preferable! About this, Peter Kahrel wrote: “… many people […] write single lines in brackets […] but this is not needed …” relevant too about line returns!
3/ I’m more interested by a technical discussion about your mention “… if you work with pageItems.everyItem(), you will not get every items! …”: your script won’t find: items on master pages or locked/not visible layers, locked items [and maybe other cases!], not mine!(^/)
PS: Beyond writing its code, concentrate here such a script on 1 line was a joke! … but maybe you have less humour than me! ;-)
-
-
May 14, 2017 at 2:10 am #94637
Masood Ahmad
ParticipantHi Kai, Your code works well. I’ll check it further on the original files. Thanks a lot.
-
February 28, 2018 at 4:23 am #102028
Bruce Johnson
MemberI was looking for a script like this, but i have an additional question: The script works, but only if the object is visible. If it’s an anchored Image which is in overset text area (because it’s too big), the script can’t clear the overrides.
Is it possible to find all items, whether they are “visible” or not?
I need it for a big TOC where anchored images are used next to the text and they are way too big. If i apply an own object style to the images, the style is set, but the size doesn’t change. So the script should clear this to display the object with the correct size. Resizing all frames to make the images visible is not an option.
-
February 28, 2018 at 10:47 am #102032
Kai Rübsamen
MemberBruce, a short test shows, that the script works with image frames in overset too. So you have maybe another problem? How do you set the size of your object? Which version of InDesign?
Kai
-
March 1, 2018 at 8:37 am #102041
Bruce Johnson
MemberI have a text frame with anchored images set to object style “format1”, which sets the object size of the images to 87x87mm. The TOC has a layout with several text frames with 30x30mm for the images. The images there have to be “format2” which sets a size of 30x30mm for the anchored images.
If i load the TOC, the images are there, but not visible (too big) because of “format1”. I use find/change to set the object style to “format2”. “format2” is set, but the size is still 87x87mm. If i use the script, nothing happens, the override is still there. But if i resize the text frame to make the image visible, the script then works.
It’s the same thing like changing the object style per find/change. If the image is visible, everything works. If not, the format is set correctly, but with override. Or is this a bug?
-
March 1, 2018 at 9:51 am #102042
Kai Rübsamen
MemberHm, I’m working here with CC2015, but I could try my new MacBook where CC2018 is installed ;-) I’m not sure, if this is logic, that you can set a size of something only, when it is visible …
Can you built a litle example? 2-3 pages, one or two big pictures in text with format1 and your generated toc …? Sent me your file with your dummy pics to forum@ruebiarts.de
btw.: Do you know, that you can refresh the toc with a script too and could temporarily increase the frame (as Plan B, if Plan A doesn’t work)
Kai
-
July 26, 2018 at 12:41 pm #105099
Rombout Versluijs
MemberIm having this issue with tables. I use linked xlxs files with the sheets linked to text frames with tables inside. When i update the link file it some sets the paragraph style to a different one. It seems like some bug. Prior use the select the correct one before doing the update and than it worked. But know it simple switches to a different one.
I can use Clear All Overrides script, but that destroy my table row styles ive added.
Does someone know a trick to solve this?
-
July 26, 2018 at 1:25 pm #105100
Kai Rübsamen
MemberRombout, I do not understand the problem. Maybe a example before/after would help.
-
July 26, 2018 at 11:30 pm #105103
Rombout Versluijs
MemberOkay here goes.
Ive made a catalogue wich uses excel sheets with set set range values for header info and spec info. All is set with style as for the tables and rows. The problem which is happening is that on each save all links need to be updated.
Somehow since yesterday when i do update all my frame which contain the a table with a certain paragraph style get a new paragraph style. Ive even added object frame styles to try to suppress this and this was working prior.
I get the feeling that when you have nothing selected and go the the paragraph styles in the top menu and pick something it somehow applies this. Prior i used the preselect the proper paragraph style in the styles list and this worked. But now it keeps jumpig to a different one.
Before i update links
https://www.dropbox.com/s/024vl8fu55gt48e/Before.png?raw=1The warning that i loose local edits. Not sure what is wrong with this, because sometimes it doesnt give that warning yet other times it gives it for each and every linked file. There doesnt seem to be standard, even when i havent done any edits i still get this.
https://www.dropbox.com/s/0klz0t1gairtsqj/warning.png?raw=1After i update, see the header called “Banner 510”, in the op right you can see the frame some how gets a different paragraph style. While all is set to paragraph style in the table style options and also in the object frame options.
https://www.dropbox.com/s/muhql84y39pjyjt/after.png?raw=1 -
July 26, 2018 at 11:35 pm #105104
Rombout Versluijs
MemberI notice when i select it and then update it, it gets a different paragraph style. Yet when i dont select it, than it works properly. This is bugging me a lot, it looks like some bug to me.No where is that style it gets set to that frame.
Than once i did the update without selecting any table in a frame. Than it does update all other without issues or assigning a new paragraph style to the frame. Its really weird.
-
July 27, 2018 at 1:42 am #105106
Kai Rübsamen
MemberGood to read, that you find a solution. If you work with table styles, cell styles within a table style, para styles within cell styles and have no overrides on cell styles and table styles, this shouldn’t be a problem.
-
July 27, 2018 at 2:25 am #105107
Rombout Versluijs
MemberThe table doesn’t get changed its the text where the table is placed in. Yet I’ve even added aobject from to these. Also the issue doesn’t happen consistently. When I noticed that selecting nothing didn’t do anything. I then reverted the docdocument and tried again with selecting the frame and than updating it this time it also worked perfect. I than restarted InDesign and redid both steps. This time both if of them worked properly.
But the issue has happened before today. Luckily I’ve applied styles to everything I can think off, so using a clear over override scripts fixes it quickly but still I wonder why certain times it works and other times it doesnt
-
June 14, 2019 at 2:22 pm #117185
Year 1917
Memberi seem to get a error when using any of the above scripts (cc2019)
can someone tell me how to use them, or it simply does not work in this version?thanks
-
June 27, 2019 at 12:02 am #117342
Kai Rübsamen
MemberWhat kind of errror?
-
February 20, 2020 at 1:36 pm #12243973
Rafal Szubinski
MemberHi Kai
When I try to use your script, I’m keep getting this error https://bit.ly/2V6Bd1k. Can you help me to solve this problem?
-
February 20, 2020 at 2:00 pm #12243974
Brian Pifer
ParticipantMake sure whatever is inside quotation marks (“b”) on the following line is an actual named Object Style in your document:
var oStyle = app.activeDocument.objectStyles.itemByName(“b”);
An example of the change would be:
var oStyle = app.activeDocument.objectStyles.itemByName(“myNamedStyle”);
-
February 21, 2020 at 1:07 pm #12432991
Rombout Versluijs
MemberPerhaps if I got time this weekend I can alter the script and make the user ask for style to select from a drop-down. That way you won’t need to alter the script each time. Would be way more convenient wouldn’t it?
-
February 26, 2020 at 7:04 pm #12304369
Rombout Versluijs
MemberSorry almost forgot about it. Is this perhaps more handy?
Ive altered it a bit and now you get a dialog window and you can pick the object style from the dropdownlist. It will then go over all items and clear the overrides.I got another idea by making it more functional by letting the user choose between object-, character- or paragraph-style. That way we got 3 different versions of a script in one :)
Would be nice if this forum had a bit more advanced messaging system and also allowed for image uplaod
-
February 26, 2020 at 7:13 pm #12343070
Rombout Versluijs
MemberTried your “oneliner” but get error because of the comma’s. Thought it could be possible
-
-
AuthorPosts
- You must be logged in to reply to this topic.
