Due to this thread How to change Revision Visibility? I got curious as to how to set the visibility of Revisions with Python.
If I input Revision elements into this first script, it changes all of the Revision’s visibility to “Hidden” which is what I assume would be 0 in the RevisionVisibility enumeration (see here in the API docs http://www.revitapidocs.com/2016/486d8b1e-811d-fd43-d2a4-a4eef4e53538.htm )
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.Elements)
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
revisions = UnwrapElement(IN[0])
doc = DocumentManager.Instance.CurrentDBDocument
TransactionManager.Instance.EnsureInTransaction(doc)
newvisibility = []
for revision in revisions:
newvis = revision.Visibility = RevisionVisibility()
newvisibility.append(newvis)
TransactionManager.Instance.TransactionTaskDone()
OUT = revisions, newvisibility
Because of this I know that the Revision visibility can be modified with Python, but I cannot figure out how to get the members of RevisionVisibility. I tried to get an output with this code, but I get the Error “TypeError: RevisionVisibility is not iterable”:
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.Elements)
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
vislist = []
visibilityoptions = enumerate(RevisionVisibility())
vislist.append(visibilityoptions)
OUT = vislist
Am I missing some Python knowledge on how to list enumeration members, or does the error “TypeError: RevisionVisibility is not iterable” mean that it is just not possible for the RevisionVisibility enumeration?
If I could get the members, inputting Revision Elements, and a “Select Revision Visibility” node into the following code should in theory, work (I think - I might be trying to grab the members by index incorrectly in the lines that say visibility = vislist[0]
etc - someone please correct me if I am wrong )
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.Elements)
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
revisions = UnwrapElement(IN[0])
selectvisibility = UnwrapElement(IN[1])
doc = DocumentManager.Instance.CurrentDBDocument
visibilityoptions = enumerate(RevisionVisibility())
vislist.append(RevisionVisibility())
if selectvisibility == "Hidden":
visibility = vislist[0]
elif selectvisibility == "CloudAndTagVisible":
visibility = vislist[1]
else:
visibility = vislist[2]
TransactionManager.Instance.EnsureInTransaction(doc)
newvisibility = []
for revision in revisions:
newvis = revision.Visibility = visibility
newvisibility.append(newvis)
TransactionManager.Instance.TransactionTaskDone()
OUT = revisions, newvisibility, vislist
Anyone have any ideas/thoughts/suggestions? Maybe I am just trying to get the enumeration members incorrectly? Thank you in advance
EDIT: I had a thought (of course after leaving my office/computer with Dynamo) on something I didn’t think to try before posting because I was so thinking in my head the way the WallFunction enumeration works. I’m thinking maybe the code would work if I just omitted the enumeration (still not sure if I was trying to use that improperly) and changed:
if selectvisibility == "Hidden":
visibility = vislist[0]
elif selectvisibility == "CloudAndTagVisible":
visibility = vislist[1]
else:
visibility = vislist[2]
to:
if selectvisibility == "Hidden":
visibility = RevisionVisibility(Hidden)
elif selectvisibility == "CloudAndTagVisible":
visibility = RevisionVisibility(CloudAndTagVisible)
else:
visibility = RevisionVisibility(TagVisible)
I will have to try tomorrow unless someone else decides to test it before I get back to my computer with Dynamo before then