Skip to main content
Known Participant
September 8, 2017
Answered

How to check if an anchored frame is empty or not?

  • September 8, 2017
  • 1 reply
  • 467 views

I have a script which deletes graphics but leaves behind anchored frames. Is there any way I can find out which pages of my doc/book has empty anchored frames?

This topic has been closed for replies.
Correct answer frameexpert

You could use something like this:

#target framemaker

var doc = app.ActiveDoc;

var frames = getEmptyAnchoredFrames (doc);

deleteFrames (frames);

function getEmptyAnchoredFrames (doc) {

    var graphic, frames = [];

    graphic = doc.FirstGraphicInDoc;

    while (graphic.ObjectValid () === 1) {

        // Test for an anchored frame.

        if (graphic.constructor.name === "AFrame") {

            // See if the anchored frame is empty.

            if (graphic.FirstGraphicInFrame.ObjectValid () === 0) {

                frames.push (graphic);

            }

        }

        graphic = graphic.NextGraphicInDoc;

    }

   

    return frames;

}

function deleteFrames (frames) {

    for (var i = 0; i < frames.length; i += 1) {

        frames.Delete ();

    }

}

1 reply

frameexpert
Community Expert
frameexpertCommunity ExpertCorrect answer
Community Expert
September 10, 2017

You could use something like this:

#target framemaker

var doc = app.ActiveDoc;

var frames = getEmptyAnchoredFrames (doc);

deleteFrames (frames);

function getEmptyAnchoredFrames (doc) {

    var graphic, frames = [];

    graphic = doc.FirstGraphicInDoc;

    while (graphic.ObjectValid () === 1) {

        // Test for an anchored frame.

        if (graphic.constructor.name === "AFrame") {

            // See if the anchored frame is empty.

            if (graphic.FirstGraphicInFrame.ObjectValid () === 0) {

                frames.push (graphic);

            }

        }

        graphic = graphic.NextGraphicInDoc;

    }

   

    return frames;

}

function deleteFrames (frames) {

    for (var i = 0; i < frames.length; i += 1) {

        frames.Delete ();

    }

}

www.frameexpert.com
Known Participant
September 12, 2017

Thank you! frameexpert