Fix bpy.extras.object_data_add use without an active space
This commit is contained in:
parent
5cd6aa4bc9
commit
f52d60a21d
Notes:
blender-bot
2023-02-14 06:57:56 +01:00
Referenced by issue #72338, `bpy.extras.object_data_add` not callable in a python script when "context.space_data" is None
|
@ -130,7 +130,10 @@ def object_data_add(context, obdata, operator=None, name=None):
|
|||
obj_new.matrix_world = add_object_align_init(context, operator)
|
||||
|
||||
space_data = context.space_data
|
||||
if space_data.type == 'VIEW_3D':
|
||||
if space_data and space_data.type != 'VIEW_3D':
|
||||
space_data = None
|
||||
|
||||
if space_data:
|
||||
if space_data.local_view:
|
||||
obj_new.local_view_set(space_data, True)
|
||||
|
||||
|
|
Loading…
Reference in New Issue