This class encapsulates light information.
Namespace: Autodesk.Revit.DB.Lighting
Assembly: RevitAPI (in RevitAPI.dll) Version: 2015.0.0.0 (2015.0.0.0)
Since: 2013
Syntax
C# |
---|
|
Visual Basic |
---|
|
Visual C++ |
---|
|
Examples

public void GetLightData(Document document)
{
// This code demonstrates how to get light information from project and family document
LightType lightData = null;
if (document.IsFamilyDocument)
{
// In family document, get LightType via LightFamily.GetLightType(int) method.
LightFamily lightFamily = LightFamily.GetLightFamily(document);
for (int index = 0; index < lightFamily.GetNumberOfLightTypes(); index++)
{
lightData = lightFamily.GetLightType(index);
}
}
else
{
// In family document, get LightType via GetLightTypeFromInstance or GetLightType method.
// In order to get the light information, please get a light fixture instance first
FilteredElementCollector collector = new FilteredElementCollector(document);
collector.OfClass(typeof(FamilyInstance)).OfCategory(BuiltInCategory.OST_LightingFixtures);
FamilyInstance lightFixture = collector.Cast<FamilyInstance>().First<FamilyInstance>();
if (lightFixture == null) // check null reference
return;
// Get the LightType for given light fixture
lightData = LightType.GetLightTypeFromInstance(document, lightFixture.Id);
}
// Get the light data via LightType
Color filterColor = lightData.ColorFilter; // get the ColorFilter property
LossFactor lossFactor = lightData.GetLossFactor(); // get the loss factor
if (lossFactor is AdvancedLossFactor)
{
AdvancedLossFactor advancedFactor = lossFactor as AdvancedLossFactor;
double luminaireValue = advancedFactor.LuminaireDirtDepreciation;
}
}

Public Sub GetLightData(document As Document)
' This code demonstrates how to get light information from project and family document
Dim lightData As LightType = Nothing
If document.IsFamilyDocument Then
' In family document, get LightType via LightFamily.GetLightType(int) method.
Dim lightFamily__1 As LightFamily = LightFamily.GetLightFamily(document)
For index As Integer = 0 To lightFamily__1.GetNumberOfLightTypes() - 1
lightData = lightFamily__1.GetLightType(index)
Next
Else
' In family document, get LightType via GetLightTypeFromInstance or GetLightType method.
' In order to get the light information, please get a light fixture instance first
Dim collector As New FilteredElementCollector(document)
collector.OfClass(GetType(FamilyInstance)).OfCategory(BuiltInCategory.OST_LightingFixtures)
Dim lightFixture As FamilyInstance = collector.Cast(Of FamilyInstance)().First()
If lightFixture Is Nothing Then
' check null reference
Return
End If
' Get the LightType for given light fixture
lightData = LightType.GetLightTypeFromInstance(document, lightFixture.Id)
End If
' Get the light data via LightType
Dim filterColor As Color = lightData.ColorFilter
' get the ColorFilter property
Dim lossFactor As LossFactor = lightData.GetLossFactor()
' get the loss factor
If TypeOf lossFactor Is AdvancedLossFactor Then
Dim advancedFactor As AdvancedLossFactor = TryCast(lossFactor, AdvancedLossFactor)
Dim luminaireValue As Double = advancedFactor.LuminaireDirtDepreciation
End If
End Sub