Multiple Views

Hello,

I have this current script but trying to figure out how to make it applicable for multiple views. V = Single View. Confused as how to restructure / rewrite the following code. Thank you!

import clr
clr.AddReference(‘ProtoGeometry’)
from Autodesk.DesignScript.Geometry import *

clr.AddReference(“RevitNodes”)
import Revit
clr.ImportExtensions(Revit.Elements)

clr.ImportExtensions(Revit.GeometryConversion)

clr.AddReference(“RevitServices”)
import RevitServices

from RevitServices.Persistence import *
from RevitServices.Transactions import TransactionManager
from System.Collections.Generic import *

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

g = UnwrapElement(IN[0])
b = UnwrapElement(IN[1])
v = UnwrapElement(IN[2])

TransactionManager.Instance.EnsureInTransaction(doc)

for g, b in zip(g, b):
if b:
g.HideBubbleInView(DatumEnds.End1,v)
g.ShowBubbleInView(DatumEnds.End0,v)
else:
g.HideBubbleInView(DatumEnds.End0,v)
g.ShowBubbleInView(DatumEnds.End1,v)

TransactionManager.Instance.TransactionTaskDone()

doc.Regenerate()

OUT = g

How is the data structured before being passed into the node? Also, what are g and b?

1 Like

Hello Cgartland,

The information is organized as such. Basically this script easily flips the grids over to the appropriate sides quickly and efficiently per view. The idea is that if I can quickly utilize multiple views, that would be ideal :slight_smile:

Let me know if you need any other information.

Thank you,
Kevin

Hi, I would suggest this change:

(...)
views = UnwrapElement(IN[2])
(...)
for g, b in zip(g, b):
	if b:
		[g.HideBubbleInView(DatumEnds.End1,v) for v in views]
		[g.ShowBubbleInView(DatumEnds.End0,v) for v in views]
	else:
		[g.HideBubbleInView(DatumEnds.End0,v) for v in views]
		[g.ShowBubbleInView(DatumEnds.End1,v) for v in views]
(...)
1 Like

Guiseppe,

That worked perfectly! Thank you so much and appreciate the insight. :slight_smile: