Hide entity on all Pages (Scenes) but one programmatically in Ruby script?

Given a certain object I know the name of, I would like to hide it in all scenes but a certain one. This .each loop however hides all entities in all scenes for some reason. I can’t find what is wrong with it.

I know:

  • The name of the one scene I want the group to be visible on = target_scene

  • The name of the group I want to hide on all other scenes = target

    Sketchup.active_model.pages.each{|op|
      if(op.name != "target_scene")
          target.hidden = true
          op.update(16)
      end
    }
    

You need select the page before update.

1 Like

look at :set_visibility attribute…

john

1 Like

Thank you that did it. Here is the final script:

Sketchup.active_model.pages.each{|op|
    if(op.name != "target_scene")
        Sketchup.active_model.pages.selected_page = op            
        target.hidden = true
        op.update(16)
    end
}

Thanks John but :set_visibility looks like Layer control and I wanted to hide independently of Layers.

The only thing missing is remember previous selected scene and restore it after the loop.

1 Like

Yeah, and camera.