mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 09:48:32 +00:00
BBIM: Fixes for:
- Task Time attributes - Fix typo animation time calculation
This commit is contained in:
@@ -116,7 +116,7 @@ classes = (
|
||||
prop.Task,
|
||||
prop.TaskResource,
|
||||
prop.TaskProduct,
|
||||
prop.BIMDuration,
|
||||
prop.ISODuration,
|
||||
prop.BIMWorkScheduleProperties,
|
||||
prop.BIMTaskTreeProperties,
|
||||
prop.BIMTaskTypeColor,
|
||||
|
||||
@@ -45,28 +45,31 @@ def canonicalise_time(time):
|
||||
return time.strftime("%d/%m/%y")
|
||||
|
||||
|
||||
def parse_duration_as_blender_props(dt):
|
||||
seconds = dt.seconds
|
||||
hours, seconds = divmod(seconds, 3600)
|
||||
minutes, seconds = divmod(seconds, 60)
|
||||
days = dt.days
|
||||
months = int(getattr(dt, "months", 0))
|
||||
years = int(getattr(dt, "years", 0))
|
||||
return {
|
||||
"years": years,
|
||||
"months": months,
|
||||
"days": days if days else 0,
|
||||
"hours": hours if hours else 0,
|
||||
"minutes": minutes if minutes else 0,
|
||||
"seconds": seconds if seconds else 0,
|
||||
}
|
||||
def parse_duration_as_blender_props(dt, simplify=True):
|
||||
if simplify:
|
||||
if isinstance(dt, str):
|
||||
dt = ifcdateutils.ifc2datetime(dt)
|
||||
|
||||
seconds = getattr(dt, "seconds", 0)
|
||||
hours, seconds = divmod(seconds, 3600)
|
||||
minutes, seconds = divmod(seconds, 60)
|
||||
days = getattr(dt, "days",0)
|
||||
months = int(getattr(dt, "months", 0))
|
||||
years = int(getattr(dt, "years", 0))
|
||||
return {
|
||||
"years": years,
|
||||
"months": months,
|
||||
"days": days,
|
||||
"hours": hours,
|
||||
"minutes": minutes,
|
||||
"seconds": seconds,
|
||||
}
|
||||
|
||||
|
||||
def simplify_duration(durations_attributes, duration_type, prop_name):
|
||||
for item in durations_attributes:
|
||||
if item.name == prop_name:
|
||||
duration_props = item
|
||||
print(duration_props, "duration_props")
|
||||
if duration_props and not duration_type or duration_type == "ELAPSEDTIME":
|
||||
duration_string = "P{}Y{}M{}DT{}H{}M{}S".format(
|
||||
duration_props.years if duration_props.years else 0,
|
||||
|
||||
@@ -278,7 +278,7 @@ class Task(PropertyGroup):
|
||||
has_children: BoolProperty(name="Has Children")
|
||||
is_selected: BoolProperty(name="Is Selected")
|
||||
is_expanded: BoolProperty(name="Is Expanded")
|
||||
has_bar_visual: BoolProperty(name="Bar Visualization", default=False)
|
||||
has_bar_visual: BoolProperty(name="Show Task Bar Animation", default=False)
|
||||
level_index: IntProperty(name="Level Index")
|
||||
duration: StringProperty(name="Duration", update=updateTaskDuration)
|
||||
start: StringProperty(name="Start", update=updateTaskTimeStart)
|
||||
@@ -317,18 +317,18 @@ class BIMWorkPlanProperties(PropertyGroup):
|
||||
work_schedules: EnumProperty(items=getWorkSchedules, name="Work Schedules")
|
||||
|
||||
|
||||
class BIMDuration(PropertyGroup):
|
||||
name: StringProperty(name="Attribute")
|
||||
years: IntProperty(name="Years")
|
||||
months: IntProperty(name="Months")
|
||||
days: IntProperty(name="Days ")
|
||||
hours: IntProperty(name="Hours")
|
||||
minutes: IntProperty(name="Minutes")
|
||||
seconds: IntProperty(name="Seconds")
|
||||
class ISODuration(PropertyGroup):
|
||||
name: StringProperty(name="Name")
|
||||
years: IntProperty(name="Years", default=0)
|
||||
months: IntProperty(name="Months", default=0)
|
||||
days: IntProperty(name="Days", default=0)
|
||||
hours: IntProperty(name="Hours", default=0)
|
||||
minutes: IntProperty(name="Minutes", default=0)
|
||||
seconds: IntProperty(name="Seconds", default=0)
|
||||
|
||||
|
||||
class BIMWorkScheduleProperties(PropertyGroup):
|
||||
durations_attributes: CollectionProperty(name="Durations Attributes", type=BIMDuration)
|
||||
durations_attributes: CollectionProperty(name="Durations Attributes", type=ISODuration)
|
||||
work_calendars: EnumProperty(items=getWorkCalendars, name="Work Calendars")
|
||||
work_schedule_attributes: CollectionProperty(name="Work Schedule Attributes", type=Attribute)
|
||||
editing_type: StringProperty(name="Editing Type")
|
||||
|
||||
@@ -344,7 +344,7 @@ class Sequence(blenderbim.core.tool.Sequence):
|
||||
@classmethod
|
||||
def load_task_time_attributes(cls, task_time):
|
||||
def callback(name, prop, data):
|
||||
if prop.data_type == "string":
|
||||
if prop and prop.data_type == "string":
|
||||
duration_props = bpy.context.scene.BIMWorkScheduleProperties.durations_attributes.add()
|
||||
duration_props.name = name
|
||||
if prop.is_null:
|
||||
@@ -353,8 +353,7 @@ class Sequence(blenderbim.core.tool.Sequence):
|
||||
setattr(duration_props, key, 0)
|
||||
return True
|
||||
if name in ["ScheduleDuration", "ActualDuration", "FreeFloat", "TotalFloat"] and data[name]:
|
||||
time_object = ifcopenshell.util.date.ifc2datetime(data[name])
|
||||
for key, value in helper.parse_duration_as_blender_props(time_object).items():
|
||||
for key, value in helper.parse_duration_as_blender_props(data[name]).items():
|
||||
duration_props[key] = value
|
||||
return True
|
||||
if isinstance(data[name], datetime):
|
||||
@@ -396,7 +395,7 @@ class Sequence(blenderbim.core.tool.Sequence):
|
||||
value = 0
|
||||
return True
|
||||
else:
|
||||
duration_type = getattr(attributes, "DurationType", None)
|
||||
duration_type = attributes["DurationType"] if "DurationType" in attributes else None
|
||||
time_split_iso_duration = helper.simplify_duration(
|
||||
props.durations_attributes, duration_type, prop.name
|
||||
)
|
||||
@@ -1030,7 +1029,7 @@ class Sequence(blenderbim.core.tool.Sequence):
|
||||
|
||||
def calculate_using_multiplier(start, finish, fps, multiplier):
|
||||
animation_time = (finish - start) / multiplier
|
||||
return animation_time.seconds_left() * fps
|
||||
return animation_time.total_seconds() * fps
|
||||
|
||||
def calculate_using_duration(start, finish, fps, animation_duration, real_duration):
|
||||
return calculate_using_multiplier(start, finish, fps, real_duration / animation_duration)
|
||||
@@ -1039,6 +1038,8 @@ class Sequence(blenderbim.core.tool.Sequence):
|
||||
return ((finish - start) / real_duration) * animation_frames
|
||||
|
||||
props = bpy.context.scene.BIMWorkScheduleProperties
|
||||
if not (props.visualisation_start and props.visualisation_finish):
|
||||
return
|
||||
start = parser.parse(props.visualisation_start, dayfirst=True, fuzzy=True)
|
||||
finish = parser.parse(props.visualisation_finish, dayfirst=True, fuzzy=True)
|
||||
duration = finish - start
|
||||
|
||||
Reference in New Issue
Block a user