mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 17:31:45 +00:00
You can now toggle showing time columns in work schedule, minor fixes and ui cleanup
This commit is contained in:
@@ -2,7 +2,7 @@ import bpy
|
||||
import json
|
||||
import ifcopenshell.api
|
||||
from datetime import datetime
|
||||
from dateutil.parser import parse
|
||||
from dateutil import parser
|
||||
from blenderbim.bim.ifc import IfcStore
|
||||
from ifcopenshell.api.sequence.data import Data
|
||||
|
||||
@@ -587,9 +587,12 @@ class EditTaskTime(bpy.types.Operator):
|
||||
continue
|
||||
if "Start" in key or "Finish" in key or key == "StatusTime":
|
||||
try:
|
||||
attributes[key] = parse(value)
|
||||
attributes[key] = parser.isoparse(value)
|
||||
except:
|
||||
attributes[key] = None
|
||||
try:
|
||||
attributes[key] = parser.parse(value, dayfirst=True, fuzzy=True)
|
||||
except:
|
||||
attributes[key] = None
|
||||
return attributes
|
||||
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ import ifcopenshell.api
|
||||
from blenderbim.bim.ifc import IfcStore
|
||||
from ifcopenshell.api.sequence.data import Data
|
||||
from blenderbim.bim.prop import StrProperty, Attribute
|
||||
from dateutil.parser import parse
|
||||
from dateutil import parser
|
||||
from bpy.types import PropertyGroup
|
||||
from bpy.props import (
|
||||
PointerProperty,
|
||||
@@ -68,14 +68,17 @@ def updateTaskTimeDateTime(self, context, startfinish):
|
||||
|
||||
if startfinish_value == "-":
|
||||
return
|
||||
|
||||
self.file = IfcStore.get_file()
|
||||
props = context.scene.BIMWorkScheduleProperties
|
||||
|
||||
try:
|
||||
startfinish_datetime = parse(startfinish_value)
|
||||
startfinish_datetime = parser.isoparse(startfinish_value)
|
||||
except:
|
||||
setattr(self, startfinish, "-")
|
||||
return
|
||||
try:
|
||||
startfinish_datetime = parser.parse(startfinish_value, dayfirst=True, fuzzy=True)
|
||||
except:
|
||||
setattr(self, startfinish, "-")
|
||||
return
|
||||
|
||||
task = self.file.by_id(self.ifc_definition_id)
|
||||
if task.TaskTime:
|
||||
@@ -85,6 +88,9 @@ def updateTaskTimeDateTime(self, context, startfinish):
|
||||
Data.load(IfcStore.get_file())
|
||||
|
||||
if Data.task_times[task_time.id()][startfinish_key] == startfinish_datetime:
|
||||
canonical_startfinish_value = canonicalise_time(startfinish_datetime)
|
||||
if startfinish_value != canonical_startfinish_value:
|
||||
setattr(self, startfinish, canonical_startfinish_value)
|
||||
return
|
||||
|
||||
ifcopenshell.api.run(
|
||||
@@ -130,6 +136,7 @@ class BIMWorkScheduleProperties(PropertyGroup):
|
||||
active_task_index: IntProperty(name="Active Task Index")
|
||||
active_task_id: IntProperty(name="Active Task Id")
|
||||
task_attributes: CollectionProperty(name="Task Attributes", type=Attribute)
|
||||
should_show_times: BoolProperty(name="Should Show Times", default=False)
|
||||
active_task_time_id: IntProperty(name="Active Task Id")
|
||||
task_time_attributes: CollectionProperty(name="Task Time Attributes", type=Attribute)
|
||||
contracted_tasks: StringProperty(name="Contracted Task Items", default="[]")
|
||||
|
||||
@@ -98,6 +98,9 @@ class BIM_PT_work_schedules(Panel):
|
||||
if self.props.active_work_schedule_id and self.props.active_work_schedule_id == work_schedule_id:
|
||||
if self.props.is_editing == "WORK_SCHEDULE":
|
||||
row.operator("bim.edit_work_schedule", text="", icon="CHECKMARK")
|
||||
elif self.props.is_editing == "TASKS":
|
||||
row.prop(self.props, "should_show_times", text="", icon="TIME")
|
||||
row.operator("bim.add_summary_task", text="", icon="ADD").work_schedule = work_schedule_id
|
||||
row.operator("bim.disable_editing_work_schedule", text="", icon="CANCEL")
|
||||
elif self.props.active_work_schedule_id:
|
||||
row.operator("bim.remove_work_schedule", text="", icon="X").work_schedule = work_schedule_id
|
||||
@@ -124,9 +127,6 @@ class BIM_PT_work_schedules(Panel):
|
||||
row.prop(attribute, "is_null", icon="RADIOBUT_OFF" if attribute.is_null else "RADIOBUT_ON", text="")
|
||||
|
||||
def draw_editable_task_ui(self, work_schedule_id):
|
||||
row = self.layout.row(align=True)
|
||||
row.label(text="X Summary Tasks")
|
||||
row.operator("bim.add_summary_task", text="", icon="ADD").work_schedule = work_schedule_id
|
||||
self.layout.template_list(
|
||||
"BIM_UL_tasks",
|
||||
"",
|
||||
@@ -256,9 +256,10 @@ class BIM_UL_tasks(UIList):
|
||||
row.prop(item, "identification", emboss=False, text="")
|
||||
row.prop(item, "name", emboss=False, text="")
|
||||
|
||||
row.prop(item, "start", emboss=False, text="")
|
||||
row.prop(item, "finish", emboss=False, text="")
|
||||
row.prop(item, "duration", emboss=False, text="")
|
||||
if props.should_show_times:
|
||||
row.prop(item, "start", emboss=False, text="")
|
||||
row.prop(item, "finish", emboss=False, text="")
|
||||
row.prop(item, "duration", emboss=False, text="")
|
||||
|
||||
if props.active_task_id == item.ifc_definition_id:
|
||||
if props.active_task_time_id:
|
||||
@@ -289,6 +290,6 @@ class BIM_UL_tasks(UIList):
|
||||
row.operator("bim.remove_task", text="", icon="X").task = item.ifc_definition_id
|
||||
else:
|
||||
row.operator("bim.enable_editing_task_time", text="", icon="TIME").task = item.ifc_definition_id
|
||||
row.operator("bim.add_task", text="", icon="ADD").task = item.ifc_definition_id
|
||||
row.operator("bim.enable_editing_task", text="", icon="GREASEPENCIL").task = item.ifc_definition_id
|
||||
row.operator("bim.add_task", text="", icon="ADD").task = item.ifc_definition_id
|
||||
row.operator("bim.remove_task", text="", icon="X").task = item.ifc_definition_id
|
||||
|
||||
Reference in New Issue
Block a user