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
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
I am new to python in Dynamo and I am trying this script for turning the bubbles off on one side. I am getting this error and I have tried a few things but it would not work for me. Could you please help me with this error in line 45 with the code you have provided.I appreciate any help.