0

Whenever I open a PDF-file in Illustrator for edithing, there are a lot of ungrouped and uncategorized Elemetns in it. So I tried to select multiple elements with a spicific name with the below Script, but since the name of the elements are between Angle-brackets "<someName>" script wont select them:

function selectPageItemsByName(items, name) {
    for (var i = 0; i < items.length; i++) {
        var item = items[i];
        if (item.name === name) {
            item.selected = true;
        }
    }
}

function main() {
    var document = app.activeDocument;
    var name = '<someFile>';
    document.selection = null;
    selectPageItemsByName(document.pageItems, name);
}
main();

Femkeblanko from Adobe Community says: Items with angle brackets in their label (unless user-created) are unnamed. They correspond to an empty string, i.e. "".

If I remove the Brackets from the name of the Elemetns, the script works but I have a lot of Elements and it needs time. So, isn't there a way to salve it?

HamiD
  • 1,075
  • 1
  • 6
  • 22
  • you need *something* to select by. a name isn't gonna work as they don't have names. do they have anything in common? what elements are you trying to select? will giving them names help? – Yarin_007 Dec 12 '22 at 21:27
  • @Yarin_007 They are all Masks which I want to remove. – HamiD Dec 13 '22 at 08:08
  • 1
    Perhaps [this](https://stackoverflow.com/questions/35057879/how-to-select-and-delete-every-clipping-masks-in-an-illustrator-document-using-j/40981685#40981685)? – Yarin_007 Dec 13 '22 at 10:58
  • @Yarin_007 you can write it as an answer if you want, so I can accept it. – HamiD Dec 13 '22 at 11:44

1 Answers1

2

this is a pretty creative way:

// Select->Objects->Clipping Mask
app.executeMenuCommand("Clipping Masks menu item"); 
// Edit->Clear
app.executeMenuCommand("clear"); 

but it isn't really documented very well

some links for future reference:

Where is the perfect reference of adobe illustrator script?

https://ai-scripting.docsforadobe.dev/index.html

https://ten-artai.com/illustrator-ccver-22-menu-commands-list/

https://github.com/ten-A/AiMenuObject

Yarin_007
  • 1,449
  • 1
  • 10
  • 17