mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-11 10:06:47 +00:00
Support importing lag times from P6 XML
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
import ifcopenshell.util.date
|
||||
|
||||
|
||||
class Usecase:
|
||||
def __init__(self, file, **settings):
|
||||
self.file = file
|
||||
@@ -6,7 +9,9 @@ class Usecase:
|
||||
self.settings[key] = value
|
||||
|
||||
def execute(self):
|
||||
lag_value = self.file.createIfcDuration(self.settings["lag_value"])
|
||||
lag_value = self.file.createIfcDuration(
|
||||
ifcopenshell.util.date.datetime2ifc(self.settings["lag_value"], "IfcDuration")
|
||||
)
|
||||
lag_time = self.file.create_entity(
|
||||
"IfcLagTime",
|
||||
**{
|
||||
|
||||
@@ -22,7 +22,7 @@ def timedelta2duration(timedelta):
|
||||
|
||||
|
||||
def ifc2datetime(element):
|
||||
if isinstance(element, str) and element[0] == "P": # IfcDuration
|
||||
if isinstance(element, str) and "P" in element[0:2]: # IfcDuration
|
||||
duration = isodate.parse_duration(element)
|
||||
if isinstance(duration, datetime.timedelta):
|
||||
return timedelta2duration(duration)
|
||||
|
||||
Reference in New Issue
Block a user