mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-12 06:32:09 +00:00
Resource Parsing for P6XML (#1842)
* 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 * merged updats * refactoring code for the 4D model to avoid duplicate code * Assign process in the api module was missing an atrribute QuantityIn Process * Merged changes from master * refactoring * resolved conflicts * refactoring code for IFC4D * refactoring code for IFC4D * refactoring code for IFC4D * Reverted the changes to IfcRelAssignsToProcess usecase * Changed the class to be more discriptive from Utils to ScheduleIfcGenerator * reverted changes to add_work_plan and Makefile * Added resource parsing support for Primavera XER * added relative path for importing common as it was failing in BlenderBIM * Initial support for Primavera XER files * merged updats * Assign process in the api module was missing an atrribute QuantityIn Process * Merged changes from master * refactoring * resolved conflicts * refactoring code for IFC4D * refactoring code for IFC4D * Reverted the changes to IfcRelAssignsToProcess usecase * Changed the class to be more discriptive from Utils to ScheduleIfcGenerator * reverted changes to add_work_plan and Makefile * Added resource parsing support for Primavera XER * added relative path for importing common as it was failing in BlenderBIM * deleted repetitive classes for P6XER import * Resource Parsing added Primavera P6 XML module * Initial support for Primavera XER files * IFC4D impl XER calendars exceptions and work time * merged updats * refactoring code for the 4D model to avoid duplicate code * Assign process in the api module was missing an atrribute QuantityIn Process * Merged changes from master * refactoring * resolved conflicts * refactoring code for IFC4D * refactoring code for IFC4D * refactoring code for IFC4D * Reverted the changes to IfcRelAssignsToProcess usecase * Changed the class to be more discriptive from Utils to ScheduleIfcGenerator * reverted changes to add_work_plan and Makefile * Added resource parsing support for Primavera XER * added relative path for importing common as it was failing in BlenderBIM * Initial support for Primavera XER files * merged updats * Assign process in the api module was missing an atrribute QuantityIn Process * Merged changes from master * refactoring * resolved conflicts * refactoring code for IFC4D * refactoring code for IFC4D * Reverted the changes to IfcRelAssignsToProcess usecase * Changed the class to be more discriptive from Utils to ScheduleIfcGenerator * reverted changes to add_work_plan and Makefile * Added resource parsing support for Primavera XER * deleted repetitive classes for P6XER import * Resource Parsing added Primavera P6 XML module * 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 * refactoring code for the 4D model to avoid duplicate code * Assign process in the api module was missing an atrribute QuantityIn Process * Merged changes from master * refactoring * resolved conflicts * refactoring code for IFC4D * refactoring code for IFC4D * refactoring code for IFC4D * Reverted the changes to IfcRelAssignsToProcess usecase * Changed the class to be more discriptive from Utils to ScheduleIfcGenerator * reverted changes to add_work_plan and Makefile * Added resource parsing support for Primavera XER * added relative path for importing common as it was failing in BlenderBIM * Initial support for Primavera XER files * merged updats * Assign process in the api module was missing an atrribute QuantityIn Process * Merged changes from master * refactoring * resolved conflicts * refactoring code for IFC4D * refactoring code for IFC4D * Reverted the changes to IfcRelAssignsToProcess usecase * Changed the class to be more discriptive from Utils to ScheduleIfcGenerator * reverted changes to add_work_plan and Makefile * Added resource parsing support for Primavera XER * deleted repetitive classes for P6XER import * Resource Parsing added Primavera P6 XML module * Initial support for Primavera XER files * IFC4D impl XER calendars exceptions and work time * merged updats * refactoring code for the 4D model to avoid duplicate code * Assign process in the api module was missing an atrribute QuantityIn Process * Merged changes from master * refactoring * resolved conflicts * refactoring code for IFC4D * refactoring code for IFC4D * refactoring code for IFC4D * Reverted the changes to IfcRelAssignsToProcess usecase * Changed the class to be more discriptive from Utils to ScheduleIfcGenerator * reverted changes to add_work_plan and Makefile * Added resource parsing support for Primavera XER * added relative path for importing common as it was failing in BlenderBIM * Initial support for Primavera XER files * merged updats * Assign process in the api module was missing an atrribute QuantityIn Process * Merged changes from master * refactoring * resolved conflicts * refactoring code for IFC4D * refactoring code for IFC4D * Reverted the changes to IfcRelAssignsToProcess usecase * Changed the class to be more discriptive from Utils to ScheduleIfcGenerator * reverted changes to add_work_plan and Makefile * Added resource parsing support for Primavera XER * deleted repetitive classes for P6XER import * Resource Parsing added Primavera P6 XML module * removed the testing code Co-authored-by: Dion Moult <dion@thinkmoult.com>
This commit is contained in:
@@ -196,7 +196,8 @@ class ScheduleIfcGenerator:
|
|||||||
)
|
)
|
||||||
identification = wbs["Code"]
|
identification = wbs["Code"]
|
||||||
if wbs["ParentObjectId"]:
|
if wbs["ParentObjectId"]:
|
||||||
identification = self.wbs[wbs["ParentObjectId"]]["ifc"].Identification + "." + wbs["Code"]
|
if self.wbs[wbs["ParentObjectId"]]["ifc"]:
|
||||||
|
identification = self.wbs[wbs["ParentObjectId"]]["ifc"].Identification + "." + wbs["Code"]
|
||||||
ifcopenshell.api.run(
|
ifcopenshell.api.run(
|
||||||
"sequence.edit_task",
|
"sequence.edit_task",
|
||||||
self.file,
|
self.file,
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ import ifcopenshell
|
|||||||
import ifcopenshell.api
|
import ifcopenshell.api
|
||||||
import ifcopenshell.util.date
|
import ifcopenshell.util.date
|
||||||
import xml.etree.ElementTree as ET
|
import xml.etree.ElementTree as ET
|
||||||
from .common import ScheduleIfcGenerator
|
from common import ScheduleIfcGenerator
|
||||||
|
|
||||||
class P62Ifc:
|
class P62Ifc:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@@ -36,6 +36,7 @@ class P62Ifc:
|
|||||||
self.root_activites = []
|
self.root_activites = []
|
||||||
self.activities = {}
|
self.activities = {}
|
||||||
self.relationships = {}
|
self.relationships = {}
|
||||||
|
self.resources = {}
|
||||||
self.day_map = {
|
self.day_map = {
|
||||||
"Monday": 1,
|
"Monday": 1,
|
||||||
"Tuesday": 2,
|
"Tuesday": 2,
|
||||||
@@ -45,12 +46,33 @@ class P62Ifc:
|
|||||||
"Saturday": 6,
|
"Saturday": 6,
|
||||||
"Sunday": 7,
|
"Sunday": 7,
|
||||||
}
|
}
|
||||||
|
self.sequence_type_map = {
|
||||||
|
"Start to Start": "START_START",
|
||||||
|
"Start to Finish": "START_FINISH",
|
||||||
|
"Finish to Start": "FINISH_START",
|
||||||
|
"Finish to Finish": "FINISH_FINISH",
|
||||||
|
}
|
||||||
|
self.RESOURCE_TYPES_MAPPING = {
|
||||||
|
'Labor': "LABOR",
|
||||||
|
'Mat': "MATERIAL",
|
||||||
|
'Equip': "EQUIPMENT"
|
||||||
|
}
|
||||||
|
|
||||||
def execute(self):
|
def execute(self):
|
||||||
|
import time
|
||||||
|
|
||||||
|
start = time.time()
|
||||||
|
print("Started")
|
||||||
self.parse_xml()
|
self.parse_xml()
|
||||||
ifcCreator = ScheduleIfcGenerator(self.file, self.work_plan, self.project, self.calendars,
|
ifcCreator = ScheduleIfcGenerator(self.file, self.work_plan, self.project, self.calendars,
|
||||||
self.wbs, self.root_activites, self.activities, self.relationships, None)
|
self.wbs, self.root_activites, self.activities, self.relationships, self.resources)
|
||||||
|
end = time.time()
|
||||||
|
|
||||||
ifcCreator.create_ifc()
|
ifcCreator.create_ifc()
|
||||||
|
end2 = time.time()
|
||||||
|
print("Parsing time is", end - start)
|
||||||
|
print("IFC Creation took", end2 - end)
|
||||||
|
print("Overall Time", end2 - start)
|
||||||
|
|
||||||
def parse_xml(self):
|
def parse_xml(self):
|
||||||
tree = ET.parse(self.xml)
|
tree = ET.parse(self.xml)
|
||||||
@@ -63,6 +85,7 @@ class P62Ifc:
|
|||||||
self.parse_wbs_xml(project)
|
self.parse_wbs_xml(project)
|
||||||
self.parse_activity_xml(project)
|
self.parse_activity_xml(project)
|
||||||
self.parse_relationship_xml(project)
|
self.parse_relationship_xml(project)
|
||||||
|
self.parse_resources_xml(root)
|
||||||
|
|
||||||
def parse_calendar_xml(self, project):
|
def parse_calendar_xml(self, project):
|
||||||
for calendar in project.findall("pr:Calendar", self.ns):
|
for calendar in project.findall("pr:Calendar", self.ns):
|
||||||
@@ -162,9 +185,25 @@ class P62Ifc:
|
|||||||
self.relationships[relationship.find("pr:ObjectId", self.ns).text] = {
|
self.relationships[relationship.find("pr:ObjectId", self.ns).text] = {
|
||||||
"PredecessorActivity": predecessor,
|
"PredecessorActivity": predecessor,
|
||||||
"SuccessorActivity": successor,
|
"SuccessorActivity": successor,
|
||||||
"Type": relationship.find("pr:Type", self.ns).text,
|
"Type": self.sequence_type_map[relationship.find("pr:Type", self.ns).text],
|
||||||
"Lag": relationship.find("pr:Lag", self.ns).text,
|
"Lag": relationship.find("pr:Lag", self.ns).text,
|
||||||
}
|
}
|
||||||
|
|
||||||
def get_wbs(self, wbs):
|
def get_wbs(self, wbs):
|
||||||
return {"Name": wbs.find("pr:Name", self.ns).text, "subtasks": []}
|
return {"Name": wbs.find("pr:Name", self.ns).text, "subtasks": []}
|
||||||
|
|
||||||
|
|
||||||
|
def parse_resources_xml(self, project):
|
||||||
|
resources = project.findall("pr:Resource", self.ns)
|
||||||
|
for resource in resources:
|
||||||
|
id = resource.find("pr:ObjectId", self.ns).text
|
||||||
|
self.resources[id] = {
|
||||||
|
"Name": resource.find("pr:Name", self.ns).text,
|
||||||
|
"Code": resource.find("pr:Id", self.ns).text,
|
||||||
|
"ParentObjectId": resource.find("pr:ParentObjectId", self.ns).text,
|
||||||
|
"Type": self.RESOURCE_TYPES_MAPPING[resource.find("pr:ResourceType", self.ns).text],
|
||||||
|
"ifc": None,
|
||||||
|
"rel": None,
|
||||||
|
}
|
||||||
|
print("Resource found", self.resources)
|
||||||
|
|
||||||
Reference in New Issue
Block a user