# Set grid bubbles by template view

**URL:** <https://forum.dynamobim.com/t/set-grid-bubbles-by-template-view/34728>\
**Category:** Uncategorized\
**Created:** [April 11, 2019, 10:30pm UTC](https://forum.dynamobim.com/t/set-grid-bubbles-by-template-view/34728 "2019-04-11T22:30:52Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![vanman](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/vanman/32/20881_2.png) [@vanman](https://forum.dynamobim.com/u/vanman)\
**Post date:** [April 11, 2019, 10:30pm UTC](https://forum.dynamobim.com/t/set-grid-bubbles-by-template-view/34728/1 "2019-04-11T22:30:52Z")

</div>

Hi, I’m trying to use grid bubbles in a view as a template. Weather there on or off to set to other views. Using the link below from @Kulkul as a start but struggling. I think I need to get the parameter value as a boolean to apply it to the other views. However all values are coming back as 1 when some are on or off in the template view that is in the example

> [@Hide GridBubble in View](https://forum.dynamobim.com/t/hide-gridbubble-in-view/4977/2):
>

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/4/f/4f6f648b1677e7363f5497d2bdf1d8f1767874c4.png)

@Steven

---

<div class="post-metadata">

**Author:** ![architectcoding](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/architectcoding/32/105118_2.png) [@architectcoding](https://forum.dynamobim.com/u/architectcoding)\
**Post date:** [April 15, 2019, 12:05am UTC](https://forum.dynamobim.com/t/set-grid-bubbles-by-template-view/34728/2 "2019-04-15T00:05:12Z")

</div>

> [@vanman](#):
>
> a start but struggling. I think I need to get the parameter value as a boolean to apply it to the other views. However all values are coming back as 1 when some are on or off in the template view that is in the example

Hi Steven, I think you took the wrong example. The graph provided by Kulkul changes the visibility in the grid type, that means in all views, and you wanted per view, so may want to start with Tomasz\_Puchala script in the same topic.

---

<div class="post-metadata">

**Author:** ![vanman](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/vanman/32/20881_2.png) [@vanman](https://forum.dynamobim.com/u/vanman)\
**Post date:** [April 15, 2019, 1:32am UTC](https://forum.dynamobim.com/t/set-grid-bubbles-by-template-view/34728/3 "2019-04-15T01:32:20Z")

</div>

Thanks, I’m stumped on how to ascertain weather a grid bubble is on or off at either end to pass onto another view 😕 dont have the python skills yet unfortunately

---

<div class="post-metadata">

**Author:** ![architectcoding](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/architectcoding/32/105118_2.png) [@architectcoding](https://forum.dynamobim.com/u/architectcoding)\
**Post date:** [April 15, 2019, 1:54am UTC](https://forum.dynamobim.com/t/set-grid-bubbles-by-template-view/34728/4 "2019-04-15T01:54:31Z")

</div>

Hey, no worries. I don’t think python skills can halt you in this case. If you keep reading that post, there is this one:

> [@Hide GridBubble in View](https://forum.dynamobim.com/t/hide-gridbubble-in-view/4977/13):
>
> This script is created with Dynamo 1.2 and the Revit 2017 api. The node TB\_Show-Hide is actually the Python script. The .dyn file is attached [Toggle Grid Bubbles.dyn](https://forum.dynamobim.com/uploads/short-url/odrFxpyBM3V4Fm2jzTHP9L5F7g7.dyn) (11.6 KB)

grid.IsBubbleVisibleInView(DatumEnds.End0, view) will return a boolean to check if it’s on or off:

> **[IsBubbleVisibleInView Method](https://www.revitapidocs.com/2019/75c39be6-5f78-9dd2-061e-13b846e739d5.htm)**
>
> Online Documentation for Autodesk's Revit API: 2015, 2016, 2017, 2017.1, 2018

Give it a try and we are here to help!

---

<div class="post-metadata">

**Author:** ![vanman](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/vanman/32/20881_2.png) [@vanman](https://forum.dynamobim.com/u/vanman)\
**Post date:** [April 15, 2019, 1:57am UTC](https://forum.dynamobim.com/t/set-grid-bubbles-by-template-view/34728/5 "2019-04-15T01:57:08Z")

</div>

I need to use my eyes and read more!!! thank you! will give it a go

---

<div class="post-metadata">

**Author:** ![vanman](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/vanman/32/20881_2.png) [@vanman](https://forum.dynamobim.com/u/vanman)\
**Post date:** [April 15, 2019, 2:31am UTC](https://forum.dynamobim.com/t/set-grid-bubbles-by-template-view/34728/6 "2019-04-15T02:31:40Z")

</div>

Nope its out of my league to adapt this to output a list that either has 0 and 1 haha. Found this that might be an easier start to change

```
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(IN[0])
v = UnwrapElement(IN[1])
b = UnwrapElement(IN[2])
TransactionManager.Instance.EnsureInTransaction(doc)

for i in a:
	if b:
		i.ShowBubbleInView(DatumEnds.End0,v)
		i.HideBubbleInView(DatumEnds.End1,v)

	else:
		i.HideBubbleInView(DatumEnds.End0,v)
		i.ShowBubbleInView(DatumEnds.End1,v)

TransactionManager.Instance.TransactionTaskDone()

#Assign your output to the OUT variable.
OUT = 0
```

---

<div class="post-metadata">

**Author:** ![vanman](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/vanman/32/20881_2.png) [@vanman](https://forum.dynamobim.com/u/vanman)\
**Post date:** [April 15, 2019, 2:45am UTC](https://forum.dynamobim.com/t/set-grid-bubbles-by-template-view/34728/7 "2019-04-15T02:45:02Z")

</div>

As far as I could guess…

```
#Start Python Script

import clr
clr.AddReference(&quot;ProtoGeometry&quot;)
from Autodesk.DesignScript.Geometry import *
# Import ToDSType(bool) extension method
clr.AddReference(&quot;RevitNodes&quot;)
import Revit
clr.ImportExtensions(Revit.Elements)
# Import geometry conversion extension methods
clr.ImportExtensions(Revit.GeometryConversion)
# Import DocumentManager and TransactionManager
clr.AddReference(&quot;RevitServices&quot;)
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
from System.Collections.Generic import *
# Import RevitAPI
clr.AddReference(&quot;RevitAPI&quot;)
import Autodesk
from Autodesk.Revit.DB import *

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

items = UnwrapElement (IN[0])
view = UnwrapElement (IN[1])

TransactionManager.Instance.EnsureInTransaction(doc)
#THUNNISSEN SCRIPT
on = 0;
off = 0;
for i in items:
if i.IsBubbleVisibleInView(DatumEnds.End0, view)
if i.IsBubbleVisibleInView(DatumEnds.End1, view)

for i in items:
if on &gt; off:
i.HideBubbleInView(DatumEnds.End0, view)
i.HideBubbleInView(DatumEnds.End1, view)
else:
i.ShowBubbleInView(DatumEnds.End0, view)
i.ShowBubbleInView(DatumEnds.End1, view)

#for i in a:
# i.HideBubble(b)
TransactionManager.Instance.TransactionTaskDone()

doc.Regenerate()
uidoc.RefreshActiveView()

OUT = []
```

---

<div class="post-metadata">

**Author:** ![architectcoding](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/architectcoding/32/105118_2.png) [@architectcoding](https://forum.dynamobim.com/u/architectcoding)\
**Post date:** [April 15, 2019, 3:16am UTC](https://forum.dynamobim.com/t/set-grid-bubbles-by-template-view/34728/8 "2019-04-15T03:16:19Z")

</div>

Baby steps, as you said you need to retrieve the initial list of 0 and 1. You can start with something like this:

```
items = UnwrapElement (IN[0])
view = UnwrapElement (IN[1])

endZero = []

for i in items:
	if i.HideBubbleInView(DatumEnds.End0, view[0]):
		endZero.append(1)
	else:
		endZero.append(0)

doc.Regenerate()
uidoc.RefreshActiveView()

OUT = boolResult

```

Substitute view[0] with any view you are interested to take as template for the rest

---

<div class="post-metadata">

**Author:** ![vanman](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/vanman/32/20881_2.png) [@vanman](https://forum.dynamobim.com/u/vanman)\
**Post date:** [April 15, 2019, 3:46am UTC](https://forum.dynamobim.com/t/set-grid-bubbles-by-template-view/34728/9 "2019-04-15T03:46:44Z")

</div>

Thanks man, this is pretty cool. I’ve been so wanting to learn python but other life stuff has been choking me. In a few weeks ill have some time to put in some effort to learning. However thanks, took your start and got this so far! This stuff is so much more interesting then my job, should have become a coder haha.

somtimes it keeps the indentation when i post here. somtimes it dosnt. unsure how to always have indentation. Update, think this will make more sense to apply to views next.

```
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

items = UnwrapElement (IN[0])
view = UnwrapElement (IN[1])

Gridend0 = []
Gridend1 = []

for i in items:
	if i.IsBubbleVisibleInView(DatumEnds.End0, view[0]):
		Gridend0.append(1)
	else:
		Gridend0.append(0)

for i in items:
	if i.IsBubbleVisibleInView(DatumEnds.End1, view[0]):
		Gridend1.append(1)
	else:
		Gridend1.append(0)

OUT = Gridend0,Gridend1

```

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/6/8/68c0bf2d17954eef44ac714defba183a0f0a7fce.png)

---

<div class="post-metadata">

**Author:** ![architectcoding](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/architectcoding/32/105118_2.png) [@architectcoding](https://forum.dynamobim.com/u/architectcoding)\
**Post date:** [April 15, 2019, 4:21am UTC](https://forum.dynamobim.com/t/set-grid-bubbles-by-template-view/34728/10 "2019-04-15T04:21:11Z")

</div>

> [@vanman](#):
>
> i.ShowBubbleInView(DatumEnds.End0, view)

Hahaha, I know, I believe a ton of us in the forum have the same feeling. Well, that’s good to hear, it will be a good investment for you, probably the most demanded programming language of 2019 and it will keep raising.  
Looks good, but if you don’t know python and you don’t mind, I’ll leave the next step here. The next part is not much more complicated but nested loops are not fun when you are starting. Just take it as example in case you are stuck.

```
items = UnwrapElement (IN[0])
view = UnwrapElement (IN[1])

Gridend0 = []
Gridend1 = []

for i in items:
if i.IsBubbleVisibleInView(DatumEnds.End0, view[0]):
Gridend0.append(1)
else:
Gridend0.append(0)

for v in view:
i = 0
for grid in items:
if Gridend0[i] == 0:
grid.HideBubbleInView(DatumEnds.End0, view)
else:
grid.ShowBubbleInView(DatumEnds.End0, view)
i += 1

OUT = Gridend0

```

---

<div class="post-metadata">

**Author:** ![vanman](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/vanman/32/20881_2.png) [@vanman](https://forum.dynamobim.com/u/vanman)\
**Post date:** [April 15, 2019, 4:32am UTC](https://forum.dynamobim.com/t/set-grid-bubbles-by-template-view/34728/11 "2019-04-15T04:32:00Z")

</div>

I was thinking somthing like this to keep it simple. I would need 3 inputs now though? The view with the grids to apply? Im so lost in my mind now haha.

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/4/4/44894ba06eeb1a0b136267039ec85a755426b6ec.png)

---

<div class="post-metadata">

**Author:** ![architectcoding](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/architectcoding/32/105118_2.png) [@architectcoding](https://forum.dynamobim.com/u/architectcoding)\
**Post date:** [April 15, 2019, 5:12am UTC](https://forum.dynamobim.com/t/set-grid-bubbles-by-template-view/34728/12 "2019-04-15T05:12:11Z")

</div>

Does it work? Not sure if it is working…if not can you share what’s inside Grids to Apply Bubble End?

---

<div class="post-metadata">

**Author:** ![vanman](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/vanman/32/20881_2.png) [@vanman](https://forum.dynamobim.com/u/vanman)\
**Post date:** [April 15, 2019, 5:32am UTC](https://forum.dynamobim.com/t/set-grid-bubbles-by-template-view/34728/13 "2019-04-15T05:32:18Z")

</div>

Dont think ive put anything in there cause I got to confused. Havnt got the time to wrap my head around it all right now as much I want to. If you can help that’d be amazing but it takes me hours to figure this sort of stuff out. Dynamo 1.3

[Grid Bubbles\_Set By Template View.dyn](https://forum.dynamobim.com/uploads/short-url/4Cx6OmkjCZa876z5IMrf0tiHqpM.dyn) (41.7 KB)

---

<div class="post-metadata">

**Author:** ![architectcoding](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/architectcoding/32/105118_2.png) [@architectcoding](https://forum.dynamobim.com/u/architectcoding)\
**Post date:** [April 15, 2019, 6:00am UTC](https://forum.dynamobim.com/t/set-grid-bubbles-by-template-view/34728/14 "2019-04-15T06:00:00Z")

</div>

Alright, the previous snippet of code I sent you was good to start, but the solution adopted to your needs is like this:

```
items = UnwrapElement (IN[0])
view = UnwrapElement (IN[1])
gridend = IN[2]

for v in view:
    i = 0
    for grid in items:
       if gridend[i] == 0:
          grid.HideBubbleInView(DatumEnds.End0, view)
       else:
          grid.ShowBubbleInView(DatumEnds.End0, view)
    i += 1

OUT = []

```

Be careful of indetantions and change DatumEnds.End0 to DatumEnds.End1 ifor the other end.

---

<div class="post-metadata">

**Author:** ![vanman](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/vanman/32/20881_2.png) [@vanman](https://forum.dynamobim.com/u/vanman)\
**Post date:** [April 15, 2019, 8:53pm UTC](https://forum.dynamobim.com/t/set-grid-bubbles-by-template-view/34728/15 "2019-04-15T20:53:19Z")

</div>

thanks so much for your response and time! I’m getting this error. Not sure if it has something to do with the lists or I’ve mucked something else up

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/1/0/10e6598f8d340f936a3f66ebd46ac9ab97d7f886.png)

---

<div class="post-metadata">

**Author:** ![architectcoding](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/architectcoding/32/105118_2.png) [@architectcoding](https://forum.dynamobim.com/u/architectcoding)\
**Post date:** [April 15, 2019, 11:11pm UTC](https://forum.dynamobim.com/t/set-grid-bubbles-by-template-view/34728/16 "2019-04-15T23:11:00Z")

</div>

> [@architectcoding](#):
>
> Grids to Apply Bubble End

Can you show us what’s inside Grids to Apply Bubble End?

---

<div class="post-metadata">

**Author:** ![vanman](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/vanman/32/20881_2.png) [@vanman](https://forum.dynamobim.com/u/vanman)\
**Post date:** [April 15, 2019, 11:26pm UTC](https://forum.dynamobim.com/t/set-grid-bubbles-by-template-view/34728/17 "2019-04-15T23:26:00Z")

</div>

```
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

items = UnwrapElement (IN[0])
view = UnwrapElement (IN[1])
gridend = IN[2]

for v in view:
    i = 0
    for grid in items:
       if gridend[i] == 0:
          grid.HideBubbleInView(DatumEnds.End0, view)
       else:
          grid.ShowBubbleInView(DatumEnds.End0, view)
    i += 1

OUT = []

```

![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/e/2/e27b239c6b05fbdeb3f9ea7a6c43a58f60a7b74e.png)

The other one has the change you talked bout to “End1”

---

<div class="post-metadata">

**Author:** ![architectcoding](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/architectcoding/32/105118_2.png) [@architectcoding](https://forum.dynamobim.com/u/architectcoding)\
**Post date:** [April 15, 2019, 11:38pm UTC](https://forum.dynamobim.com/t/set-grid-bubbles-by-template-view/34728/18 "2019-04-15T23:38:48Z")

</div>

> [@vanman](#):
>
> 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 items = UnwrapElement (IN[0]) view = UnwrapElement (IN[1]) gridend = IN[2] for v in view: i = 0 for grid in items: if gridend[i] == 0: grid.HideBubbleInView(DatumEnds.End0, view) else: grid.ShowBubbleInView(DatumEnds.End0, view) i += 1 OUT =

Oh, sorry, the error comes from that the grid list hasn’t been flatten, so the script is taking the L2 list instead of the grid elements.

---

<div class="post-metadata">

**Author:** ![vanman](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/vanman/32/20881_2.png) [@vanman](https://forum.dynamobim.com/u/vanman)\
**Post date:** [April 15, 2019, 11:56pm UTC](https://forum.dynamobim.com/t/set-grid-bubbles-by-template-view/34728/19 "2019-04-15T23:56:23Z")

</div>

is there a way to get it to take the grids inside the list for the different levels? I think flattening wont work for the varied amount of views that you want to apply the template to. Ill give flattening a go though.

---

<div class="post-metadata">

**Author:** ![architectcoding](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/architectcoding/32/105118_2.png) [@architectcoding](https://forum.dynamobim.com/u/architectcoding)\
**Post date:** [April 16, 2019, 12:09am UTC](https://forum.dynamobim.com/t/set-grid-bubbles-by-template-view/34728/20 "2019-04-16T00:09:05Z")

</div>

Oh, sorry! Didn’t check what was before the collector. Yerah, you’re right. This will do the trick:

```
for v in view:
    i = 0
    j = 0
    for grid in items[j]:
       if gridend[i] == 0:
          grid.HideBubbleInView(DatumEnds.End0, view)
       else:
          grid.ShowBubbleInView(DatumEnds.End0, view)
    i += 1
j += 1
```

[Next page](https://forum.dynamobim.com/t/set-grid-bubbles-by-template-view/34728.md?page=2)
