Skip to main content
Participant
March 19, 2024
Answered

Delete empty graphics frames inside table - Part II

  • March 19, 2024
  • 1 reply
  • 617 views

Hi everyone

I need a script to delete all empty graphics frames inside all tables of a multi page document.

I've tested without success all that was included in the first post Delete empty graphics frames inside table

 

Anyone know how to rewrite those script so that all empty graphic frames from all tables are deleted?

I've managed to work scripts to remove all the noise with an applescript with GREPs, to find a script to remove all empty lines, but my empty graphics frames prevent me from deleting my empty row.

I've attached a example of the table that need to get rid of the empty graphic frame.

I'm not that good at scripting, but I wanna learn, so any help would be much appreciated.

 

Thanks

 

Patrick

Correct answer rob day

Hi @Patof , Does this work?:

 

var c = app.activeDocument.stories.everyItem().tables.everyItem().cells.everyItem().getElements();

var api;
for (var i = 0; i < c.length; i++){
    api = c[i].allPageItems;
    for (var j = 0; j < api.length; j++){
        if (api[j].constructor.name == "Rectangle") {
            $.writeln(api[j].allPageItems.length)
            if (api[j].allPageItems.length == 0) {
                api[j].remove()
            } 
        } 
    };   
};   

 

1 reply

rob day
Community Expert
rob dayCommunity ExpertCorrect answer
Community Expert
March 19, 2024

Hi @Patof , Does this work?:

 

var c = app.activeDocument.stories.everyItem().tables.everyItem().cells.everyItem().getElements();

var api;
for (var i = 0; i < c.length; i++){
    api = c[i].allPageItems;
    for (var j = 0; j < api.length; j++){
        if (api[j].constructor.name == "Rectangle") {
            $.writeln(api[j].allPageItems.length)
            if (api[j].allPageItems.length == 0) {
                api[j].remove()
            } 
        } 
    };   
};   

 

PatofAuthor
Participant
March 19, 2024

Yes it work perfectly!

Thanks Rob!

Robert at ID-Tasker
Legend
March 19, 2024
quote

Yes it work perfectly!


By @Patof

 

Script could delete that "empty" row instead...