0
$\begingroup$

Do you have any idea how to make this piece of code working? I keep getting this error when trying to execute the unused data-blocks:

RuntimeError: Operator bpy.ops.outliner.orphans_purge.poll() failed, context is incorrect

import bpy
import sys

for area in bpy.context.screen.areas:
    if area.type == 'OUTLINER':
        try:
            override = bpy.context.copy()
            override["area.type"] = ['OUTLINER']
            override["space_data.display_mode"] = ['ORPHAN_DATA']
            bpy.ops.outliner.orphans_purge(override)
        except:
            print("Unexpected stuff:", sys.exc_info()[0])
            raise
        break
$\endgroup$

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.