diff --git a/src/blenderbim/blenderbim/bim/module/sequence/__init__.py b/src/blenderbim/blenderbim/bim/module/sequence/__init__.py index 2a43a798f4..65d1fb887e 100644 --- a/src/blenderbim/blenderbim/bim/module/sequence/__init__.py +++ b/src/blenderbim/blenderbim/bim/module/sequence/__init__.py @@ -20,6 +20,7 @@ import bpy from . import ui, prop, operator classes = ( + operator.AddAnimationCamera, operator.AddSummaryTask, operator.AddTask, operator.AddTaskBars, diff --git a/src/blenderbim/blenderbim/bim/module/sequence/operator.py b/src/blenderbim/blenderbim/bim/module/sequence/operator.py index 49d12f462c..bb6f9d17ab 100644 --- a/src/blenderbim/blenderbim/bim/module/sequence/operator.py +++ b/src/blenderbim/blenderbim/bim/module/sequence/operator.py @@ -1410,3 +1410,13 @@ class ClearPreviousAnimation(bpy.types.Operator, tool.Ifc.Operator): def _execute(self, context): core.clear_previous_animation(tool.Sequence) + + +class AddAnimationCamera(bpy.types.Operator): + bl_idname = "bim.add_animation_camera" + bl_label = "Add Camera to Scene" + bl_options = {"REGISTER", "UNDO"} + + def execute(self, context): + core.add_animation_camera(tool.Sequence) + return {"FINISHED"} diff --git a/src/blenderbim/blenderbim/bim/module/sequence/ui.py b/src/blenderbim/blenderbim/bim/module/sequence/ui.py index fa04f9502c..64ed3399f7 100644 --- a/src/blenderbim/blenderbim/bim/module/sequence/ui.py +++ b/src/blenderbim/blenderbim/bim/module/sequence/ui.py @@ -454,6 +454,7 @@ class BIM_PT_animation_tools(Panel): row = self.layout.row() row.alignment = "RIGHT" row.operator("bim.clear_previous_animation", text="Clear Previous Animation", icon="TRACKING_CLEAR_FORWARDS") + row.operator("bim.add_animation_camera", text="Add Camera", icon="CAMERA_DATA") def draw_visualisation_ui(self): row = self.layout.row(align=True) diff --git a/src/blenderbim/blenderbim/core/sequence.py b/src/blenderbim/blenderbim/core/sequence.py index acab879966..7af332cbf4 100644 --- a/src/blenderbim/blenderbim/core/sequence.py +++ b/src/blenderbim/blenderbim/core/sequence.py @@ -584,3 +584,6 @@ def create_baseline(ifc, sequence, work_schedule, name): def clear_previous_animation(sequence): sequence.clear_objects_animation(include_blender_objects=False) + +def add_animation_camera(sequence): + sequence.add_animation_camera() \ No newline at end of file diff --git a/src/blenderbim/blenderbim/core/tool.py b/src/blenderbim/blenderbim/core/tool.py index 9d644f1a81..44a107f0f0 100644 --- a/src/blenderbim/blenderbim/core/tool.py +++ b/src/blenderbim/blenderbim/core/tool.py @@ -648,6 +648,7 @@ class Search: @interface class Sequence: + def add_animation_camera(cls): pass def add_task_column(cls, column_type, name, data_type): pass def add_text_animation_handler(cls, settings): pass def animate_consumption(cls, obj, start_frame, product_frame, color, animation_type): pass @@ -660,6 +661,7 @@ class Sequence: def animate_operation(cls, obj, start_frame, product_frame, color): pass def animate_output(cls, obj, start_frame, product_frame): pass def clear_object_animation(cls, obj): pass + def clear_object_color(cls, obj): pass def clear_objects_animation(cls, include_blender_objects): pass def contract_all_tasks(cls): pass def contract_task(cls, task): pass @@ -676,6 +678,7 @@ class Sequence: def disable_editing_work_time(cls): pass def disable_selecting_deleted_task(cls): pass def disable_work_schedule(cls): pass + def display_object(cls, obj): pass def enable_editing_rel_sequence_attributes(cls, rel_sequence): pass def enable_editing_sequence_lag_time(cls, rel_sequence): pass def enable_editing_task_animation_colors(cls): pass diff --git a/src/blenderbim/blenderbim/tool/sequence.py b/src/blenderbim/blenderbim/tool/sequence.py index 5cb93acdc7..43582e2723 100644 --- a/src/blenderbim/blenderbim/tool/sequence.py +++ b/src/blenderbim/blenderbim/tool/sequence.py @@ -1614,3 +1614,18 @@ class Sequence(blenderbim.core.tool.Sequence): object_type = bpy.context.scene.BIMWorkScheduleProperties.object_type return predefined_type, object_type + @classmethod + def add_animation_camera(cls): + bpy.ops.object.camera_add() + camera = bpy.context.active_object + camera.data.lens = 26 + camera.name = "4D Camera" + camera.location = mathutils.Vector((15, 0, 15)) + camera.rotation_euler = mathutils.Euler((1.2, 0, 1.5), "XYZ") + for obj in bpy.context.scene.objects: + obj.select_set(False) + for obj in bpy.context.visible_objects: + if not (obj.hide_get() or obj.hide_render) and obj.type != "LIGHT": + obj.select_set(True) + bpy.context.scene.camera = camera + bpy.ops.view3d.camera_to_view_selected() diff --git a/src/blenderbim/test/bim/feature/sequence.feature b/src/blenderbim/test/bim/feature/sequence.feature index dc5ddd29af..fba026a0e8 100644 --- a/src/blenderbim/test/bim/feature/sequence.feature +++ b/src/blenderbim/test/bim/feature/sequence.feature @@ -843,3 +843,11 @@ Scenario: Duplicate Task and edit sequence Relationship When I press "bim.enable_editing_task_sequence(task={nested_task_one})" Then nothing happens +Scenario: Add Animation Camera + Given an empty IFC project + And I add a cube + And the object "Cube" is selected + And I set "scene.BIMRootProperties.ifc_class" to "IfcWall" + And I press "bim.assign_class" + And I press "bim.add_animation_camera" + Then "scene.objects.get('4D Camera').name" is "4D Camera"