Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Select and delete objects by "type" Javascript

LEGEND ,
Aug 02, 2018 Aug 02, 2018

I am trying to write a Javascript snippet that will select all "Text Objects" and "Brush Objects" on the current document's visible, unlocked layers, then delete the objects.

This thread about "Execute Menu Item" seemed promising, but I could not figure out the proper object names to use. Executing a menu item may not be the most efficient approach anyway.

Can someone help me with this? Thanks.

TOPICS
Scripting
1.9K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Aug 02, 2018 Aug 02, 2018

function test()

{

    var docRef = app.activeDocument;

    var sel;

    docRef.selection = null;

    app.executeMenuCommand("Brush Strokes menu item");

    sel = docRef.selection;

    for(var x=sel.length-1;x>=0;x--)

    {

        sel.remove();

    }

    app.executeMenuCommand("Text Objects menu item");

    sel = docRef.selection;

    for(var x=sel.length-1;x>=0;x--)

    {

        sel.remove();

    }

  

}

test();

Translate
Adobe
Community Expert ,
Aug 02, 2018 Aug 02, 2018

function test()

{

    var docRef = app.activeDocument;

    var sel;

    docRef.selection = null;

    app.executeMenuCommand("Brush Strokes menu item");

    sel = docRef.selection;

    for(var x=sel.length-1;x>=0;x--)

    {

        sel.remove();

    }

    app.executeMenuCommand("Text Objects menu item");

    sel = docRef.selection;

    for(var x=sel.length-1;x>=0;x--)

    {

        sel.remove();

    }

  

}

test();

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 02, 2018 Aug 02, 2018
LATEST

Thank you, William! Works like a charm. Where's the tip jar?

I will study this and see what I can learn for next time.

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