答案 0 :(得分:2)
对象将其子项列表保留为obj.children
import bpy
for obj in bpy.data.objects['comp_1_1_2_a'].children:
if len(obj.material_slots) == 0:
bpy.context.scene.objects.active = obj
bpy.ops.object.material_slot_add()
obj.material_slots[0].material = bpy.data.materials['Material']