1
$\begingroup$

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.

$\endgroup$
  • $\begingroup$ I think you can use this blender.stackexchange.com/questions/34217/… and Python pretty print. $\endgroup$ – lemon Mar 24 '17 at 16:11
  • $\begingroup$ I tried the method you suggested, but it only yields bpy.data.scenes['Scene'] as text $\endgroup$ – John Mar 24 '17 at 16:27
1
$\begingroup$

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".

$\endgroup$

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.