Script for printing a list of all actions in a scene file?

Hello friends, I’m trying to clean up my job folders and I’m trying to be careful about what I delete. At the same time I’m trying to make asset libraries of actions. So I need to go through and make some spreadsheets of all actions.

It seems like it would be a simple script but I’m way too ignorant of python. Is there a script, or would it be easy to make a script that would print all action names in a file so I could copy/paste?

Thanks very much for any and all advice. peace

So far I’ve been able to find
bpy.data.actions.items()

which gives me a list, but I’m looking to refine that list because it gives me a lot that I don’t need; it’s comma separated but each entry contains text I’d like to clean out of the list, for instance

[(‘action_name’, bpy.data.actions[‘action_name’])

would be much more useful as simply

action_name

for the purpose of being able to paste into a spreadsheet.

I’ll keep digging.

not a nice solution, but it works:



import re

a = re.split(r',', str(bpy.data.actions.items()))
b = re.findall(r'\'.*?\'', str(a))
c = str(b).replace("'","")
c = c.replace("[","")
c = c.replace("]","")
c = c.replace("\"","")

d = re.split(r',', c)

del d[::2]

print(d)

Hey Blender_Fun1, that’s very nice of you. I’m almost there.

Your script gives me

[’ Action_Name’, ‘Action_Name2’ ]

Which is better by far. Where might I hack this to remove the quotes and brackets?

Much obliged!

Hi,

This is python regex (Regular Expression)

Here is a cool online site where you can test your expressions and get a python version.

Hope that helps…

1 Like

no, that’s just the way blender/python shows an array.

just print it out like this, and you will see, that it is ok:

for item in d:
     print(item)

That works. Thank you!

So as it stands now I can get it to work in the python console which is grand. But I’m really curious about how I could make it into a script. If I try and run it in the text editor, it throws an error. I tried inserting an import bpy at the beginning and that didn’t help.

I can use it as a text file that I copy and paste into the console. Is there a way I can turn it into a text file/script that I could run in the text editor? This is pure curiosity, I already have a useful solution thanks to you.

Thank you @AlphaChannel! I appreciate your advice and help.

1 Like