Copy link to clipboard
Copied
Hi. I'm trying to stop InDesign from updating styles that are based on other styles while a Javascript is running, but I have no idea how (or even if it can be done).
I need to increase the point size of a couple hundred paragraph styles in one document and have written a Javascript that successfully does so. However, the problem I'm running into is that when Style A is updated, it's point size is changed to the same point size of Style B, the paragraph style on which Style A is based. When the Javascript goes on to update Style B, that change populates down to Style A because they no longer differ. Here's a specific case to clarify.
Style TX is 10 point.
Style BI is based on style TX but is point 9 point instead of 10.
Javascript changes BI to 10 point, thus effacing the 9-point/10-point discrepancy.
Javascript changes TX to 11 point.
Because BI is based on TX and because their point sizes no longer differ, InDesign changes BI to 11 also.
I need to prevent that last step. Does anyone know if it's possible to prevent InDesign from populating changes in a style to other styles that are based upon it?
Thanks for any help.
Copy link to clipboard
Copied
The whole idea of "based on" is to auto-update changes 😉
You have pretty much have 2 options:
Or maybe 3rd option - don't set whole numbers but 9.1 and then go again and remove ".1"? To be on a safe side - do ".1" as a counter - ".01", ".02"... so you won't have to check Based On.
But I think going from childrens to parents would be the best option.
Copy link to clipboard
Copied
Thanks for your thoughts!
Yeah, I understand the purpose of "based on"; that's why I used it when I built the templates, which are incredibly complex. The options you suggest had occurred to me, but I'm hoping there's an easier way. Re: 1, the only way I can think to unlink and then relink the based-ons is to build an array to store the based-on values for all 238 styles. If I'm going to go to that trouble, I might as well just create an array of point sizes and then drop those into the style definitions. (I'd have to start with the parents, though, and work down through the chains; if I change the children first, I'll end up with the same problem I have in the BI/TX example above. Re: 2, this would be incredibly unwiedly, unfortunately. Some of the styles have based-on chains two or more levels deep.
At some point, InDesign has to say to itself, "Aah. The point size for TX changed, so I need to change the point size for everything based on it that shares the same point size." If I can suspend that action until after the script is finished, the whole problem goes away.
Sounds, though, like that's too low of a level in the code to access. Sigh. I may just have to do it manually. At least I got some experience writing a Javascript.
Copy link to clipboard
Copied
Yeah, option 2. would be probably quite complicated in JavaScript - but it's extremely simple in VB6.
So you are left with an array of 238 Based On values or point sizes option.
But let's go back to the basics 😉 what is your goal? What are you trying to achieve?
Copy link to clipboard
Copied
I see the option to work not with full point sizes.
Instead of doing changes from 9 Pt. to 10 Pt., do a change to 10.001 perhaps.
Use a unique value for every change like 10.001, 10.002 and so on.
Visibly there is no difference to 10 Pt.
Just an idea, did no tests for this.
Regards,
Uwe Laubender
( Adobe Community Expert )
Copy link to clipboard
Copied
I've already suggested that...
Copy link to clipboard
Copied
Yes. But the difference in point sizes should be much more lower.
You'll see a difference in text composition when you work with e.g. 10.1 Pt instead of 10.0.
Not so much or not at all when you work with more subtle values like 10.001 instead of 10.0.
Regards,
Uwe Laubender
( Adobe Community Expert )
Copy link to clipboard
Copied
But this small difference is just temporary - to avoid instant updates - and would be reversed.
If you leave it like that it will force InDesign to do extra math all the time - and if you don't also change baseline value to a constant instead of Auto - it will have a knock-on effect...
Copy link to clipboard
Copied
Hi, and thanks to you both. I appreciate the ideas. I have to set this aside for a family emergency, but I will get back to it and try out your suggestions.
To answer your question, AdobeScripts, I have developed and maintaine a set of templates that I use to typeset a series of books for one client. I've set up their styles to accommodate paragraphs of left-to-right languages, paragraphs of right-to-left languages, and paragraphs that mix the two, so they're quite complex, and the relationships among the styles are a bit tangled. We want to change the typeface, but the new font has a smaller x-height, so to make the text easier to read, I need to bump up by 110% the point size of every style using the new font. I do not, however, want weird fractional point sizes, so I'm rounding to the nearest 1/4 point. Almost every style is based on another style, and most of the time, this makes it easier to update the templates when I need to do so. In this case, however, that style linking is creating the dilemma I describe above.
Copy link to clipboard
Copied
Hoiw about changing the order in which you update the styles in the script? Chqange the base style first, then the ones based on it.
Copy link to clipboard
Copied
Yeah, already suggested - but in JS it would be a bit complicated.
Copy link to clipboard
Copied
sorry, I missed that.
Copy link to clipboard
Copied
I appreciate everyone's thoughts. In the end, though, I couldn't come up with a way to do it that wasn't a nightmare, so I cheated.
Probably no one cares, but I saved the file as an IDML, opened that in BBEdit, found the style definitions among the XML data, copied them, pasted them into Word, wrote a VBA script to find all the pointSize values and recalculate them, copied the edited text, and pasted it back into the IDML. Once I knew the corrected file would open and that the sizing was correct, I pulled the style definitions into my original InDesign file, replacing the style defs there with the incoming defs.
I'll have to do that two more times (for two more templates), and it takes longer than a script would, but it's still faster and more accurate than changing the point sizes manually, and I learned some scripting along the way, so not a bad return after all.
Copy link to clipboard
Copied
It's not cheating 😉 it's very clever way to resolve the problem 😉