MCPcopy Create free account
hub / github.com/ThatOpen/engine_web-ifc / CreateModel

Method CreateModel

src/ts/web-ifc-api.ts:554–601  ·  view source on GitHub ↗

* Creates a new model and returns a modelID number * @param schema ifc schema version * @returns ModelID

(model: NewIfcModel, settings?: LoaderSettings)

Source from the content-addressed store, hash-verified

552 * @returns ModelID
553 */
554 CreateModel(model: NewIfcModel, settings?: LoaderSettings): number {
555 let s = this.CreateSettings(settings);
556 let result = this.wasmModule.CreateModel(s);
557 let id = this.LookupSchemaId(model.schema);
558 if (id == -1) {
559 Log.error("Unsupported Schema:" + model.schema);
560 this.CloseModel(result);
561 return -1;
562 }
563 this.modelSchemaList[result] = id;
564 this.modelSchemaNameList[result] = model.schema;
565 this.deletedLines.set(result, new Set());
566 const modelName = model.name || "web-ifc-model-" + result + ".ifc";
567 const timestamp = new Date().toISOString().slice(0, 19);
568 const description = model.description?.map((d) => ({
569 type: STRING,
570 value: d,
571 })) || [{ type: STRING, value: "ViewDefinition [CoordinationView]" }];
572 const authors = model.authors?.map((a) => ({ type: STRING, value: a })) || [
573 null,
574 ];
575 const orgs = model.organizations?.map((o) => ({
576 type: STRING,
577 value: o,
578 })) || [null];
579 const auth = model.authorization
580 ? { type: STRING, value: model.authorization }
581 : null;
582
583 this.wasmModule.WriteHeaderLine(result, FILE_DESCRIPTION, [
584 description,
585 { type: STRING, value: "2;1" },
586 ]);
587 this.wasmModule.WriteHeaderLine(result, FILE_NAME, [
588 { type: STRING, value: modelName },
589 { type: STRING, value: timestamp },
590 authors,
591 orgs,
592 { type: STRING, value: "thatopen/web-ifc-api" },
593 { type: STRING, value: "thatopen/web-ifc-api" },
594 auth,
595 ]);
596 this.wasmModule.WriteHeaderLine(result, FILE_SCHEMA, [
597 [{ type: STRING, value: model.schema }],
598 ]);
599
600 return result;
601 }
602
603 /**
604 * Saves a model to a Buffer

Callers 3

WebIfcApi.spec.tsFile · 0.45
Columns.spec.tsFile · 0.45
runCodeFunction · 0.45

Calls 3

CreateSettingsMethod · 0.95
LookupSchemaIdMethod · 0.95
CloseModelMethod · 0.95

Tested by

no test coverage detected