ViewDefinition Class

The definition element for a view. ViewDefinitions specify the area/volume that is viewed, the Ids of a DisplayStyle and a CategorySelector, plus additional view-specific parameters in their Element.jsonProperties.

Subclasses of ViewDefinition determine which model(s) are viewed.

Example: Obtaining the background color for a view

/** Given a ViewDefinition, return its background color.
 * @param view The ViewDefinition of interest.
 * @return The background color for the view.
 * @note This is a convenience function intended to demonstrate the API. The background color is defined on the ViewDefinition's DisplayStyle. If multiple properties of the DisplayStyle are of interest, it would be more efficient to obtain the DisplayStyle via ViewDefinition.loadDisplayStyle() directly.
 */
function getViewBackgroundColor(view: ViewDefinition): ColorDef {
  const displayStyle: DisplayStyle = view.loadDisplayStyle(); // Load the view's display style from the IModelDb.
  return displayStyle.backgroundColor; // Extract the background color.
}

note ViewDefinition is only available in the backend. See ViewState for usage in the frontend.

Extends

Extended by

Implements

Methods

Name Description
isDrawingView(): boolean Type guard for 'instanceof DrawingViewDefinition'  
isSpatialView(): boolean Type guard for instanceof SpatialViewDefinition  
isView2d(): boolean Type guard for 'instanceof ViewDefinition2d`  
isView3d(): boolean Type guard for instanceof ViewDefinition3d  
loadCategorySelector(): CategorySelector Load this view's CategorySelector from the IModelDb.  
loadDisplayStyle(): DisplayStyle Load this view's DisplayStyle from the IModelDb.  
createCode(iModel: IModelDb, scopeModelId: CodeScopeProps, codeValue: string): Code Static Create a Code for a ViewDefinition given a name that is meant to be unique within the scope of the specified DefinitionModel.  

Inherited methods

Name Inherited from Description
buildConcurrencyControlRequest(opcode: DbOpcode): void Element Add a request for locks, code reservations, and anything else that would be needed to carry out the specified operation.
clone(): this Entity Make a deep copy of this Entity
delete(): void Element Delete this Element from the iModel.
forEachProperty(func: PropertyCallback, includeCustom: boolean = false): void Entity Call a function for each property of this Entity.
Element Get the class metadata for this element.
getDisplayLabel(): string Element Get a display label for this Element.
getJsonProperty(nameSpace: string): any Element Get a JSON property of this element, by namespace
getToolTipMessage(): string[] Element Get a list of HTML strings that describe this Element for the tooltip.
getUserProperties(namespace: string): any Element Get a set of JSON user properties by namespace
insert(): string Element Insert this Element into the iModel.
removeUserProperties(nameSpace: string): void Element Remove a set of JSON user properties, specified by namespace, from this Element
setJsonProperty(nameSpace: string, value: any): void Element  
setUserProperties(nameSpace: string, value: any): void Element Change a set of user JSON properties of this Element by namespace.
update(): void Element Update this Element in the iModel.
onAllInputsHandled(_id: Id64String, _iModel: IModelDb): void Static Element  
onBeforeOutputsHandled(_id: Id64String, _iModel: IModelDb): void Static Element  
onDelete(_props: ElementProps, _iModel: IModelDb): IModelStatus Static Element  
onDeleted(_props: ElementProps, _iModel: IModelDb): void Static Element  
onInsert(_props: ElementProps, _iModel: IModelDb): IModelStatus Static Element  
onInserted(_props: ElementProps, _iModel: IModelDb): void Static Element  
onUpdate(_props: ElementProps, _iModel: IModelDb): IModelStatus Static Element  
onUpdated(_props: ElementProps, _iModel: IModelDb): void Static Element  

Properties

Name Type Description
categorySelectorId Id64String The element Id of the CategorySelector for this ViewDefinition  
displayStyleId Id64String The element Id of the DisplayStyle for this ViewDefinition  

Inherited properties

Name Type Inherited from Description
classFullName Accessor ReadOnly string Entity Get the full BIS class name of this Entity in the form "schema:class".
classFullName Accessor StaticReadOnly string Entity Get the full BIS class name of this Entity in the form "schema:class"
className Accessor ReadOnly string Entity The name of the BIS class associated with this class.
code Code Element The Code for this element
federationGuid undefined | GuidString Element A FederationGuid assigned to this element by some other federated database
id Id64String Entity The Id of this Entity.
iModel IModelDb Entity The Entity.IModelDb that contains this Entity
isPrivate boolean DefinitionElement If true, don't show this DefinitionElement in user interface lists.
jsonProperties [key: string]: any Element Optional json properties of this element.
model Id64String Element The ModelId of the Model containing this element
parent undefined | RelatedElement Element The parent element, if present, of this element.
schema Static Schema Entity The Schema that defines this class.
schemaName Accessor ReadOnly string Entity The name of the BIS Schema that defines this class
userLabel undefined | string Element A user-assigned label for this element.

Defined in

Last Updated: 03 June, 2019