若要在 Blender 2.8 Python API 中將網格(對象)設置為活動,context.view_layer使用「網格」的active屬性而不是2.8之前上下文的場景context.scene。
嘗試使用"bpy.context.scene.objects.active"使對象處於活動狀態時,Blender 會引發錯誤:
屬性Bpy_prop_collection:未找到屬性「active」,blender升到2.8之後,Python API已經把這個屬性移走
若要使 Blender 2.8 中的對象處於活動狀態,請使用以下代碼:
obj = bpy.context.window.scene.objects[0]
bpy.context.view_layer.objects.active = obj # 'obj' is the active object now
轉載請註明出處(百家號:blender幫)