1

A very simple question on how to dump bpy.context.scene information using python script to blender console or a string so I can use to debug.

I have tried to serialize the object using pickle and json dump with no success. Serializing seems to not work here for some reason.

Note to downvoters: Please atleast leave a constructive comment why you feel this question needs to be downvoted. If you dont know the answer move on.

John
  • 43
  • 6
  • I think you can use this http://blender.stackexchange.com/questions/34217/how-to-redirect-output-from-bpy-ops and Python pretty print. – lemon Mar 24 '17 at 16:11
  • I tried the method you suggested, but it only yields bpy.data.scenes['Scene'] as text – John Mar 24 '17 at 16:27

1 Answers1

1

I had the need to do something similar recently, and here is a very brief solution that I attempted, hopefully it can be helpful:

  1. Create a script at the same location with your target .blend file named something like script.py:
import bpy
# Use bpy.context.scene.objects.keys() to get the name of objects

with open('output.txt', 'w+') as the_file:
    the_file.write(', '.join(bpy.context.scene.objects.keys()))
  1. Execute blender in background for the target file and run the script: In command line, use blender -b filename.blend -P script.py to run blender in background and execute the script on the scene.

This script will dump all object names in the scene into a file named "output.txt".