How to use the @bentley/imodeljs-backend.DisplayStyle3d.insert 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 / agent-test-app / src / changeSetUtility / ChangesetGenerationHarness.ts View on Github external
const pathname: string = path.join(this._localIModelDbPath, this._iModelName + ".bim");
        if (fs.existsSync(pathname))
            fs.unlinkSync(pathname);

        this._iModelDb = IModelDb.createStandalone(pathname, { rootSubject: { name: this._iModelName } });

        const definitionModelId: Id64String = IModel.dictionaryId;
        this._physicalModelId = PhysicalModel.insert(this._iModelDb, IModel.rootSubjectId, "TestModel");
        this._codeSpecId = this._iModelDb.codeSpecs.insert("TestCodeSpec", CodeScopeSpec.Type.Model);
        this._categoryId = SpatialCategory.insert(this._iModelDb, definitionModelId, "TestCategory", { color: new ColorDef("blanchedAlmond") });

        // Insert a ViewDefinition for the PhysicalModel
        const viewName = "Physical View";
        const modelSelectorId: Id64String = ModelSelector.insert(this._iModelDb, definitionModelId, viewName, [this._physicalModelId]);
        const categorySelectorId: Id64String = CategorySelector.insert(this._iModelDb, definitionModelId, viewName, [this._categoryId]);
        const displayStyleId: Id64String = DisplayStyle3d.insert(this._iModelDb, definitionModelId, viewName);
        const viewRange = new Range3d(0, 0, 0, 50, 50, 50);
        OrthographicViewDefinition.insert(this._iModelDb, definitionModelId, viewName, modelSelectorId, categorySelectorId, displayStyleId, viewRange);

        this._iModelDb.updateProjectExtents(new Range3d(-1000, -1000, -1000, 1000, 1000, 1000));
        this._iModelDb.saveChanges("Setup new iModel");
        this._iModelDb.closeStandalone();
        this._iModelDb = undefined;

        return pathname;
    }
    private _initializeLogger(): void {
github imodeljs / imodeljs / test-apps / synchro-schedule-importer / src / SynchroScheduleImporter.ts View on Github external
iModel.views.iterateViews({ from: "BisCore.SpatialViewDefinition" }, (view: ViewDefinition) => {
    if (!view.isSpatialView())
      return true;

    // Create a new display style.
    const vf = new ViewFlags();
    vf.renderMode = RenderMode.SmoothShade;
    vf.cameraLights = true;
    const bgColor = new ColorDef("rgb(127, 127, 127)");

    const displayStyleId = DisplayStyle3d.insert(iModel, view.model, "Schedule View Style", { viewFlags: vf, backgroundColor: bgColor, scheduleScript: script });
    iModel.views.setDefaultViewId(SpatialViewDefinition.insertWithCamera(iModel, view.model, "Schedule View", view.modelSelectorId, view.categorySelectorId, displayStyleId, iModel.projectExtents, StandardViewIndex.Iso));
    return true;
  });
  return true;
github imodeljs / imodeljs / test-apps / analysis-importer / src / AnalysisImporter.ts View on Github external
const displayStyleIds: Id64Array = [];
    const names = [];
    for (const analysisStyleProp of analysisStyleProps) {
      let name = analysisStyleProp.scalarChannelName!;
      if (undefined !== analysisStyleProp.displacementChannelName) {
        const exaggeration = (analysisStyleProp.displacementScale === 1.0) ? "" : (" X " + analysisStyleProp.displacementScale);
        name = modelName + ": " + name + " and " + analysisStyleProp.displacementChannelName + exaggeration;
      }
      names.push(name);
      displayStyleIds.push(DisplayStyle3d.insert(this.iModelDb, this.definitionModelId, name, { viewFlags: vf, backgroundColor: bgColor, analysisStyle: analysisStyleProp }));
    }
    const modelSelectorId = ModelSelector.insert(this.iModelDb, this.definitionModelId, modelName, [modelId]);
    const categorySelectorId = CategorySelector.insert(this.iModelDb, this.definitionModelId, modelName, [categoryId]);

    DisplayStyle3d.insert(this.iModelDb, this.definitionModelId, modelName + ": No AuxData", { viewFlags: vf, backgroundColor: bgColor });
    return OrthographicViewDefinition.insert(this.iModelDb, this.definitionModelId, modelName, modelSelectorId, categorySelectorId, displayStyleIds[0], polyface.range());
  }
  /** Import a polyface with auxillary data */
