Set grid bubbles by template view

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

@Steven

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.

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

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:

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

Give it a try and we are here to help!

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

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

As far as I could guess…

#Start Python Script

import clr
clr.AddReference("ProtoGeometry")
from Autodesk.DesignScript.Geometry import *
# Import ToDSType(bool) extension method
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
# Import geometry conversion extension methods
clr.ImportExtensions(Revit.GeometryConversion)
# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
from System.Collections.Generic import *
# Import RevitAPI
clr.AddReference("RevitAPI")
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 > 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 = []

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

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

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

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.

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

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 (41.7 KB)

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.

1 Like

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

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

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

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

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.

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.

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