Filtering "Null" Parameter Values

Hey all,

Trying to filter a list of all furniture and furniture system families (types/FamilySymbol, not instances) in a project down to only types that have an associated Type Mark. I’ve tried many different syntax methods, but I still end up with a few “blank” values in my list. I use quotes around blank because the logic is filtering out null values, so there must be a value, but I cannot figure out what it would be. If I go to the family types in question, the field is blank, and there’s nothing in the parameter value field to delete.

Any ideas as to what’s going on?

Edit: Inputs can be ignored. I removed the rest of the script as to not be confusing - I’m automating the create of furniture schedules later on down the script.

# Enable Python support and load DesignScript library
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

clr.AddReference('DSCoreNodes')
from DSCore import List

clr.AddReference('RevitNodes')
from Revit.Elements.Views import *

clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *

clr.AddReference('RevitServices')
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument

# The inputs to this node will be stored as a list in the IN variables.
fieldnames = IN[0]
prefix = IN[1]
texttype = IN[2]
phase = IN[3]
phasevis = IN[4]
fieldslst = []
fieldnameslst = []
schedules = []
output = []
errs = []

# collect furniture and furniture system familysymbols from document

collector1 = FilteredElementCollector(doc)
filter1 = ElementCategoryFilter(BuiltInCategory.OST_Furniture)
filter2 = ElementCategoryFilter(BuiltInCategory.OST_FurnitureSystems)
ffefilter = LogicalOrFilter(filter1, filter2)
types = collector1.WherePasses(ffefilter).WhereElementIsElementType().ToElements()

for type in types:
	typmrk = type.get_Parameter(BuiltInParameter.ALL_MODEL_TYPE_MARK)
	if typmrk.HasValue == True and (typmrk.AsString().startswith(' ') or typmrk.AsString().startswith('')):
		output.append(typmrk.AsString())
	

# Assign your output to the OUT variable.
OUT = output
	

String parameters are weird in that IF they have previously had a value then the HasValue will return true even if it’s empty because an empty string is technically something.

Instead of using startswith why not just check for empty?

typmrk.AsString() == ""

2 Likes

Hello, try this

if typmrk.HasValue and typmrk.AsString() is not None and typmrk.AsString().Length > 0:
1 Like

Note that this could leave you with a whitespace only Type Mark.

1 Like

Ah, great context @SeanP (regarding your HasValue comment). I had tried the technique you mention but didn’t seem to filter out the empty strings. Additionally, I realized that my script was missing a ‘not’ in there, but correcting it didn’t seem to change anything anyway. I wonder if the Length > 0 solution that @c.poupin mentioned did the trick in the end.

1 Like

@c.poupin That did the trick, needs to be very explicit. :slight_smile:

1 Like