Skip to main content
Participating Frequently
February 2, 2010
Question

Recursive fitness

  • February 2, 2010
  • 1 reply
  • 617 views

hi!

I am trying to rebuild my script to make a recursive fitness of textframes. With a deep nested set of anchored objects (inline and custom position)

All works well,but when i in my loop tries to first change the current textframe and directly after that change my parent I get an errror msg saying "invalid object for this request".

I have figured out by stepping with the debugger that when i try to change one textframe twice i breaks (because a textframe can be a parent of many textframes). i think it can have something to do with "allowOverrides" set to false.

Any help would be very appreciated!

This topic has been closed for replies.

1 reply

ramkumar_vp
Inspiring
February 2, 2010

Hi Swedenesume,


I think there is no need for the recursive, try the following code to solve your problem.

var myDoc = app.activeDocument;

var myItems = myDoc.allPageItems;

for(var i=myItems.length-1;i>=0;i--)
{
    if(myItems.constructor.name.toString()=="TextFrame")
    {
        myItems.fit(FitOptions.frameToContent);
    }
}

The above code will fit the frames for last nested frame to parent frame.


Regards,

Ramkumar .P

Participating Frequently
February 2, 2010

THANKS!

Very helpfull tips!!

I have one more question about this.

I have anchored objects. And they can be either inline or custom position. If the anchored position is custom the parent textframe cant rezise itself to the new height.

The only way I know how to solve this is by using the geometricbounds and calculate the height of the parent.

Is there a better way to rezise a parent textframe to a custom position anchored object then to calculate the coordinates?

And how could that be implemented to the excellent example you gave?

Many Many Thanks!

ramkumar_vp
Inspiring
February 3, 2010

In my document, it works well for custom anchored object also.


I am checking & fitting the textframes only.


Please check the code once again & do the manupulation wherever you need.


Regards,

Ramkumar .P