How to use the @bentley/bentleyjs-core.Id64.invalid function in @bentley/bentleyjs-core

To help you get started, we’ve selected a few @bentley/bentleyjs-core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github imodeljs / imodeljs / core / common / src / Code.ts View on Github external
public static create(iModel: IModel, name: string, scopeType: CodeScopeSpec.Type, scopeReq?: CodeScopeSpec.ScopeRequirement): CodeSpec {
    return new CodeSpec(iModel, Id64.invalid, name, scopeType, scopeReq, undefined); // tslint:disable-line:deprecation
  }
github imodeljs / imodeljs / example-code / snippets / src / backend / WorkingWithViewDefinitions.ts View on Github external
// __PUBLISH_EXTRACT_END__

// __PUBLISH_EXTRACT_START__ ViewDefinition.getBackgroundColor
/** 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.settings.backgroundColor; // Extract the background color.
}
// __PUBLISH_EXTRACT_END__

const imodel = {} as IModelDb;
findViewsOfDrawingModel(imodel, Id64.invalid);
const fakeView = {} as ViewDefinition;
getViewBackgroundColor(fakeView);
github imodeljs / imodeljs / test-apps / analysis-importer / src / AnalysisImporter.ts View on Github external
/*---------------------------------------------------------------------------------------------
* Copyright (c) 2019 Bentley Systems, Incorporated. All rights reserved.
* Licensed under the MIT License. See LICENSE.md in the project root for license terms.
*--------------------------------------------------------------------------------------------*/
import { CategorySelector, DefinitionModel, DisplayStyle3d, IModelDb, ModelSelector, OrthographicViewDefinition, PhysicalModel, SpatialCategory } from "@bentley/imodeljs-backend";
import { GeometryStreamBuilder, GeometryStreamProps, Gradient, Code, GeometricElement3dProps, ViewFlags, ColorDef, RenderMode, AnalysisStyleProps } from "@bentley/imodeljs-common";
import { Id64, Id64String, Id64Array } from "@bentley/bentleyjs-core";
import { Angle, Polyface, IModelJson, AuxChannelDataType, AuxChannel, PolyfaceBuilder, Point3d, StrokeOptions, AuxChannelData, PolyfaceAuxData } from "@bentley/geometry-core";
import * as path from "path";
import { readFileSync } from "fs";

export class AnalysisImporter {
  public iModelDb: IModelDb;
  public definitionModelId: Id64String = Id64.invalid;

  public constructor(iModelFileName: string) {
    this.iModelDb = IModelDb.createSnapshot(iModelFileName, { rootSubject: { name: "Analysis Example" } });
  }
  /** Create a geometry stream from a Polyface. */
  private generateGeometryStreamFromPolyface(polyface: Polyface): GeometryStreamProps {
    const builder = new GeometryStreamBuilder();
    builder.appendGeometry(polyface);
    return builder.geometryStream;
  }

  /**  get [[AnalysisStyles] for a polyface.  This is just an example - it pairs displacement and scalar channels that have matching input names */
  private getPolyfaceAnalysisStyleProps(polyface: Polyface, displacementScaleValue: number): AnalysisStyleProps[] {
    const analysisStyleProps: AnalysisStyleProps[] = [];
    if (undefined === polyface.data.auxData)
      return analysisStyleProps;
github imodeljs / imodeljs / test-apps / display-test-app / src / frontend / ViewPicker.ts View on Github external
public clear(): void {
    super.clear();
    this._defaultViewId = Id64.invalid;
    this._views.clear();
  }
github imodeljs / imodeljs / test-apps / display-test-app / src / frontend / ViewPicker.ts View on Github external
}
    }

    if (Id64.isInvalid(this._defaultViewId) && 0 < this._array.length) {
      this._defaultViewId = this._array[0].id;
      const defaultViewId = await iModel.views.queryDefaultViewId();
      for (const spec of this) {
        if (spec.id === defaultViewId) {
          this._defaultViewId = defaultViewId;
          break;
        }
      }
    }

    if (Id64.isInvalid(this._defaultViewId))
      this.insert({ id: Id64.invalid, name: "Spatial View", class: SpatialViewState.classFullName });

    const selectedView = Id64.isInvalid(this._defaultViewId) ? this.manufactureSpatialView(iModel) : await iModel.views.load(this._defaultViewId);
    this._views.set(this._defaultViewId, selectedView);
  }
github imodeljs / imodeljs / core / backend / src / rpc-impl / IModelReadRpcImpl.ts View on Github external
public async getDefaultViewId(tokenProps: IModelTokenProps): Promise {
    const iModelToken = IModelToken.fromJSON(tokenProps);
    const spec = { namespace: "dgn_View", name: "DefaultView" };
    const blob = IModelDb.find(iModelToken).queryFilePropertyBlob(spec);
    if (undefined === blob || 8 !== blob.length)
      return Id64.invalid;

    const view = new Uint32Array(blob.buffer);
    return Id64.fromUint32Pair(view[0], view[1]);
  }
  public async getSpatialCategoryId(tokenProps: IModelTokenProps, categoryName: string): Promise {
github imodeljs / imodeljs / core / common / src / SubCategoryAppearance.ts View on Github external
constructor(props?: SubCategoryAppearance.Props) {
    if (!props) {
      this.color = ColorDef.black;
      this.weight = 0;
      this.priority = 0;
      this.transparency = 0;
      this.invisible = this.dontPlot = this.dontSnap = this.dontLocate = false;
      this.styleId = Id64.invalid;
      this.materialId = Id64.invalid;
      return;
    }

    this.invisible = JsonUtils.asBool(props.invisible);
    this.dontSnap = JsonUtils.asBool(props.dontSnap);
    this.dontLocate = JsonUtils.asBool(props.dontLocate);
    this.dontPlot = JsonUtils.asBool(props.dontPlot);
    this.color = ColorDef.fromJSON(props.color);
    this.weight = JsonUtils.asInt(props.weight);
    this.styleId = Id64.fromJSON(props.style);
    this.priority = JsonUtils.asInt(props.priority);
    this.materialId = Id64.fromJSON(props.material);
    this.transparency = JsonUtils.asInt(props.transp);
  }
github imodeljs / imodeljs / core / common / src / IModel.ts View on Github external
public static getDefaultSubCategoryId(categoryId: Id64String): Id64String {
    return Id64.isValid(categoryId) ? Id64.fromLocalAndBriefcaseIds(Id64.getLocalId(categoryId) + 1, Id64.getBriefcaseId(categoryId)) : Id64.invalid;
  }
github imodeljs / imodeljs / presentation / backend / src / RulesetEmbedder.ts View on Github external
private handleDuplicateRuleset(ruleset: Ruleset, duplicateHandlingStrategy: DuplicateRulesetHandlingStrategy, rulesetId: Id64String): Id64String {
    if (DuplicateRulesetHandlingStrategy.Skip === duplicateHandlingStrategy)
      return rulesetId;

    let rulesetElement;
    try {
      rulesetElement = this._iModelDb.elements.getElement(rulesetId);
    } catch (err) {
      return Id64.invalid;
    }

    rulesetElement.jsonProperties.jsonProperties = ruleset;
    rulesetElement.update();
    return rulesetId;
  }
github imodeljs / imodeljs / core / frontend / src / SpatialClassification.ts View on Github external
private createId(classifiers: SpatialClassifiers): ClassifierTreeId {
    const active = classifiers.active;
    return {
      modelId: undefined !== active ? active.modelId : Id64.invalid,
      type: BatchType.PlanarClassifier,
      expansion: undefined !== active ? active.expand : 0,
    };
  }
}