Hidden objects are still visible?

Changing visible property to hide the selected component:
t5.skp (73.8 KB)
image

My code:

s = Sketchup.active_model.selection[0]
s.visible = false

But I got the result:
image

When I clicked anywhere in Sketchup, the selected component disappeared as expected.

What is the right way to hide an object with Ruby?

Everything is working correctly. It shows this way because the object was selected beforehand.
It will also show this way (hidden render) if you use the Outliner to select any hidden object.

Users can also use View > Hidden Objects to globally display hidden objects as you’ve shown.

3 Likes

Thanks Dan. I fixed my code following your suggestion as below:

s = Sketchup.active_model.selection[0]
s.visible = false
Sketchup.active_model.selection.clear
2 Likes