How to use the @bentley/imodeljs-backend.IModelDb.openStandalone function in @bentley/imodeljs-backend

To help you get started, we’ve selected a few @bentley/imodeljs-backend 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 / test-apps / synchro-schedule-importer / src / SynchroScheduleImporter.ts View on Github external
function doImport(inputArgs: Yargs.Arguments) {
  let originalIModel: IModelDb;

  try {
    originalIModel = IModelDb.openStandalone(inputArgs.input as string, inputArgs.createDuplicateIbim ? OpenMode.Readonly : OpenMode.ReadWrite); // could throw Error
  } catch (error) {
    process.stdout.write("Unable to open: " + inputArgs.input + "\n");
    return false;
  }

  let outputIModel = originalIModel;
  let outputFileName = inputArgs.input as string;
  if (inputArgs.createDuplicateIbim) {
    outputFileName = inputArgs.input + ".animated.ibim";
    IModelJsFs.copySync(inputArgs.input as string, outputFileName);
    outputIModel = IModelDb.openStandalone(outputFileName, OpenMode.ReadWrite);
  }
  try { unlinkSync(outputFileName + ".tiles"); } catch (error) { }
  if (inputArgs.fixRange)
    doFixRange(outputIModel);

  if (inputArgs.script) {
    if (doAddAnimationScript(outputIModel, inputArgs.script as string, inputArgs.createSeparateScript as boolean))
      process.stdout.write("Animation Script: " + inputArgs.script + " added to: " + outputFileName + "\n");
  }

  try {
    outputIModel.saveChanges();
  } catch (error) {
    process.stdout.write("Unable to save changes to: " + outputFileName + "\n");
  }
github imodeljs / imodeljs / test-apps / synchro-schedule-importer / src / SynchroScheduleImporter.ts View on Github external
function doImport(inputArgs: Yargs.Arguments) {
  let originalIModel: IModelDb;

  try {
    originalIModel = IModelDb.openStandalone(inputArgs.input as string, inputArgs.createDuplicateIbim ? OpenMode.Readonly : OpenMode.ReadWrite); // could throw Error
  } catch (error) {
    process.stdout.write("Unable to open: " + inputArgs.input + "\n");
    return false;
  }

  let outputIModel = originalIModel;
  let outputFileName = inputArgs.input as string;
  if (inputArgs.createDuplicateIbim) {
    outputFileName = inputArgs.input + ".animated.ibim";
    IModelJsFs.copySync(inputArgs.input as string, outputFileName);
    outputIModel = IModelDb.openStandalone(outputFileName, OpenMode.ReadWrite);
  }
  try { unlinkSync(outputFileName + ".tiles"); } catch (error) { }
  if (inputArgs.fixRange)
    doFixRange(outputIModel);
github imodeljs / imodeljs / example-code / snippets / src / backend / IModelTestUtils.ts View on Github external
const destPath = KnownTestLocations.outputDir;
    if (!IModelJsFs.existsSync(destPath))
      IModelJsFs.mkdirSync(destPath);

    if (opts === undefined)
      opts = {};

    const srcName = path.join(KnownTestLocations.assetsDir, filename);
    const dbName = path.join(destPath, (opts.copyFilename ? opts.copyFilename! : filename));
    const srcStat = IModelTestUtils.getStat(srcName);
    const destStat = IModelTestUtils.getStat(dbName);
    if (!srcStat || !destStat || srcStat.mtimeMs !== destStat.mtimeMs) {
      IModelJsFs.copySync(srcName, dbName, { preserveTimestamps: true });
    }

    const iModel: IModelDb = IModelDb.openStandalone(dbName, opts.openMode, opts.enableTransactions); // could throw Error
    assert.exists(iModel);
    return iModel!;
  }
github imodeljs / imodeljs / test-apps / imodel-from-geojson / src / GeoJsonImporter.ts View on Github external
public constructor(iModelFileName: string, geoJson: GeoJson, appendToExisting: boolean, modelName?: string, labelProperty?: string, pointRadius?: number, pseudoColor?: boolean, mapType?: string, mapGroundBias?: number,
    private _classifiedURL?: string, private _classifiedName?: string, private _classifiedOutside?: string, private _classifiedInside?: string) {
    this.iModelDb = appendToExisting ? IModelDb.openStandalone(iModelFileName, OpenMode.ReadWrite) : IModelDb.createSnapshot(iModelFileName, { rootSubject: { name: geoJson.title } });
    this._geoJson = geoJson;
    this._appendToExisting = appendToExisting;
    this._modelName = modelName;
    this._labelProperty = labelProperty;
    this._pointRadius = pointRadius === undefined ? .25 : pointRadius;
    this._colorIndex = pseudoColor ? 0 : undefined;
    this._viewFlags = new ViewFlags();
    this._viewFlags.renderMode = RenderMode.SmoothShade;
    switch (mapType) {
      case "none":
        this._viewFlags.backgroundMap = false;
        break;
      case "streets":
        this._viewFlags.backgroundMap = true;
        this._backgroundMap = { providerName: "BingProvider", groundBias: mapGroundBias, providerData: { mapType: BackgroundMapType.Street } };
        break;