Copy link to clipboard
Copied
..is there a way to have a one move script to remove auto-sizing on all text frames within an indesign document without selecting the text frames manually?
I personally use auto-sizing for color names and keys when building catalog spreads, but some designers at work complain about it *eye rolls*...so I want to give them a script to alleviate their ‘pain.’
As always any feedback is much appreciated.
Cheers.
Hi Neal,
this one should do it:
var doc = app.documents[0];
var allTextContainers = [];
var allStories = doc.stories.everyItem().getElements();
var allStoriesLength = allStories.length;
for(var n=0;n<allStoriesLength;n++)
{
allTextContainers =
allTextContainers.concat( allStories[n].textContainers );
};
var allTextContainersLength = allTextContainers.length;
for(var n=0;n<allTextContainersLength;n++)
{
if( allTextContainers[n].constructor.name == "TextPath" )
{ continue };
allTextCont
...
Copy link to clipboard
Copied
So far I have the below script that removes auto-size to only one instance of a text frame within a document with many instances of a text frame sporting auto-sizing.
So how can I ‘loop?’ the script to catch every text frame with auto-size on the document and turn it to off?
As always thanks in advance for any feedback....cheers.
- var doc=app.documents[0];
- var po=doc.pageItems[0];
- //copy
- var txt=po.textFramePreferences.autoSizingType =
- AutoSizingTypeEnum.OFF;
- //var txt=po.textFrames.add();
- //txt.visibleBounds=po.visibleBounds;
- //txt.contents="1";
- //txt.paragraphs[0].justification=1667591796 ;
- /*
- myFrame.textFramePreferences.autoSizingType =
- AutoSizingTypeEnum.HEIGHT_ONLY;
- */
Copy link to clipboard
Copied
Hi Neal,
this one should do it:
var doc = app.documents[0];
var allTextContainers = [];
var allStories = doc.stories.everyItem().getElements();
var allStoriesLength = allStories.length;
for(var n=0;n<allStoriesLength;n++)
{
allTextContainers =
allTextContainers.concat( allStories[n].textContainers );
};
var allTextContainersLength = allTextContainers.length;
for(var n=0;n<allTextContainersLength;n++)
{
if( allTextContainers[n].constructor.name == "TextPath" )
{ continue };
allTextContainers[n].textFramePreferences.autoSizingType =
AutoSizingTypeEnum.OFF;
};
CODE EDITED Feb 6, 2020
Why? Because the transfer of this thread to the new Adobe InDesign Forum damaged the code.
Regards,
Uwe Laubender
( ACP )
Copy link to clipboard
Copied
Ha...I think I’ll go with your script just the same.
The one I fashioned together works, but something tells me yours might catch more variables, i.e. unknown situations.
In any case I have both scripts on hand that both deliver the same results so far.
Thanks man, I really appreciate it.
Cheers.
Copy link to clipboard
Copied
Also, how do you get your code posted here formatted in that easier to read fashion with the numbers and the green and grey lines, etc?
Thanks again.
Copy link to clipboard
Copied
..I just accomplished this by piggy backing off a resize script I had previously and came up with the following that worked.
- /* Turn off auto-size on all text frames within a document
- Neal Derek Lawson via snippets from Adobe Forums
- */
- var doc=app.documents[0];
- var po=doc.pageItems;
- for (var i=po.length-1; i>=0; i--) {
- po.textFramePreferences.autoSizingType=AutoSizingTypeEnum.OFF;
- };
Copy link to clipboard
Copied
Hi Neal,
your script will only work with documents where all first level pageItems are text frames ( text frames that are drawn directly to a spread ).
Add one single rectangle to a page and your code will throw an error, because a rectangle has no property textFramePreferences.
Also: Nested text frames e.g. in groups or anchored text frames will not be reached.
Regards,
Uwe
Copy link to clipboard
Copied
Yes, I gathered that soon after replying.
It would have taking me forever, to fashion the end result, after running into those hurdles, i.e. graphic frames, groups, nested/anchors, etc.
I appreciate the speed boost and the accounting for all those obstacles.
One thing, how do you post your code with the formatting I see everyone using (vertical grey/green bar, with white and grey rows, and the code font, etc)?
Thanks again man.
Copy link to clipboard
Copied
Hi Neal,
for code formatting enable the Advanced Editor feature when answering in the forums.
Select your code you copied over, go to >> Insert > Syntax Highlighting > javascript
Regards,
Uwe
Copy link to clipboard
Copied
...thanks so much.
Cheers.
Copy link to clipboard
Copied
Hi, Uwe! I think I have used this script successfully before. Now, when I try to run it, I get an "Undefined is not an object" error. Do you know what causes this?
Copy link to clipboard
Copied
Hi Jorgen,
thank you for your reply. Now I edited the code to something more reasonable.
The transfer of this thread to the new Adobe InDesign Forum damaged the code!
Regards,
Uwe Laubender
( ACP )
Copy link to clipboard
Copied
Thanks-you, I'm one of THOSE designers (Art-Director actually) who can't stand the Auto resize. It has it's uses, but my designers use this everywhere!!! and if I have to correct thir layout due to bad aesthetiques. it is AMAZINGLY annoying.