WIP: Fix for Blender 4 armature commands in release documentation #22

Closed
Geoff Gerber wants to merge 1 commits from Geoffrey-Gerber/blender-developer-docs:geoffrey-gerber-patch-1 into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.

View File

@ -16,6 +16,18 @@ Python code that was working with armature layers and bone collections.
- Each layer that contains one or more bones will be converted. Empty - Each layer that contains one or more bones will be converted. Empty
layers are skipped. layers are skipped.
### Creating And Deleting Bone Collections
Adding:
```
arm.data.collections.new('IK Controls')
```
Removing:
```
ik_controls = arm.data.collections['IK Controls']
ik_controls = arm.data.collections.remove(ik_controls)
```
### Changing Visibility ### Changing Visibility
Blender 3.6 and older: Blender 3.6 and older:
@ -28,11 +40,11 @@ arm.layers[0] = False
Blender 4.0: Blender 4.0:
``` Python ``` Python
for bcoll in arm.collections: for bcoll in arm.data.collections:
bcoll.is_visible = True bcoll.is_visible = True
arm.collections['IK Controls'].is_visible = False arm.data.collections['IK Controls'].is_visible = False
arm.collections[0].is_visible = False arm.data.collections[0].is_visible = False
``` ```
### Assigning & Unassigning Bones ### Assigning & Unassigning Bones
@ -47,10 +59,10 @@ arm.bones['arm_lower_R'].layers[1] = True
Blender 4.0: Blender 4.0:
``` Python ``` Python
arm.collections['IK Controls'].assign(arm.bones['arm_lower_R']) arm.data.collections['IK Controls'].assign(arm.data.bones['arm_lower_R'])
arm.collections['IK Controls'].unassign(arm.bones['arm_lower_R']) arm.data.collections['IK Controls'].unassign(arm.data.bones['arm_lower_R'])
arm.collections[2].assign(arm.bones['arm_lower_R']) arm.data.collections[2].assign(arm.data.bones['arm_lower_R'])
arm.collections[2].unassign(arm.bones['arm_lower_R']) arm.data.collections[2].unassign(arm.data.bones['arm_lower_R'])
``` ```
### Assigning bone to collections of another Bone: ### Assigning bone to collections of another Bone:
@ -65,9 +77,9 @@ Blender 4.0 (until there is a
`bone.collections.set(other_collections)` function): `bone.collections.set(other_collections)` function):
``` Python ``` Python
bone = arm.bones['arm_lower_R'] bone = arm.data.bones['arm_lower_R']
bone.collections.clear() bone.collections.clear()
for bcoll in arm.bones['other_bone'].collections: for bcoll in arm.data.bones['other_bone'].collections:
bcoll.assign(bone) bcoll.assign(bone)
``` ```
@ -84,10 +96,10 @@ Blender 4.0:
``` Python ``` Python
# Any mode but armature edit mode: # Any mode but armature edit mode:
in_collection = arm.collections['IK Controls'].bones in_collection = arm.data.collections['IK Controls'].bones
# Armature edit mode: # Armature edit mode:
in_collection = [ebone for ebone in arm.edit_bones in_collection = [ebone for ebone in arm.data.edit_bones
if 'IK Controls' in ebone.collections] if 'IK Controls' in ebone.collections]
``` ```
@ -105,8 +117,8 @@ arm["custom_layer_data"] = {
Blender 4.0 has custom properties on bone collections: Blender 4.0 has custom properties on bone collections:
``` Python ``` Python
arm.collections['IK Controls']['custom'] = 'some custom data' arm.data.collections['IK Controls']['custom'] = 'some custom data'
arm.collections[3]['whatever'] = 'you need' arm.data.collections[3]['whatever'] = 'you need'
``` ```
## Bone Groups to Bone Collections ## Bone Groups to Bone Collections
@ -168,7 +180,7 @@ Blender 4.0:
``` Python ``` Python
# On the armature bone: # On the armature bone:
bone = arm.bones['arm_lower_R'] bone = arm.data.bones['arm_lower_R']
# Alternatively, set on the pose bone: # Alternatively, set on the pose bone:
bone = obj.pose.bones['arm_lower_R'] bone = obj.pose.bones['arm_lower_R']
@ -180,5 +192,5 @@ bone.color.palette = 'CUSTOM'
bone.color.custom.active = (0.95, 1.0, 0.0) bone.color.custom.active = (0.95, 1.0, 0.0)
# Disable display of bone colors on the armature: # Disable display of bone colors on the armature:
arm.show_bone_colors = False arm.data.show_bone_colors = False
``` ```