Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """
- Copyright (c) [2/25/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.
- """
- import bpy
- def create_shape_keys_from_file(file_path):
- # Get the active object
- active_object = bpy.context.active_object
- # Check if an object is selected
- if active_object:
- # Open the file in read mode
- with open(file_path, 'r') as file:
- # Read shape key names from the file
- shape_key_names = [line.strip() for line in file.readlines()]
- # Create shape keys based on the names
- for name in shape_key_names:
- bpy.ops.object.shape_key_add(from_mix=False)
- shape_key = active_object.data.shape_keys.key_blocks[-1]
- shape_key.name = name
- shape_key.value = 0 # Set the initial value to 0
- print(f"Shape keys created based on names from: {file_path}")
- else:
- print("Error: No object selected.")
- # Set the file path containing shape key names
- file_path = "shape_key_names.txt"
- # Call the function to create shape keys based on the names from the file
- create_shape_keys_from_file(file_path)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement