Turn On Top & Left Grid Bubbles Only

I have been trying to manipulate the code in this post to turn on grid bubbles in the Top and Left sides of the grids. This code manipulates them to turn on for the Top and Right. I have been able to manipulate it to turn on the Bottom and Left grid bubbles, all grid bubbles, or no grid bubbles, but I have had no luck with Left and Top.

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

Grids_On_Off_Internet.dyn (21.0 KB)

I have attached the script I have been using.

Things I have attempted that failed

  • Switching “greater” to “less”
  • Changing End0 and End1 Show/Hide

Any direction would be helpful!

This is because “top” and “right” refers to the positive directions. Changing that to “top” and “left” now means your looking for a (more) positive value in the Y direction and a (more) negative value in the X direction. X+Y is looking for the generally larger value (more positive). You’ll have to change the logic.

Thanks @Nick_Boyts ! I was able to get it to work with a change in logic. I’m sharing my code for anybody else who wants to use it! I haven’t thoroughly tested it, but it worked for multiple views in a current project I have.

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])
bx = UnwrapElement(IN[1])
by = UnwrapElement(IN[2])
v = UnwrapElement(IN[3])

TransactionManager.Instance.EnsureInTransaction(doc)

for g, bx, by in zip(g, bx, by):
	if bx and by:
		g.ShowBubbleInView(DatumEnds.End1,v)
		g.HideBubbleInView(DatumEnds.End0,v)
	elif bx:
		g.HideBubbleInView(DatumEnds.End1,v)
		g.ShowBubbleInView(DatumEnds.End0,v)
	elif by:
		g.ShowBubbleInView(DatumEnds.End1,v)
		g.HideBubbleInView(DatumEnds.End0,v)	
	else:
		g.HideBubbleInView(DatumEnds.End0,v)
		g.ShowBubbleInView(DatumEnds.End1,v)
	
TransactionManager.Instance.TransactionTaskDone()

doc.Regenerate()

OUT = g

Grids Top Left_FG.dyn (18.3 KB)