Make Grey Key Schedule Values False

This came up in the office and I thought it was fun…

I don’t know of a native Revit way to do it.


import clr
from Autodesk.DesignScript.Geometry import *

# Import RevitAPI
import Autodesk
from Autodesk.Revit.DB import *

# Import DocumentManager and TransactionManager
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

# Assign input to the IN variables
scheduleKeyWord = IN[0]

doc = DocumentManager.Instance.CurrentDBDocument

# Start the Transaction

projectViews = FilteredElementCollector(doc).OfClass(View).ToElements()

#get all the view schedules
for view in projectViews:
    if not view.IsTemplate and view.ViewType == ViewType.Schedule: 
        if scheduleKeyWord in view.Name: 
            schedule = view

element = FilteredElementCollector(doc, schedule.Id).ToElements()

#we want as many false values as there are empty values
output = []

params = []
for i in element:
    for param in params:
    #    output.append(param.StorageType)
        iterator = param.ForwardIterator()
        while iterator.MoveNext():
            p = iterator.Current
            type = p.Definition.ParameterType
            if type == ParameterType.YesNo:
                value = p.AsInteger()
                if value == 0:
                    name = p.Definition.Name
                    type = p.Definition.ParameterType
                    value = p.AsValueString()

# End the Transaction

# Assign your output to the OUT variable
OUT = schedule, output

This is one of the silly things Revit does. When you have a Yes/No field, it comes in as Null (so really Yes/No has 3 possible values, Yes/No/Null.

However, once you set the value to True (or False) - it can never return to Null. And actually having null would be a handy thing to have in a lot of cases. It can be used as QQA/QC to show those items that need a decision. As it is - you get a blank, a Yes and a No on the schedule. Often it would be nice to have a Yes, No, back to < blank > toggle at the user level - because we want it blank. So everyone ends up putting additional parameters in to do an X or something in anther field that responds to True. It would also be nice to have the schedule format Yes/No as X / Blank or Square or Circle.

You can’t even use the ClearValue() method to set it back to null. Kinda sucks.

also we can check the ‘grey state’ (the parameter has no assigned value) with HasValue property (only get)

1 Like