Show/Hide level bubbles in multiple views

Hello Everyone.
I found this script from dynamo Forum to show the level bubbles for the current view. see pic 1

But when i try multiples views, it does not work. Can someone please help me how to adjust it for multiple views? I dont know Python very much. pic 2 with error

Here is the python 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(IN[0])
v = UnwrapElement(IN[1])
TransactionManager.Instance.EnsureInTransaction(doc)
for i in a:
i.ShowBubbleInView(DatumEnds.End0,v)
i.ShowBubbleInView(DatumEnds.End1,v)
TransactionManager.Instance.TransactionTaskDone()

OUT = 0

@Ammad ,

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])

t  = Transaction(doc, "Show Bubbles")
t.Start()

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

t.Commit()

OUT = "Done!"

i think i will not solve your issue but your code is more readable </>

KR

Andreas

2 Likes

How do you paste code like the way you did it. I was unable to post it like this.

grafik

1 Like

Thanks

At the moment your code is hard to read, as I have no idea what a and v are. Spell out variables using camelCase or some other standard format so that people an understand what you are working with.

But if I assume that v is your view, and a is your list of grids, then I can guess that you need to add a loop mechanism to your views so that it can iterate over all the views, and then iterate over all the grids in the view iterations.

something like:

for view in viewList:
    for grid in gridList:
        grid.ShowBubbleInView(DatumEnds.End0,view)
        grid.ShowBubbleInView(DatumEnds.End1,view)
1 Like