[Blender_Kitsu] Add Operators to cleanup Animation Files #38
@ -117,10 +117,25 @@ class KITSU_OT_anim_check_action_names(bpy.types.Operator):
|
|||||||
return bool(cache.shot_active_get())
|
return bool(cache.shot_active_get())
|
||||||
|
|
||||||
def execute(self, context: bpy.types.Context) -> Set[str]:
|
def execute(self, context: bpy.types.Context) -> Set[str]:
|
||||||
|
active_shot = cache.shot_active_get()
|
||||||
|
addon_prefs = bpy.context.preferences.addons["blender_kitsu"].preferences
|
||||||
|
|
||||||
existing_action_names = [a.name for a in bpy.data.actions]
|
existing_action_names = [a.name for a in bpy.data.actions]
|
||||||
failed = []
|
failed = []
|
||||||
succeeded = []
|
succeeded = []
|
||||||
|
|
||||||
|
for obj in [obj for obj in bpy.data.objects if obj.type == "ARMATURE"]:
|
||||||
|
# Cerate Action if None Exists
|
||||||
|
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]
|
||||||
|
new_action = bpy.data.actions.new(
|
||||||
|
f"{addon_prefs.shot_builder_action_prefix}{base_name}.{active_shot.name}.v001")
|
||||||
|
new_action.use_fake_user = True
|
||||||
|
obj.animation_data_create()
|
||||||
|
obj.animation_data.action = new_action
|
||||||
|
obj.animation_data.action.name = f"{addon_prefs.shot_builder_action_prefix}{base_name}.{active_shot.name}.v001"
|
||||||
|
|
||||||
# Rename actions.
|
# Rename actions.
|
||||||
for action, name in self.wrong:
|
for action, name in self.wrong:
|
||||||
if name in existing_action_names:
|
if name in existing_action_names:
|
||||||
@ -278,8 +293,6 @@ class KITSU_OT_anim_enforce_naming_convention(bpy.types.Operator):
|
|||||||
|
|
||||||
def execute(self, context:bpy.types.Context):
|
def execute(self, context:bpy.types.Context):
|
||||||
shot_base_name = bpy.path.basename(bpy.data.filepath).replace(".anim.blend","")
|
shot_base_name = bpy.path.basename(bpy.data.filepath).replace(".anim.blend","")
|
||||||
active_shot = cache.shot_active_get()
|
|
||||||
addon_prefs = bpy.context.preferences.addons["blender_kitsu"].preferences
|
|
||||||
scene_col = context.scene.collection
|
scene_col = context.scene.collection
|
||||||
anim_suffix = "anim.output"
|
anim_suffix = "anim.output"
|
||||||
|
|
||||||
@ -308,17 +321,6 @@ class KITSU_OT_anim_enforce_naming_convention(bpy.types.Operator):
|
|||||||
|
|
||||||
# Rename Actions
|
# Rename Actions
|
||||||
if self.rename_actions:
|
if self.rename_actions:
|
||||||
for obj in [obj for obj in bpy.data.objects if obj.type == "ARMATURE"]:
|
|
||||||
base_name = obj.name.split(
|
|
||||||
addon_prefs.shot_builder_armature_prefix)[-1]
|
|
||||||
# Cerate Action if None Exists
|
|
||||||
if obj.animation_data is None or obj.animation_data.action is None:
|
|
||||||
new_action = bpy.data.actions.new(
|
|
||||||
f"{addon_prefs.shot_builder_action_prefix}{base_name}.{active_shot.name}.v001")
|
|
||||||
new_action.use_fake_user = True
|
|
||||||
obj.animation_data_create()
|
|
||||||
obj.animation_data.action = new_action
|
|
||||||
obj.animation_data.action.name = f"{addon_prefs.shot_builder_action_prefix}{base_name}.{active_shot.name}.v001"
|
|
||||||
bpy.ops.kitsu.anim_check_action_names()
|
bpy.ops.kitsu.anim_check_action_names()
|
||||||
self.report(
|
self.report(
|
||||||
{"INFO"},
|
{"INFO"},
|
||||||
|
Loading…
Reference in New Issue
Block a user