📋 Metadata

💬 Content

draguu:

one more question - i have made a script which select bones - suppose it has WXYZ bones i wrote a code something like this

C.object.data.bones[“W”].select = True ; C.object.data.bones[“X”].select = True ; C.object.data.bones[“Y”].select = True ; C.object.data.bones[“Z”].select = True

now i want it to check if this armature has X bone or not . it X bone does not exist in the armature then script should skip that bone and select rest of the bones ( which is W, Y and Z )

You can add a function for that in your script:

def select_bone(bone_name, select):
    if bone_name in C.object.data.bones:
        C.object.data.bones[bone_name].select = select
    
select_bone("W", True)
select_bone("X", True)
select_bone("Y", True)
select_bone("Z", True)

Or:

def select_bone(bone_name, select):
    if bone_name in C.object.data.bones:
        C.object.data.bones[bone_name].select = select
    
bone_names = ["W", "X", "Y", "Z"]

for bone_name in bone_names:
    select_bone(bone_name, True)

🔗 View on Blender Artists