iterateViews Method

Iterate all ViewDefinitions matching the supplied query.

iterateViews(params: ViewQueryParams, callback: (view: ViewDefinition) => boolean): boolean

Parameter Type Description
params ViewQueryParams Specifies the query by which views are selected.
callback (view: ViewDefinition) => boolean Function invoked for each ViewDefinition matching the query. Return false to terminate iteration, true to continue.

Returns - true if all views were iterated, false if iteration was terminated early due to callback returning false.

Example: Finding all views of a specific DrawingModel

 * Return an array of all views of a specified drawing model.
 * @param iModel The IModelDb in which to query
 * @param drawingModelId The Id of the DrawingModel of interest
 * @param includePrivate Whether or not to include views marked as 'private'
 * @return An array of all of the views which are configured to view the specified drawing model.
function findViewsOfDrawingModel(iModel: IModelDb, drawingModelId: Id64String, includePrivate: boolean = false): DrawingViewDefinition[] {
  let where = "BaseModel.Id=" + drawingModelId; // Limit query to those views which look at the specified model
  if (!includePrivate)
    where += " AND IsPrivate=FALSE"; // Exclude private views if specified

  const views: DrawingViewDefinition[] = [];
  const params: ViewQueryParams = { from: "BisCore.DrawingViewDefinition", where };
  iModel.views.iterateViews(params, (view: ViewDefinition) => {
    if (view.isDrawingView())

    return true; // indicates we want to continue iterating the set of views.

  return views;

Defined in

Last Updated: 03 June, 2019