Highlighted

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

New Here ,
Sep 08, 2017

Copy link to clipboard

Copied

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?

Adobe Community Professional
Correct answer by frameexpert | Adobe Community Professional

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 ();

    }

}

TOPICS
Scripting

Views

232

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

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

New Here ,
Sep 08, 2017

Copy link to clipboard

Copied

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?

Adobe Community Professional
Correct answer by frameexpert | Adobe Community Professional

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 ();

    }

}

TOPICS
Scripting

Views

233

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Sep 08, 2017 0
Adobe Community Professional ,
Sep 10, 2017

Copy link to clipboard

Copied

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 ();

    }

}

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 10, 2017 0
New Here ,
Sep 12, 2017

Copy link to clipboard

Copied

Thank you! frameexpert

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 12, 2017 0