Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """
- Copyright (c) [2/21/24] [Dieton]
- Permission is hereby granted, free of charge, to any person obtaining a copy
- of this software and associated documentation files (the "Software"), to deal
- in the Software without restriction, including without limitation the rights
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- copies of the Software, and to permit persons to whom the Software is
- furnished to do so, subject to the following conditions:
- The above copyright notice and this permission notice shall be included in all
- copies or substantial portions of the Software.
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- SOFTWARE.
- EveryShapeKeyEveryFrame Blender Script
- Description:
- This script automates the process of creating an animation in Blender where each frame corresponds to a different blend shape (shape key). It sets the value of the current shape key to 1.0 and all other shape keys to 0.0 on each frame, creating a abrupt transition between different blend shapes.
- Usage:
- 1. Select the object with shape keys.
- 2. Run the script in Blender's Text Editor.
- 3. The animation will be created starting from frame 1.
- """
- import bpy
- def create_blend_shape_animation(obj):
- # Check if the object has shape keys
- if obj and obj.type == 'MESH' and obj.data.shape_keys:
- # Set the start frame
- start_frame = 1
- bpy.context.scene.frame_set(start_frame)
- # Iterate through all shape keys
- for i, shape_key in enumerate(obj.data.shape_keys.key_blocks):
- # Set the value of the current shape key to 1.0
- shape_key.value = 1.0
- # Insert a keyframe for the shape key's value
- shape_key.keyframe_insert(data_path="value", frame=bpy.context.scene.frame_current)
- # Reset the shape key value to 0.0 for all other shape keys
- for other_key in obj.data.shape_keys.key_blocks:
- if other_key != shape_key:
- other_key.value = 0.0
- other_key.keyframe_insert(data_path="value", frame=bpy.context.scene.frame_current)
- # Go to the next frame
- bpy.context.scene.frame_set(bpy.context.scene.frame_current + 1)
- # Set the end frame
- bpy.context.scene.frame_end = bpy.context.scene.frame_current
- # Get the active object
- active_object = bpy.context.active_object
- # Call the function to create the blend shape animation
- create_blend_shape_animation(active_object)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement