Sorry, but no. The topic is about Layers visibility on a scenes, but you are talking about the entities…however the entity overall visibility will depends also which layer associated to it.
You may need to check the #drawing_element_visible? method (and search for it in this forum… for example this topic )