Skip to main content
Participating Frequently
August 9, 2018
Answered

How to hide object in scripting

  • August 9, 2018
  • 2 replies
  • 2562 views

How do you hide in object in scripting like a text frame? This can be accomplished from the menu by selecting the text frame and select Object -> Hide.

The only thing I've found is the "visible" property for layers to show and hide them but I can't find a property on the text frame to show or hide from scripting.

This topic has been closed for replies.
Correct answer Ten A

You can use executeMenuCommand like below.

app.executeMenuCommand("hide");

Select your textFrame and run it.

2 replies

Inspiring
August 10, 2018

In my case it was easier to put all objects I wanted to be hidden later on into one layer right from the start.
Then it is possible to hide a complete layer (and show again afterwards). Below are two functions to hide and show a top level layer. You call the function and just have to pass it the name of your layer.

E.g. call "hide_layer (text)" than you do a Save As or Export and after that call "show_layer (text).

function hide_layer (a) {

    var docHide = app.activeDocument; 

    var myLayers1 = docHide.layers; 

    var hideName1 = a; 

    try { 

        hideLayer1 = myLayers1.getByName (hideName1); 

        hideLayer1.visible = false; 

        redraw(); 

        } 

    catch (e) {} 

    }

 

function show_layer (a) {

    var docShow = app.activeDocument; 

    var myLayers2 = docShow.layers; 

    var showName2 = a; 

    try { 

        showLayer2 = myLayers2.getByName (showName2); 

        showLayer2.visible = true; 

        redraw(); 

        } 

    catch (e) {} 

    }

Ten A
Community Expert
Ten ACommunity ExpertCorrect answer
Community Expert
August 9, 2018

You can use executeMenuCommand like below.

app.executeMenuCommand("hide");

Select your textFrame and run it.

Participating Frequently
August 10, 2018

Thank you! That worked but how would I show these items? I get an error when I try to select hidden items.

Ten A
Community Expert
Community Expert
August 16, 2018

Try "showAll" command.

And You can reference below.

Illustrator CC(ver.22) menu commands list | CC Labo