How to use the @bentley/imodeljs-backend.PhysicalModel.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
private _createStandalone(): string {
        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;