Blender Kitsu: Fix Don't replace existing actions during Check Action Names
#75
@ -116,6 +116,12 @@ class KITSU_OT_anim_check_action_names(bpy.types.Operator):
|
|||||||
def poll(cls, context: bpy.types.Context) -> bool:
|
def poll(cls, context: bpy.types.Context) -> bool:
|
||||||
return bool(cache.shot_active_get())
|
return bool(cache.shot_active_get())
|
||||||
|
|
||||||
|
def get_action(self, action_name:str):
|
||||||
|
if bpy.data.actions.get(action_name):
|
||||||
|
return bpy.data.actions.get(action_name)
|
||||||
|
else:
|
||||||
|
return bpy.data.actions.new(action_name)
|
||||||
|
|
||||||
def execute(self, context: bpy.types.Context) -> Set[str]:
|
def execute(self, context: bpy.types.Context) -> Set[str]:
|
||||||
active_shot = cache.shot_active_get()
|
active_shot = cache.shot_active_get()
|
||||||
addon_prefs = bpy.context.preferences.addons["blender_kitsu"].preferences
|
addon_prefs = bpy.context.preferences.addons["blender_kitsu"].preferences
|
||||||
@ -140,9 +146,8 @@ class KITSU_OT_anim_check_action_names(bpy.types.Operator):
|
|||||||
# Cerate Action if None Exists
|
# Cerate Action if None Exists
|
||||||
if obj.animation_data is None or obj.animation_data.action is None:
|
if obj.animation_data is None or obj.animation_data.action is None:
|
||||||
base_name = obj.name.split(addon_prefs.shot_builder_armature_prefix)[-1]
|
base_name = obj.name.split(addon_prefs.shot_builder_armature_prefix)[-1]
|
||||||
new_action = bpy.data.actions.new(
|
action_name = f"{addon_prefs.shot_builder_action_prefix}{base_name}.{active_shot.name}.v001"
|
||||||
f"{addon_prefs.shot_builder_action_prefix}{base_name}.{active_shot.name}.v001"
|
new_action = self.get_action(action_name)
|
||||||
)
|
|
||||||
new_action.use_fake_user = True
|
new_action.use_fake_user = True
|
||||||
obj.animation_data_create()
|
obj.animation_data_create()
|
||||||
obj.animation_data.action = new_action
|
obj.animation_data.action = new_action
|
||||||
|
Loading…
Reference in New Issue
Block a user