Ifc4D xer calendars (#1832)

* P6XML Parser failing on calendar type

* add work plan references a get_person which is not an attribute. modified to get_user to work

* Initial support for Primavera XER files

* IFC4D impl XER calendars exceptions and work time

Co-authored-by: Dion Moult <dion@thinkmoult.com>
This commit is contained in:
HassanEmam
2021-10-27 00:13:50 +01:00
committed by GitHub
parent f64e1dbd7f
commit 04b3b9b60e
3 changed files with 51 additions and 19 deletions
+14
View File
@@ -240,6 +240,20 @@ endif
cp -r dist/working/lark-parser-0.8.5/lark dist/blenderbim/libs/site/packages/ cp -r dist/working/lark-parser-0.8.5/lark dist/blenderbim/libs/site/packages/
rm -rf dist/working rm -rf dist/working
# Required by IFC4D
mkdir dist/working
cd dist/working && wget https://files.pythonhosted.org/packages/b0/bb/9c4dddd3ca173cb56241cfb2eddfae24690dc676d357ac4cab17d0a36d9d/PyP6Xer-1.13.0.tar.gz
cd dist/working && tar -xzvf xerparser*
cp -r dist/working/xerparser-1.13.0/xerparser dist/blenderbim/libs/site/packages/
rm -rf dist/working
# Required by xerparser and IFC4D
mkdir dist/working
cd dist/working && wget https://files.pythonhosted.org/packages/9f/7b/76c4e5ef1a1b528fcaada4133f972e77d33c252831676cf414119ca6093d/tqdm-4.50.0.tar.gz
cd dist/working && tar -xzvf tqdm*
cp -r dist/working/tqdm-4.50.0/tqdm dist/blenderbim/libs/site/packages/
rm -rf dist/working
# Required by IFCClash # Required by IFCClash
mkdir dist/working mkdir dist/working
cd dist/working && wget $(HPPFCL_URL) cd dist/working && wget $(HPPFCL_URL)
@@ -1097,6 +1097,26 @@ class ImportP6(bpy.types.Operator, ImportHelper):
print("Import finished in {:.2f} seconds".format(time.time() - start)) print("Import finished in {:.2f} seconds".format(time.time() - start))
return {"FINISHED"} return {"FINISHED"}
class ImportP6XER(bpy.types.Operator, ImportHelper):
bl_idname = "import_p6xer.bim"
bl_label = "Import P6 XER"
bl_options = {"REGISTER", "UNDO"}
filename_ext = ".xer"
filter_glob: bpy.props.StringProperty(default="*.xer", options={"HIDDEN"})
def execute(self, context):
from ifc4d.p6xer2ifc import P6XER2Ifc
self.file = IfcStore.get_file()
start = time.time()
p6xer2ifc = P6XER2Ifc()
p6xer2ifc.xer = self.filepath
p6xer2ifc.file = self.file
p6xer2ifc.work_plan = self.file.by_type("IfcWorkPlan")[0] if self.file.by_type("IfcWorkPlan") else None
p6xer2ifc.execute()
Data.load(IfcStore.get_file())
print("Import finished in {:.2f} seconds".format(time.time() - start))
return {"FINISHED"}
class ImportP6XER(bpy.types.Operator, ImportHelper): class ImportP6XER(bpy.types.Operator, ImportHelper):
bl_idname = "import_p6xer.bim" bl_idname = "import_p6xer.bim"
+17 -19
View File
@@ -20,7 +20,7 @@ from xerparser.reader import Reader
import ifcopenshell import ifcopenshell
import ifcopenshell.api import ifcopenshell.api
import ifcopenshell.util.date import ifcopenshell.util.date
from datetime import datetime, time, timedelta from datetime import datetime, timedelta, date
class P6XER2Ifc(): class P6XER2Ifc():
@@ -93,7 +93,8 @@ class P6XER2Ifc():
self.parse_wbs_xer() self.parse_wbs_xer()
self.parse_activity_xer() self.parse_activity_xer()
self.parse_relationship_xer() self.parse_relationship_xer()
work_schedule = self.create_work_schedule() #work_schedule = self.create_work_schedule()
#self.create_tasks(work_schedule)
def parse_wbs_xer(self): def parse_wbs_xer(self):
@@ -110,18 +111,16 @@ class P6XER2Ifc():
def parse_calendar_xer(self): def parse_calendar_xer(self):
standard_work_week = [] standard_work_week = []
exceptions = {}
for cal in self.model.calendars: for cal in self.model.calendars:
standard_work_week = [] standard_work_week = cal.working_hours
for k,v in cal.working_days.items(): #TODO: add work times except_lst = cal.exceptions
standard_work_week.append({ for exception in except_lst:
"DayOfWeek": self.day_map2[k], month = exceptions.setdefault(exception.year, {}).setdefault(exception.month, {})
"WorkTimes": [{ month.setdefault("FullDay", [])
"Start": time(8, 0), month.setdefault("WorkTime", [])
"Finish": time(16, 0) exceptions[exception.year][exception.month]["FullDay"].append(exception.day)
}] if not v else [],
"ifc": None,
})
exceptions = {} #TODO: to be implemented
self.calendars[cal.clndr_id] = { self.calendars[cal.clndr_id] = {
"Name": cal.clndr_name, "Name": cal.clndr_name,
"Type": cal.clndr_type, "Type": cal.clndr_type,
@@ -249,8 +248,8 @@ class P6XER2Ifc():
work_time=work_time, work_time=work_time,
attributes={ attributes={
"Name": f"{year}-{month}", "Name": f"{year}-{month}",
"Start": datetime.date(year, 1, 1), "Start": date(year, 1, 1),
"Finish": datetime.date(year, 12, 31), "Finish": date(year, 12, 31),
}, },
) )
recurrence = ifcopenshell.api.run( recurrence = ifcopenshell.api.run(
@@ -290,8 +289,8 @@ class P6XER2Ifc():
work_time=day["ifc"], work_time=day["ifc"],
attributes={ attributes={
"Name": "{}-{}-{}".format(year, month, ", ".join([str(d) for d in day_component])), "Name": "{}-{}-{}".format(year, month, ", ".join([str(d) for d in day_component])),
"Start": datetime.date(year, 1, 1), "Start": date(year, 1, 1),
"Finish": datetime.date(year, 12, 31), "Finish": date(year, 12, 31),
}, },
) )
recurrence = ifcopenshell.api.run( recurrence = ifcopenshell.api.run(
@@ -425,8 +424,7 @@ class P6XER2Ifc():
self.file = ifcopenshell.file(schema="IFC4") self.file = ifcopenshell.file(schema="IFC4")
self.work_plan = self.file.create_entity("IfcWorkPlan") self.work_plan = self.file.create_entity("IfcWorkPlan")
# TODO: working time need to be extracted from the xer not hard coded
# TODO: exceptions need to be implemented
# TODO: add support for resources # TODO: add support for resources
# TODO: consider showing progress bar for better user experience # TODO: consider showing progress bar for better user experience
# TODO: support multiple projects in a single file # TODO: support multiple projects in a single file