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$
2
  • $\begingroup$ I think you can use this blender.stackexchange.com/questions/34217/… and Python pretty print. $\endgroup$
    – lemon
    Commented Mar 24, 2017 at 16:11
  • $\begingroup$ I tried the method you suggested, but it only yields bpy.data.scenes['Scene'] as text $\endgroup$
    – John
    Commented Mar 24, 2017 at 16:27

1 Answer 1

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$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .