mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-11 18:16:40 +00:00
Fix bug where demolition animations were not generated properly.
This commit is contained in:
@@ -1814,14 +1814,20 @@ class VisualiseWorkScheduleDateRange(bpy.types.Operator):
|
||||
|
||||
def animate_destruction(self, obj, product_frame):
|
||||
obj.color = (1.0, 1.0, 1.0, 1)
|
||||
obj.hide_viewport = False
|
||||
obj.hide_render = False
|
||||
obj.keyframe_insert(data_path="color", frame=self.start_frame)
|
||||
obj.keyframe_insert(data_path="hide_viewport", frame=self.start_frame)
|
||||
obj.keyframe_insert(data_path="hide_render", frame=self.start_frame)
|
||||
obj.keyframe_insert(data_path="color", frame=product_frame["STARTED"] - 1)
|
||||
obj.color = (1.0, 0.0, 0.0, 1)
|
||||
obj.keyframe_insert(data_path="color", frame=product_frame["STARTED"])
|
||||
obj.hide_viewport = True
|
||||
obj.hide_render = True
|
||||
obj.color = (0.0, 0.0, 0.0, 1)
|
||||
obj.keyframe_insert(data_path="color", frame=product_frame["COMPLETED"])
|
||||
obj.keyframe_insert(data_path="hide_viewport", frame=product_frame["COMPLETED"])
|
||||
obj.keyframe_insert(data_path="hide_render", frame=product_frame["COMPLETED"])
|
||||
|
||||
def animate_operation(self, obj, product_frame):
|
||||
obj.color = (1.0, 1.0, 1.0, 1)
|
||||
|
||||
@@ -103,7 +103,11 @@ def prop_is_value(prop, value):
|
||||
exec(f"assert bpy.context.{prop} == {value}")
|
||||
is_value = True
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
exec(f"assert list(bpy.context.{prop}) == {value}")
|
||||
is_value = True
|
||||
except:
|
||||
pass
|
||||
if not is_value:
|
||||
actual_value = eval(f"bpy.context.{prop}")
|
||||
assert False, f"Value is {actual_value}"
|
||||
|
||||
@@ -37,3 +37,42 @@ class TestVisualiseWorkScheduleDateRange(test.bim.bootstrap.NewFile):
|
||||
When I am on frame "2"
|
||||
Then the object "Timeline" has a body of "2021-01-02"
|
||||
"""
|
||||
|
||||
@test.bim.bootstrap.scenario
|
||||
def test_animating_the_demolition_of_a_wall(self):
|
||||
return """
|
||||
Given an empty IFC project
|
||||
And I press "bim.add_work_schedule"
|
||||
And I press "bim.enable_editing_tasks(work_schedule=72)"
|
||||
And I press "bim.add_summary_task(work_schedule=72)"
|
||||
And I press "bim.enable_editing_task(task=76)"
|
||||
And I set "scene.BIMWorkScheduleProperties.task_attributes.get("PredefinedType").enum_value" to "DEMOLITION"
|
||||
And I press "bim.edit_task"
|
||||
And I press "bim.enable_editing_task_time(task=76)"
|
||||
And I set "scene.BIMWorkScheduleProperties.task_time_attributes.get("ScheduleStart").string_value" to "2021-01-02"
|
||||
And I set "scene.BIMWorkScheduleProperties.task_time_attributes.get("ScheduleFinish").string_value" to "2021-01-06"
|
||||
And I press "bim.edit_task_time"
|
||||
And the object "Cube" is selected
|
||||
And I set "scene.BIMRootProperties.ifc_class" to "IfcWall"
|
||||
And I press "bim.assign_class"
|
||||
And the object "IfcWall/Cube" is selected
|
||||
And I press "bim.assign_product(task=76, relating_product='')"
|
||||
And I set "scene.BIMWorkScheduleProperties.visualisation_start" to "01/01/21"
|
||||
And I set "scene.BIMWorkScheduleProperties.visualisation_finish" to "01/02/21"
|
||||
And I set "scene.BIMWorkScheduleProperties.speed_types" to "FRAME_SPEED"
|
||||
And I set "scene.BIMWorkScheduleProperties.speed_animation_frames" to "7"
|
||||
And I set "scene.BIMWorkScheduleProperties.speed_real_duration" to "P1W"
|
||||
And I press "bim.visualise_work_schedule_date_range(work_schedule=72)"
|
||||
When I am on frame "1"
|
||||
Then "scene.objects.get('IfcWall/Cube').hide_viewport" is "False"
|
||||
Then "scene.objects.get('IfcWall/Cube').hide_render" is "False"
|
||||
Then "scene.objects.get('IfcWall/Cube').color" is "[1.0, 1.0, 1.0, 1]"
|
||||
When I am on frame "2"
|
||||
Then "scene.objects.get('IfcWall/Cube').hide_viewport" is "False"
|
||||
Then "scene.objects.get('IfcWall/Cube').hide_render" is "False"
|
||||
Then "scene.objects.get('IfcWall/Cube').color" is "[1.0, 0.0, 0.0, 1]"
|
||||
When I am on frame "6"
|
||||
Then "scene.objects.get('IfcWall/Cube').hide_viewport" is "True"
|
||||
Then "scene.objects.get('IfcWall/Cube').hide_render" is "True"
|
||||
Then "scene.objects.get('IfcWall/Cube').color" is "[0.0, 0.0, 0.0, 1]"
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user