Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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 {
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;
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 */
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);
}
}
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);
}
}
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 */