Bookkeeping/Initialization in python scripts

Hi,

I’m new to blender and sorry for some stupid questions… I searched the forum before posting this thread but found nothing…

I already know how to create and manipulate object and scenes using python ,bpy.data.xxx.xxx… and I’m having some problem runing the script in blender background (blender --background --python myscript.py)

Do I need to do any bookkeeping/ initialization before my actual script kicks in? And does starting scene also contains one mesh cube, one light and one camera if I run my script in blender background, just like the starting scene using blender GUI?

Do I need to any clean up after I finish rendering?

Sincerely,

Robin

one thing you can do is let your script show what your scene contains:
meshes = [el.name for el in pby.data.objects if el.type == “MESH”]
print(meshes) # to some file …

You can change the startup file , fill your View3D with needed objects and use Ctrl-U (or via the File menu) …