mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-18 03:19:53 +00:00
BBIM 4D: implement human readable duration to read/edit durations.
new IOS Fuzzy Duration Parsing utility
This commit is contained in:
@@ -33,11 +33,7 @@ def parse_datetime(value):
|
||||
|
||||
|
||||
def parse_duration(value):
|
||||
try:
|
||||
return isodate.parse_duration(value)
|
||||
except:
|
||||
return None
|
||||
|
||||
return ifcopenshell.util.date.parse_duration(value)
|
||||
|
||||
def canonicalise_time(time):
|
||||
if not time:
|
||||
|
||||
@@ -203,9 +203,8 @@ def updateTaskDuration(self, context):
|
||||
if self.duration == "-":
|
||||
return
|
||||
|
||||
try:
|
||||
isodate.parse_duration(self.duration),
|
||||
except:
|
||||
duration = ifcopenshell.util.date.parse_duration(self.duration)
|
||||
if not duration:
|
||||
self.duration = "-"
|
||||
return
|
||||
|
||||
@@ -215,17 +214,12 @@ def updateTaskDuration(self, context):
|
||||
task_time = task.TaskTime
|
||||
else:
|
||||
task_time = ifcopenshell.api.run("sequence.add_task_time", self.file, task=task)
|
||||
SequenceData.load()
|
||||
ifcopenshell.api.run(
|
||||
"sequence.edit_task_time",
|
||||
self.file,
|
||||
**{"task_time": task_time, "attributes": {"ScheduleDuration": self.duration}},
|
||||
**{"task_time": task_time, "attributes": {"ScheduleDuration": duration}},
|
||||
)
|
||||
SequenceData.load()
|
||||
if props.active_task_id == self.ifc_definition_id:
|
||||
attribute = props.task_time_attributes.get("Duration")
|
||||
if attribute:
|
||||
attribute.string_value = self.duration
|
||||
bpy.ops.bim.load_task_properties()
|
||||
|
||||
|
||||
|
||||
@@ -374,7 +374,7 @@ class BIM_PT_work_schedules(Panel):
|
||||
|
||||
def draw_editable_task_ui(self, work_schedule_id):
|
||||
row = self.layout.row(align=True)
|
||||
row.label(text="")
|
||||
row.label(text="Task Tools")
|
||||
row = self.layout.row(align=True)
|
||||
row.alignment = "RIGHT"
|
||||
row.operator("bim.add_summary_task", text="Add Summary Task", icon="ADD").work_schedule = work_schedule_id
|
||||
|
||||
@@ -225,7 +225,7 @@ class Sequence(blenderbim.core.tool.Sequence):
|
||||
else "-"
|
||||
)
|
||||
item.duration = (
|
||||
isodate.duration_isoformat(ifcopenshell.util.date.ifc2datetime(task_time.ScheduleDuration))
|
||||
str(ifcopenshell.util.date.readable_ifc_duration(task_time.ScheduleDuration))
|
||||
if task_time.ScheduleDuration
|
||||
else "-"
|
||||
)
|
||||
@@ -243,7 +243,7 @@ class Sequence(blenderbim.core.tool.Sequence):
|
||||
item.finish = "-"
|
||||
item.duration = "-"
|
||||
|
||||
bpy.context.scene.BIMWorkScheduleProperties.is_task_update_enabled = True
|
||||
props.is_task_update_enabled = True
|
||||
|
||||
@classmethod
|
||||
def get_active_work_schedule(cls):
|
||||
|
||||
Reference in New Issue
Block a user