LightType.GetLightType
Description:
Creates a light type object from the given document and family type ID
Creates a light type object from the given document and family type ID
-
documentThe document the typeId is from
-
typeIdThe ID of the light family type
public LightType GetLightTypeFromLightSymbol(Document document)
{
if (document.IsFamilyDocument) // not used in family document
return null;
// In order to get the light infromation, please get a light fixture symbol first
FilteredElementCollector collector = new FilteredElementCollector(document);
collector.OfClass(typeof(FamilySymbol)).OfCategory(BuiltInCategory.OST_LightingFixtures);
FamilySymbol lightSymbo = collector.Cast<FamilySymbol>().First<FamilySymbol>();
if (lightSymbo == null) // check null reference
return null;
// Get the LightType for given light fixture sybmol
return LightType.GetLightType(document, lightSymbo.Id);
}
-
The ElementId is the argument that is being validated The ElementId is not valid because it is not for a light element.
-
A non-optional argument was null