mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 17:58:20 +00:00
Feature to add a camera to extents of the scene objects
This commit is contained in:
@@ -20,6 +20,7 @@ import bpy
|
||||
from . import ui, prop, operator
|
||||
|
||||
classes = (
|
||||
operator.AddAnimationCamera,
|
||||
operator.AddSummaryTask,
|
||||
operator.AddTask,
|
||||
operator.AddTaskBars,
|
||||
|
||||
@@ -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"}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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()
|
||||
@@ -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
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user