Viewport labels? I am not sure I know what that is, but I will make a guess that you are asking about turning off the Viewport Titles:
If that’s indeed the case, then the easiest way would be to make a Viewport Type that hides the title. For example:
Once you have that ready, you would want to change the Viewport Type for the selected Viewports like this:
Python code:
# Copyright(c) 2019, Konrad K Sobon
# @arch_laboratory, http://archi-lab.net
import clr
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
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *
import sys
pyt_path = r'C:\Program Files (x86)\IronPython 2.7\Lib'
sys.path.append(pyt_path)
def ProcessList(_func, _list):
return map( lambda x: ProcessList(_func, x) if type(x)==list else _func(x), _list )
def ProcessListArg(_func, _list, _arg):
return map( lambda x: ProcessListArg(_func, x, _arg) if type(x)==list else _func(x, _arg), _list )
def Unwrap(item):
return UnwrapElement(item)
def ChangeViewportType(vp, newVp):
vp.ChangeTypeId(newVp.Id)
return vp
if isinstance(IN[0], list):
viewports = ProcessList(Unwrap, IN[0])
else:
viewports = [Unwrap(IN[0])]
vpName = IN[1]
try:
errorReport = None
allVp = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Viewports).ToElements()
validTypeIds = allVp[0].GetValidTypes()
validTypes = []
for i in validTypeIds:
validTypes.append(doc.GetElement(i))
selectedVp = next((x for x in validTypes if x.ToDSType(True).Name == vpName), None)
TransactionManager.Instance.EnsureInTransaction(doc)
output = ProcessListArg(ChangeViewportType, viewports, selectedVp)
TransactionManager.Instance.TransactionTaskDone()
except:
import traceback
errorReport = traceback.format_exc()
if errorReport == None:
OUT = output
else:
OUT = errorReport
Hope this helps.
Cheers!