github imodeljs / imodeljs / test-apps / imodel-from-reality-model / src / RealityModelContextIModelCreator.ts View on Github external
protected insertSpatialView(viewName: string, range: AxisAlignedBox3d, realityModels: ContextRealityModelProps[], geoLocated: boolean): Id64String {
    const modelSelectorId: Id64String = ModelSelector.insert(this.iModelDb, this.definitionModelId, viewName, [this.physicalModelId]);
    const categorySelectorId: Id64String = CategorySelector.insert(this.iModelDb, this.definitionModelId, viewName, []);
    const vf = new ViewFlags();
    vf.backgroundMap = geoLocated;
    vf.renderMode = RenderMode.SmoothShade;
    vf.cameraLights = true;
    const displayStyleId: Id64String = DisplayStyle3d.insert(this.iModelDb, this.definitionModelId, viewName, { viewFlags: vf, contextRealityModels: realityModels });
    return OrthographicViewDefinition.insert(this.iModelDb, this.definitionModelId, viewName, modelSelectorId, categorySelectorId, displayStyleId, range, StandardViewIndex.Iso);
  }
}
github imodeljs / imodeljs / test-apps / imodel-from-geojson / src / GeoJsonImporter.ts View on Github external
protected insertSpatialView(viewName: string, range: AxisAlignedBox3d): Id64String {
    const modelSelectorId: Id64String = ModelSelector.insert(this.iModelDb, this.definitionModelId, viewName, [this.physicalModelId]);
    const categorySelectorId: Id64String = CategorySelector.insert(this.iModelDb, this.definitionModelId, viewName, [this.featureCategoryId]);
    const displayStyleId: Id64String = DisplayStyle3d.insert(this.iModelDb, this.definitionModelId, viewName, { viewFlags: this._viewFlags, backgroundMap: this._backgroundMap });
    return OrthographicViewDefinition.insert(this.iModelDb, this.definitionModelId, viewName, modelSelectorId, categorySelectorId, displayStyleId, range, StandardViewIndex.Top);
  }
}
github imodeljs / imodeljs / test-apps / analysis-importer / src / AnalysisImporter.ts View on Github external
classFullName: "Generic:PhysicalObject",
      category: categoryId,
      geom: geometry,
    };
    this.iModelDb.elements.insertElement(props);

    const displayStyleIds: Id64Array = [];
    const names = [];
    for (const analysisStyleProp of analysisStyleProps) {
      let name = analysisStyleProp.scalarChannelName!;
      if (undefined !== analysisStyleProp.displacementChannelName) {
        const exaggeration = (analysisStyleProp.displacementScale === 1.0) ? "" : (" X " + analysisStyleProp.displacementScale);
        name = modelName + ": " + name + " and " + analysisStyleProp.displacementChannelName + exaggeration;
      }
      names.push(name);
      displayStyleIds.push(DisplayStyle3d.insert(this.iModelDb, this.definitionModelId, name, { viewFlags: vf, backgroundColor: bgColor, analysisStyle: analysisStyleProp }));
    }
    const modelSelectorId = ModelSelector.insert(this.iModelDb, this.definitionModelId, modelName, [modelId]);
    const categorySelectorId = CategorySelector.insert(this.iModelDb, this.definitionModelId, modelName, [categoryId]);

    DisplayStyle3d.insert(this.iModelDb, this.definitionModelId, modelName + ": No AuxData", { viewFlags: vf, backgroundColor: bgColor });
    return OrthographicViewDefinition.insert(this.iModelDb, this.definitionModelId, modelName, modelSelectorId, categorySelectorId, displayStyleIds[0], polyface.range());
  }
  /** Import a polyface with auxillary data */