(filename)
| 8 | const ifcapi = new IfcAPI(); |
| 9 | |
| 10 | async function LoadFile(filename) { |
| 11 | // load model data as a string |
| 12 | |
| 13 | await ifcapi.Init(); |
| 14 | const ifcData = fs.readFileSync(filename); |
| 15 | |
| 16 | let modelID = ifcapi.OpenModel(ifcData); |
| 17 | |
| 18 | |
| 19 | |
| 20 | console.log(`Loaded model ${filename} to modelID ${modelID}`); |
| 21 | |
| 22 | let numLines = 0; |
| 23 | |
| 24 | |
| 25 | //Data types |
| 26 | |
| 27 | // enum IfcTokenType : char |
| 28 | // { |
| 29 | // UNKNOWN = 0, |
| 30 | // STRING = 1 |
| 31 | // LABEL = 2 |
| 32 | // ENUM = 3 |
| 33 | // REAL = 4 |
| 34 | // REF = 5 |
| 35 | // EMPTY = 6 |
| 36 | // SET_BEGIN |
| 37 | // SET_END |
| 38 | // LINE_END |
| 39 | // }; |
| 40 | |
| 41 | console.log(`Modify values`); |
| 42 | |
| 43 | //Change units |
| 44 | let units = ifcapi.GetLineIDsWithType(modelID, IFCSIUNIT); |
| 45 | for (let i = 0; i < units.size(); i++) { |
| 46 | let expressID = units.get(i); |
| 47 | const unit = await ifcapi.properties.getItemProperties(modelID, expressID); |
| 48 | unit.Prefix = { type: 3, value: 'MILLI' }; |
| 49 | ifcapi.WriteLine(modelID, unit); |
| 50 | } |
| 51 | |
| 52 | |
| 53 | //IfcProduct edition |
| 54 | let storeys = ifcapi.GetLineIDsWithType(modelID, IFCBUILDINGSTOREY); |
| 55 | for (let i = 0; i < storeys.size(); i++) { |
| 56 | numLines++; |
| 57 | let expressID = storeys.get(i); |
| 58 | const storey = await ifcapi.properties.getItemProperties(modelID, expressID); |
| 59 | storey.Description = new IFC2X3.IfcText('Description') |
| 60 | storey.Name = new IFC2X3.IfcLabel('Name') |
| 61 | storey.LongName = new IFC2X3.IfcText('Long name'); |
| 62 | ifcapi.WriteLine(modelID, storey); |
| 63 | } |
| 64 | |
| 65 | //IfcProperty edition |
| 66 | let properties = ifcapi.GetLineIDsWithType(modelID, IFCPROPERTYSINGLEVALUE) |
| 67 | for (let i = 0; i < properties.size(); i++) { |
no test coverage detected