1 # SPDX-License-Identifier: GPL-2.0-or-later
5 Match Frame Range + Clear All Paths
8 Silly operator to loop through all bones and clear their paths, useful
9 when having hidden bones (othrewise you have to go through each one of
10 them and clear manually)
12 *Match Current Frame Range:
13 Set the current frame range as motion path range.
15 Both requests by Hjalti from Project Pampa
16 Thanks to Bassam Kurdali for helping finding out the weirdness behind
19 Developed during Caminandes Open Movie Project
25 class AMTH_POSE_OT_paths_clear_all(bpy
.types
.Operator
):
27 """Clear motion paths from all bones"""
28 bl_idname
= "pose.paths_clear_all"
29 bl_label
= "Clear All Motion Paths"
33 def poll(cls
, context
):
34 return context
.mode
== "POSE"
36 def execute(self
, context
):
38 for b
in context
.object.data
.bones
:
40 bpy
.ops
.pose
.paths_clear()
45 class AMTH_POSE_OT_paths_frame_match(bpy
.types
.Operator
):
47 """Match Start/End frame of scene to motion path range"""
48 bl_idname
= "pose.paths_frame_match"
49 bl_label
= "Match Frame Range"
52 def execute(self
, context
):
53 avs
= context
.object.pose
.animation_visualization
56 if avs
.motion_path
.type == "RANGE":
57 if scene
.use_preview_range
:
58 avs
.motion_path
.frame_start
= scene
.frame_preview_start
59 avs
.motion_path
.frame_end
= scene
.frame_preview_end
61 avs
.motion_path
.frame_start
= scene
.frame_start
62 avs
.motion_path
.frame_end
= scene
.frame_end
65 if scene
.use_preview_range
:
66 avs
.motion_path
.frame_before
= scene
.frame_preview_start
67 avs
.motion_path
.frame_after
= scene
.frame_preview_end
69 avs
.motion_path
.frame_before
= scene
.frame_start
70 avs
.motion_path
.frame_after
= scene
.frame_end
75 def pose_motion_paths_ui(self
, context
):
79 avs
= context
.object.pose
.animation_visualization
80 if context
.active_pose_bone
:
81 mpath
= context
.active_pose_bone
.motion_path
83 layout
.label(text
="Motion Paths Extras:")
85 split
= layout
.split()
87 col
= split
.column(align
=True)
89 if context
.selected_pose_bones
:
91 sub
= col
.row(align
=True)
93 "pose.paths_update", text
="Update Path", icon
="BONE_DATA")
94 sub
.operator("pose.paths_clear", text
="", icon
="X")
97 "pose.paths_calculate",
98 text
="Calculate Path",
101 col
.label(text
="Select Bones First", icon
="ERROR")
103 col
= split
.column(align
=True)
105 AMTH_POSE_OT_paths_frame_match
.bl_idname
,
106 text
="Set Preview Frame Range" if scene
.use_preview_range
else "Set Frame Range",
107 icon
="PREVIEW_RANGE" if scene
.use_preview_range
else "TIME")
109 col
= layout
.column()
110 row
= col
.row(align
=True)
112 if avs
.motion_path
.type == "RANGE":
113 row
.prop(avs
.motion_path
, "frame_start", text
="Start")
114 row
.prop(avs
.motion_path
, "frame_end", text
="End")
116 row
.prop(avs
.motion_path
, "frame_before", text
="Before")
117 row
.prop(avs
.motion_path
, "frame_after", text
="After")
120 layout
.operator(AMTH_POSE_OT_paths_clear_all
.bl_idname
, icon
="X")
124 bpy
.utils
.register_class(AMTH_POSE_OT_paths_clear_all
)
125 bpy
.utils
.register_class(AMTH_POSE_OT_paths_frame_match
)
126 bpy
.types
.DATA_PT_display
.append(pose_motion_paths_ui
)
130 bpy
.utils
.unregister_class(AMTH_POSE_OT_paths_clear_all
)
131 bpy
.utils
.unregister_class(AMTH_POSE_OT_paths_frame_match
)
132 bpy
.types
.DATA_PT_display
.remove(pose_motion_paths_ui
)