writeLine Issue: "Line object cannot be serialized" issue when trying to write ANY line via the ifcApi
quasarchimaere opened this issue · 1 comments
Currently it is not possible to write (even unchanged lines) back to the model, this is due to a typo in the IFCWorker.js:87227
as you can clearly see there is a check for expressID
, type
and ToType
[sic] -> ToType
does not exist within a line Object and the code below states that it was actually meant to be ToTape
, once you change the clause to ToTape
it works just fine.
if (lineObject.expressID == void 0 || lineObject.type == void 0 || lineObject.ToType === void 0) {
console.warn("Line object cannot be serialized: ", lineObject);
return;
}
let rawLineData = {
ID: lineObject.expressID,
type: lineObject.type,
arguments: lineObject.ToTape()
};
this.WriteRawLineData(modelID, rawLineData);
-Hi, i use web-ifc-three@0.0.122 and web-ifc@0.0.36. I customized function "WriteLine", and did not use ifcworker.js(multi threading). Here is my code and it worked for me.
WriteLine(modelID, lineObject) {
var _this = this;
const ifcAPI = this.ifcManager.ifc.ifcAPI;
Object.keys(lineObject).forEach((propertyName) => {
let property = lineObject[propertyName];
if (property && property.expressID !== void 0) {
_this.WriteLine(modelID, property);
lineObject[propertyName] = {
type: 5,
value: property.expressID,
};
} else if (Array.isArray(property) && property.length > 0) {
for (let i = 0; i < property.length; i++) {
if (property[i].expressID !== void 0) {
_this.WriteLine(modelID, property[i]);
lineObject[propertyName][i] = {
type: 5,
value: property[i].expressID,
};
}
}
}
});
let rawLineData = {
ID: lineObject.expressID,
type: lineObject.type,
arguments: lineObject.ToTape(),
};
ifcAPI.WriteRawLineData(modelID, rawLineData);
}