← Blender.Today
  • Published 21 May 2020

(Help) python thing

i would like to get something like in the image

i have this code, but it move all the keyframe 10 time right

<code> import bpy for action in bpy.data.actions: &nbsp;&nbsp; for fcurve in action.fcurves: &nbsp;&nbsp;&nbsp;&nbsp; for point in fcurve.keyframe_points: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; point.co.x += 10 </code>

i need to move each frame 10 time more than the las one. how could i do that? and how could i access to a specific key bone and move just it?

Screenshot_2.png

jose-m-vargas
21 May 2020

2 Comments

jose-m-vargas Author

I achieved it this way it needs polish btw <pre > <source> import re import bpy

def lookFor(txt):   t = re.findall(r'"([^"]*)"', txt)   return t

amount = 1 boneName = 'null' boneNameLast = "null"

for action in bpy.data.actions:
for fcurve in action.fcurves:
boneName = lookFor(fcurve.data_path)

if boneName != boneNameLast:       boneNameLast = lookFor(fcurve.data_path)       amount = amount + 1

for point in fcurve.keyframe_points:
print(point.co.x)       point.co.x += amount

</source> </pre>

TingJoyBits

You can access to a specific key bone trough Fcurve.data_path

<pre> # selected pose bones in POSE mode bone_names = [ b.name for b in bpy.context.selected_pose_bones] # Fcurves of the active armature fcurves = bpy.context.active_object.animation_data.action.fcurves for curve in fcurves: &nbsp;&nbsp;# skip object transform curves if armature itself is animated &nbsp;&nbsp;try: &nbsp;&nbsp;&nbsp;&nbsp;if curve.data_path.split('"')[1] in bone_names: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;# print names of the selected pose bones that has animation curves &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print(curve.data_path.split('"')[1]) &nbsp;&nbsp;except IndexError: &nbsp;&nbsp;&nbsp;&nbsp;pass </pre>