Blender Kitsu: Refactor Shot Builder #183
@ -47,6 +47,34 @@ def set_render_engine(scene: bpy.types.Scene, engine='CYCLES'):
|
||||
scene.render.engine = engine
|
||||
|
||||
|
||||
def link_and_override_collection(
|
||||
file_path: str, collection_name: str, scene: bpy.types.Scene
|
||||
) -> bpy.types.Collection:
|
||||
"""_summary_
|
||||
|
||||
Args:
|
||||
file_path (str): File Path to .blend file to link from
|
||||
collection_name (str): Name of collection to link from given filepath
|
||||
scene (bpy.types.Scene): Current Scene to link collection to
|
||||
|
||||
Returns:
|
||||
bpy.types.Collection: Overriden Collection linked to Scene Collection
|
||||
"""
|
||||
bpy.ops.wm.link(
|
||||
filepath=file_path,
|
||||
directory=file_path + "/Collection",
|
||||
filename=collection_name,
|
||||
instance_collections=False,
|
||||
)
|
||||
camera_col = bpy.data.collections.get(collection_name)
|
||||
override_camera_col = camera_col.override_hierarchy_create(
|
||||
scene, bpy.context.view_layer, do_fully_editable=True
|
||||
)
|
||||
scene.collection.children.unlink(camera_col)
|
||||
# Make library override.
|
||||
return override_camera_col
|
||||
|
||||
|
||||
def link_camera_rig(
|
||||
scene: bpy.types.Scene,
|
||||
output_collection: bpy.types.Collection,
|
||||
@ -69,22 +97,11 @@ def link_camera_rig(
|
||||
collection_name = (
|
||||
"CA-camera_rig" # TODO Rename the asset itself, this breaks convention
|
||||
)
|
||||
bpy.ops.wm.link(
|
||||
filepath=path,
|
||||
directory=path + "/Collection",
|
||||
filename=collection_name,
|
||||
|
||||
override_camera_col = link_and_override_collection(
|
||||
file_path=path, collection_name=collection_name, scene=scene
|
||||
)
|
||||
|
||||
# bpy.ops.object.make_override_library()
|
||||
|
||||
camera_col = bpy.data.collections.get(collection_name)
|
||||
override_camera_col = camera_col.override_hierarchy_create(
|
||||
bpy.context.scene, bpy.context.view_layer, do_fully_editable=True
|
||||
)
|
||||
|
||||
# Make library override.
|
||||
output_collection.children.link(override_camera_col)
|
||||
# scene.collection.children.link(override_camera_col)
|
||||
|
||||
# Set the camera of the camera rig as active scene camera.
|
||||
camera = override_camera_col.objects.get(CAMERA_NAME)
|
||||
|
Loading…
Reference in New Issue
Block a user