tryGetElement Method

Get an element by Id, FederationGuid, or Code

tryGetElement<T extends Element>(elementId: Id64String | GuidString | Code | ElementLoadProps): T extends Element | undefined

throws IModelError if the element exists, but cannot be loaded.

note Useful for cases when an element may or may not exist and throwing an Error would be overkill.

see IModelDb.Elements.getElement

Parameter Type Description
elementId Id64String | GuidString | Code | ElementLoadProps either the element's Id, Code, or FederationGuid, or an ElementLoadProps

Returns - T extends Element | undefined

The element or undefined if the element is not found.

Defined in

Last Updated: 13 June, 2024