GetLightType Method
Creates a light type object from the given document and family type ID

Namespace: Autodesk.Revit.DB.Lighting
Assembly: RevitAPI (in RevitAPI.dll) Version: 23.0.0.0 (23.1.0.0)
Since:  2013

Syntax

C#
public static LightType GetLightType(
	Document document,
	ElementId typeId
)
Visual Basic
Public Shared Function GetLightType ( _
	document As Document, _
	typeId As ElementId _
) As LightType
Visual C++
public:
static LightType^ GetLightType(
	Document^ document, 
	ElementId^ typeId
)

Parameters

document
Type: Autodesk.Revit.DB..::..Document
The document the typeId is from
typeId
Type: Autodesk.Revit.DB..::..ElementId
The ID of the light family type

Return Value

The newly created LightType object

Examples

CopyC#
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);
}
CopyVB.NET
Public Function GetLightTypeFromLightSymbol(document As Document) As LightType
   If document.IsFamilyDocument Then
      ' not used in family document
      Return Nothing
   End If

   ' In order to get the light infromation, please get a light fixture symbol first
   Dim collector As New FilteredElementCollector(document)
   collector.OfClass(GetType(FamilySymbol)).OfCategory(BuiltInCategory.OST_LightingFixtures)
   Dim lightSymbo As FamilySymbol = collector.Cast(Of FamilySymbol)().First()
   If lightSymbo Is Nothing Then
      ' check null reference
      Return Nothing
   End If

   ' Get the LightType for given light fixture sybmol
   Return LightType.GetLightType(document, lightSymbo.Id)
End Function

Exceptions

ExceptionCondition
Autodesk.Revit.Exceptions..::..ArgumentException The ElementId is the argument that is being validated The ElementId is not valid because it is not for a light element.
Autodesk.Revit.Exceptions..::..ArgumentNullException A non-optional argument was null

See Also