Creates a light type object from the given document and element ID
Namespace: Autodesk.Revit.DB.LightingAssembly: RevitAPI (in RevitAPI.dll) Version: 22.0.0.0 (22.1.0.0)
Since:
2013
Syntax
Return Value
The newly created LightType object
Examples
CopyC#
public LightType GetLightTypeFromLightInstance(Document document)
{
if(document.IsFamilyDocument)
return null;
FilteredElementCollector collector = new FilteredElementCollector(document);
collector.OfClass(typeof(FamilyInstance)).OfCategory(BuiltInCategory.OST_LightingFixtures);
FamilyInstance lightFixture = collector.Cast<FamilyInstance>().First<FamilyInstance>();
if (lightFixture == null)
return null;
return LightType.GetLightTypeFromInstance(document, lightFixture.Id);
}
CopyVB.NET
Public Function GetLightTypeFromLightInstance(document As Document) As LightType
If document.IsFamilyDocument Then
Return Nothing
End If
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
Return Nothing
End If
Return LightType.GetLightTypeFromInstance(document, lightFixture.Id)
End Function
Exceptions
See Also