mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 17:58:20 +00:00
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:
@@ -240,6 +240,20 @@ endif
|
||||
cp -r dist/working/lark-parser-0.8.5/lark dist/blenderbim/libs/site/packages/
|
||||
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
|
||||
mkdir dist/working
|
||||
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))
|
||||
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):
|
||||
bl_idname = "import_p6xer.bim"
|
||||
|
||||
@@ -20,7 +20,7 @@ from xerparser.reader import Reader
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.util.date
|
||||
from datetime import datetime, time, timedelta
|
||||
from datetime import datetime, timedelta, date
|
||||
|
||||
|
||||
class P6XER2Ifc():
|
||||
@@ -93,7 +93,8 @@ class P6XER2Ifc():
|
||||
self.parse_wbs_xer()
|
||||
self.parse_activity_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):
|
||||
@@ -110,18 +111,16 @@ class P6XER2Ifc():
|
||||
|
||||
def parse_calendar_xer(self):
|
||||
standard_work_week = []
|
||||
exceptions = {}
|
||||
for cal in self.model.calendars:
|
||||
standard_work_week = []
|
||||
for k,v in cal.working_days.items(): #TODO: add work times
|
||||
standard_work_week.append({
|
||||
"DayOfWeek": self.day_map2[k],
|
||||
"WorkTimes": [{
|
||||
"Start": time(8, 0),
|
||||
"Finish": time(16, 0)
|
||||
}] if not v else [],
|
||||
"ifc": None,
|
||||
})
|
||||
exceptions = {} #TODO: to be implemented
|
||||
standard_work_week = cal.working_hours
|
||||
except_lst = cal.exceptions
|
||||
for exception in except_lst:
|
||||
month = exceptions.setdefault(exception.year, {}).setdefault(exception.month, {})
|
||||
month.setdefault("FullDay", [])
|
||||
month.setdefault("WorkTime", [])
|
||||
exceptions[exception.year][exception.month]["FullDay"].append(exception.day)
|
||||
|
||||
self.calendars[cal.clndr_id] = {
|
||||
"Name": cal.clndr_name,
|
||||
"Type": cal.clndr_type,
|
||||
@@ -249,8 +248,8 @@ class P6XER2Ifc():
|
||||
work_time=work_time,
|
||||
attributes={
|
||||
"Name": f"{year}-{month}",
|
||||
"Start": datetime.date(year, 1, 1),
|
||||
"Finish": datetime.date(year, 12, 31),
|
||||
"Start": date(year, 1, 1),
|
||||
"Finish": date(year, 12, 31),
|
||||
},
|
||||
)
|
||||
recurrence = ifcopenshell.api.run(
|
||||
@@ -290,8 +289,8 @@ class P6XER2Ifc():
|
||||
work_time=day["ifc"],
|
||||
attributes={
|
||||
"Name": "{}-{}-{}".format(year, month, ", ".join([str(d) for d in day_component])),
|
||||
"Start": datetime.date(year, 1, 1),
|
||||
"Finish": datetime.date(year, 12, 31),
|
||||
"Start": date(year, 1, 1),
|
||||
"Finish": date(year, 12, 31),
|
||||
},
|
||||
)
|
||||
recurrence = ifcopenshell.api.run(
|
||||
@@ -425,8 +424,7 @@ class P6XER2Ifc():
|
||||
self.file = ifcopenshell.file(schema="IFC4")
|
||||
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: consider showing progress bar for better user experience
|
||||
# TODO: support multiple projects in a single file
|
||||
|
||||
Reference in New Issue
Block a user