Danny Mac writes:
In this video I create a basic python script for Blender and show how you can use Blender to help write your scripts
Danny Mac writes:
In this video I create a basic python script for Blender and show how you can use Blender to help write your scripts
6 Comments
You can just use the new shortcut for context (C) and just use bone:
for bone in C.object.pose.bones:
bone.custom_shape = bpy.data.objects["Empty"]
Oops, forgot you could also use D for bpy.data ... please note this is only available from the console. I don't think this imports from a script.
So to one-liner this you can just do it from the console as:
for bone in C.object.pose.bones: bone.custom_shape = D.objects["Empty"]
Aha! In Blender 2.8 'bpy' is implicitly imported for you, so it's no longer necessary to 'import bpy' at the top of every script. That's debatably a nice little change... but I don't think it makes things things clearer where things come in from, for new scripters.
That being said, all you need to do if you want to use 'D' for bpy.data in your own scripts, is:
from bpy import data as D
you can alias any import in Python to whatever you want just using 'as'.
Awesome! Thanks for sharing this, I was wondering how to create the aliases :)
Interesting, didn't know that thanks!
hmm, I'm finding I still have to import bpy in the text editor...