LightTypeGetLightTypeFromInstance Method |
Creates a light type object from the given document and element ID
Namespace: Autodesk.Revit.DB.LightingAssembly: RevitAPI (in RevitAPI.dll) Version: 25.0.0.0 (25.0.0.0)
Syntaxpublic static LightType GetLightTypeFromInstance(
Document document,
ElementId instanceId
)
Public Shared Function GetLightTypeFromInstance (
document As Document,
instanceId As ElementId
) As LightType
public:
static LightType^ GetLightTypeFromInstance(
Document^ document,
ElementId^ instanceId
)
static member GetLightTypeFromInstance :
document : Document *
instanceId : ElementId -> LightType
Parameters
- document Document
-
The document the instanceId is from
- instanceId ElementId
-
The ID of the light fixture instance
Return Value
LightType
The newly created LightType object
ExceptionsException | Condition |
---|
ArgumentException |
The ElementId is the argument that is being validated
The ElementId is not valid because it is not for a light element.
|
ArgumentNullException |
A non-optional argument was null
|
Examplepublic 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);
}
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
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
See Also