I am having a master armature which has multiple bones. Now I want to apply rotation to a particular bone. Now, I can loop through all the bones in the armature and check for the bone with the expected name and then process it. But is there a way to select/get the bone object directly using it's name without looping through all the bones?
This also works
bpy.data.objects["Armature"].data.bones["Jaw"].select = True
Most collections in blender that you can iterate, where the items have a name property, can be accessed
item = collection["name"] jaw_bone = obj.pose.bones["jaw"]
You can also use get, to avoid an error if an item of name doesn't exist
jaw_bone = obj.pose.bones.get("jaw") if jaw_bone is not None: print("Jaw bone exists")