# Hiding and Showing the Bubble on Level heads

**URL:** <https://forum.dynamobim.com/t/hiding-and-showing-the-bubble-on-level-heads/13297>\
**Category:** Uncategorized\
**Tags:** python\
**Created:** [July 19, 2017, 9:54am UTC](https://forum.dynamobim.com/t/hiding-and-showing-the-bubble-on-level-heads/13297 "2017-07-19T09:54:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Raja](https://avatars.discourse-cdn.com/v4/letter/r/9de0a6/32.png) [@Raja](https://forum.dynamobim.com/u/Raja)\
**Post date:** [July 19, 2017, 9:54am UTC](https://forum.dynamobim.com/t/hiding-and-showing-the-bubble-on-level-heads/13297/1 "2017-07-19T09:54:19Z")

</div>

Hello all, I have to show and hide 100’s of bubbles in the level head. So I wrote a small bit of python code by referring to this

> [@Level "check box" in views](https://forum.dynamobim.com/t/level-check-box-in-views/5808/2):
>
> Hi Jacqueline, You need Python to hide check box of levels. And here is the code: import clr clr.AddReference('RevitAPI') from Autodesk.Revit.DB import \* import Autodesk clr.AddReference("RevitServices") import RevitServices from RevitServices.Persistence import DocumentManager from RevitServices.Transactions import TransactionManager doc = DocumentManager.Instance.CurrentDBDocument uiapp = DocumentManager.Instance.CurrentUIApplication app = uiapp.Application a = UnwrapElement(I…

but unfortunately it throws an error. The code follows

```
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
import Autodesk

clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)

doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
uidoc = DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument

levels = IN[0]
view = uidoc.ActiveView
check = []

TransactionManager.Instance.EnsureInTransaction(doc)

for level in levels:
	level = UnwrapElement(level)
	level.IsBubbleVisibleInView(DatumEnds.End0, view)
	#The line below works and returns True or False
	#check.append(level.HasBubbleInView(DatumEnds.End0, view))
	
TransactionManager.Instance.TransactionTaskDone()	

#OUT = check
OUT = levels

```

Error it show is

```
Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed. 
Traceback (most recent call last):
  File "<string>", line 30, in <module>
Exception: The datum plane cannot be visible in the view.
Parameter name: view

```

I am confused since the code works for _ **“HasBubbleInView”** _ but not for **_“IsBubbleInView” or “ShowBubbleInView”_**

---

<div class="post-metadata">

**Author:** ![T\_Pover](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/t_pover/32/19147_2.png) [@T\_Pover](https://forum.dynamobim.com/u/T_Pover)\
**Post date:** [July 19, 2017, 10:37am UTC](https://forum.dynamobim.com/t/hiding-and-showing-the-bubble-on-level-heads/13297/2 "2017-07-19T10:37:37Z")

</div>

I think not all bubbles are visible in the views that you supply.  
You could solve this by trying to catch the errors, like this:

```
for level in levels:
	level = UnwrapElement(level)
    try:
	       level.IsBubbleVisibleInView(DatumEnds.End0, view)
    except:
           pass
	#The line below works and returns True or False
	#check.append(level.HasBubbleInView(DatumEnds.End0, view))

```

Don’t just copy paste above code, but retype it with the proper indentation.

---

<div class="post-metadata">

**Author:** ![Raja](https://avatars.discourse-cdn.com/v4/letter/r/9de0a6/32.png) [@Raja](https://forum.dynamobim.com/u/Raja)\
**Post date:** [July 19, 2017, 1:03pm UTC](https://forum.dynamobim.com/t/hiding-and-showing-the-bubble-on-level-heads/13297/3 "2017-07-19T13:03:04Z")

</div>

@T_Pover thanks a lot, didn’t strike my mind that all the bubbles will be visible in the view.

 ![](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/3/3/33fc7246da9c12a32fc9aea866882d23f64c721c.png)

The first thing i learned in python was not to miss any indentation 🙂
