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

hide
ruby
api
#1

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
    }
0 Likes

#2

You need select the page before update.

1 Like

#3

look at :set_visibility attribute…

john

1 Like

#4

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
}
0 Likes

#5

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

0 Likes

#6

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

1 Like

#7

Yeah, and camera.

0 Likes