-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathifc2xkt.js
executable file
·57 lines (39 loc) · 1.61 KB
/
ifc2xkt.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env node
const commander = require('commander');
const package = require('./package.json');
const {convertIFCFileAndMetaModelToXKT} = require("./src/convertIFCFileAndMetaModelToXKT.js");
const {convertIFCFileToXKT} = require("./src/convertIFCFileToXKT.js");
const program = new commander.Command();
program.version(package.version, '-v, --version');
program
.option('-s, --source [file]', 'path to the source IFC file')
.option('-m, --metamodel [file]', 'path to source metamodel JSON file (optional workaround until web-ifc parses IFC properties)')
.option('-o, --output [file]', 'path to the target XKT file');
program.on('--help', () => {
});
program.parse(process.argv);
if (program.source === undefined) {
console.error('\n\nError: please specify source IFC path.');
program.help();
process.exit(1);
}
if (program.output === undefined) {
console.error('\n\nError: please specify output XKT path.');
program.help();
process.exit(1);
}
async function main() {
console.log('\n\nReading IFC file: ' + program.source);
if (program.metamodel) { // Temporary until web-ifc parses IFC properties
console.log('\n\nReading metamodel file: ' + program.metamodel);
console.log('\n\nWriting XKT file: ' + program.output);
await convertIFCFileAndMetaModelToXKT(program.source, program.metamodel, program.output);
} else {
console.log('\n\nWriting XKT file: ' + program.output);
await convertIFCFileToXKT(program.source, program.output);
}
}
main().catch(err => {
console.error('Something went wrong:', err);
process.exit(1);
});