Skip to main content
Inspiring
April 1, 2013
Answered

find and remove text frames with same geometricBounds

  • April 1, 2013
  • 1 reply
  • 1327 views

Hi Scripter ...new question starting from here:

var mySelection = app.activeDocument.selection[0].geometricBounds;

//alert (mySelection);

everywhere in the document i need to find and remove text frames with the same geometricBounds.

If possible, same dimensions but not same positions.

Thanks for help!

This topic has been closed for replies.
Correct answer foredit

ok Bala ...due to decimal differences some frames weren't removed.

I solved with "Math.round" in place of "Number"

===================

var mySelection = app.activeDocument.selection[0].geometricBounds;

var myWidth = Math.round(mySelection[3]-mySelection[1]);

var myHeight = Math.round(mySelection[2]-mySelection[0]); alert(myHeight);

var allFrames = app.activeDocument.allPageItems;

while(t = allFrames.pop() ) {

    if(t.isValid){                    

        var myTextframe = t.geometricBounds;

        var myTWidth = Math.round(myTextframe[3]-myTextframe[1]);

        var myTHeight = Math.round(myTextframe[2]-myTextframe[0]);      

        if((myWidth == myTWidth) && (myHeight == myTHeight)){              

            t.remove();

            }

        }

    }

===================

Now your script works fine!

Thanks a lot!

1 reply

R-Bala-Krishnan
Inspiring
April 2, 2013

Hi,

According to my understanding, frame which having the equal widthxheight need to be remove, sorry if it’s not match your requirement.

============================

var mySelection = app.activeDocument.selection[0].geometricBounds;

var myWidth = Number(mySelection[3]-mySelection[1]);

var myHeight = Number(mySelection[2]-mySelection[0]);

var allFrames = app.activeDocument.allPageItems;

while(t = allFrames.pop() ) {

    if(t.isValid){                     

        var myTextframe = t.geometricBounds;

        var myTWidth = Number(myTextframe[3]-myTextframe[1]);

        var myTHeight = Number(myTextframe[2]-myTextframe[0]);       

        if((myWidth == myTWidth) && (myHeight == myTHeight)){               

            t.remove();

            }

        }

    }

===================

Regards,

Bala

foreditAuthor
Inspiring
April 2, 2013

Thanks Bala, this is exactly what i mean ...but testing the script (indesign cs6) something is going wrong.

Not all frames (with same dimensions) are removed.

Have a better situation using "parseInt" instead of "Number".

I would join my indesign test document but don't know how.

Anyway, this is great for me, good to work around

best regards

foreditAuthorCorrect answer
Inspiring
April 2, 2013

ok Bala ...due to decimal differences some frames weren't removed.

I solved with "Math.round" in place of "Number"

===================

var mySelection = app.activeDocument.selection[0].geometricBounds;

var myWidth = Math.round(mySelection[3]-mySelection[1]);

var myHeight = Math.round(mySelection[2]-mySelection[0]); alert(myHeight);

var allFrames = app.activeDocument.allPageItems;

while(t = allFrames.pop() ) {

    if(t.isValid){                    

        var myTextframe = t.geometricBounds;

        var myTWidth = Math.round(myTextframe[3]-myTextframe[1]);

        var myTHeight = Math.round(myTextframe[2]-myTextframe[0]);      

        if((myWidth == myTWidth) && (myHeight == myTHeight)){              

            t.remove();

            }

        }

    }

===================

Now your script works fine!

Thanks a lot!