Python in Blender 4.0

Forum Archive Python in Blender 4.0

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #17827
    Mauro Ornelas
    Participant

      Hi All,

      The Python code was not working for me on Blender 4.0 as there are no layers on this version anymore, it was replaced by Bone Collections. I know this is not a Python focused course, but its still fun to mess with it and useful in animation I think. So after fighting with it a bit I got it to work, replacing the following part of the code: 

              #Layers
      
              row = col.row()
              row.prop(context.active_object.data, "layers", index=0, toggle=True, text="Head")
              row = col.row()
              row.prop(context.active_object.data, "layers", index=1, toggle=True, text="Claw")
              row = col.row()
              row.prop(context.active_object.data, "layers", index=16, toggle=True, text="Root")

      With:

              #Layers
      
              row = col.row()
              row.prop(context.active_object.data.collections["Root"], "is_visible",toggle=True, text="Root")
              row = col.row()
              row.prop(context.active_object.data.collections["Clamp"], "is_visible",toggle=True, text="Clamp")
              row = col.row()
              row.prop(context.active_object.data.collections["Base"], "is_visible",toggle=True, text="Base")
              row = col.row()
              row.prop(context.active_object.data.collections["MCH"], "is_visible",toggle=True, text="MCH")

      For this to work, instead of having the bones in layers, the collection names need to match context.active_object.data.collections[“Root”]. So the bone collection name needs to be Root in this case (or match in code whatever you are using).

      Control_rig.png

      #85493
      Adrian Bellworthy
      Participant

        Nice @mauroornelas
        Thanks for sharing!

        #85494
        Wayne Dixon
        Participant

          Oh thanks for reminding me about this Mauro.

          It’s been on my to do list for a while now and this week is when I am doing all those little update things

          #85495
          Wayne Dixon
          Participant

            Updated complete,  thanks again for the reminder Mauro.

          Viewing 4 posts - 1 through 4 (of 4 total)
          • The topic ‘Python in Blender 4.0’ is closed to new replies.