-
-
Notifications
You must be signed in to change notification settings - Fork 900
Expand file tree
/
Copy path__main__.py
More file actions
81 lines (73 loc) · 2.38 KB
/
__main__.py
File metadata and controls
81 lines (73 loc) · 2.38 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import argparse
import ifcopenshell
from ifc4d.msp2ifc import MSP2Ifc
from ifc4d.p6xer2ifc import P6XER2Ifc
from ifc4d.p62ifc import P62Ifc
from ifc4d.pp2ifc import PP2Ifc
parser = argparse.ArgumentParser()
parser.add_argument("-f", "--file", action="store", type=str, required=True, help="schedule file name to be parsed")
parser.add_argument(
"-s", "--schedule", action="store", required=True, type=str, help="file format as xer, p6xml, mspxml, pp"
)
parser.add_argument(
"-i", "--ifcfile", action="store", required=False, type=str, help='ifc file name as string e.g. "file.ifc"'
)
parser.add_argument(
"-o", "--output", action="store", required=True, type=str, help='ifc file name as string e.g. "file.ifc"'
)
args = parser.parse_args()
def get_file():
ifcfile = None
if args.ifcfile:
ifcfile = ifcopenshell.open(args.ifcfile)
elif args.output:
ifc = ifcopenshell.file(schema="IFC4")
ifc.create_entity("IfcWorkPlan")
ifc.create_entity("IfcProject")
ifc.write(args.output)
ifcfile = ifcopenshell.open(args.output)
else:
ifcfile = None
return ifcfile
if not args.ifcfile:
print("You need to provide an ifc file to add schedule")
print("Examples python ifc4d -i model.ifc -s xer -f schedule.xer -o newifc.ifc")
elif not args.output:
print("an output file is required to save changes")
print("python ifc4d -o newfile.ifc -s xer -f schedule.xer")
elif args.schedule == "xer":
p6xer = P6XER2Ifc()
p6xer.xer = args.file
p6xer.output = args.output
ifcfile = get_file()
if ifcfile:
p6xer.file = ifcfile
p6xer.execute()
else:
raise Exception("No files provided for output")
elif args.schedule == "mspxml":
msp = MSP2Ifc()
msp.xml = args.file()
msp.output = args.output
ifcfile = get_file()
if ifcfile:
msp.file = ifcfile
msp.execute()
elif args.schedule == "p6xml":
p6xml = P62Ifc()
p6xml.output = args.output
p6xml.xml = args.file
ifcfile = get_file()
if ifcfile:
p6xml.file = ifcopenshell.open(args.ifcfile)
p6xml.execute()
elif args.schedule == "pp":
pp = PP2Ifc()
pp.output = args.output
pp.pp = args.file
ifcfile = get_file()
if ifcfile:
pp.file = ifcopenshell.open(args.ifcfile)
pp.execute()
else:
print("schedule type you selected is not implemented at the moment")