1
$\begingroup$

I would like to delete a camera with a Python script. The code:

    bpy.ops.object.select_all(action='SELECT')
    bpy.ops.object.delete(use_global=False)

isn't enough to remove the camera completely. There are still data in bpy.data.cameras. Using the Info to see the Python code, there is nothing when removing the camera with the GUI: enter image description here

Is there another way to remove completely the camera?

Thanks for help!

$\endgroup$
2
  • $\begingroup$ I am sure someone can give you the complete answer regarding cameras, but just for reference, you can run Blender with --debug or --debug-all that will show more (a lot more) python code in the Info window and the system console. $\endgroup$
    – rob
    Oct 2 '19 at 9:56
  • $\begingroup$ It doesn't help me there is too much information and nothing about delete or remove. Thanks anyway. $\endgroup$ Oct 2 '19 at 11:01
1
$\begingroup$
bpy.data.cameras.remove(bpy.data.cameras["Camera"])

This will remove the camera data.

Does this answer your question?

$\endgroup$
2
  • $\begingroup$ Yes. How did you find it? $\endgroup$ Oct 2 '19 at 11:52
  • 2
    $\begingroup$ I forgot, I just know that to delete data you have to do this, not only for cameras but for most things in Blender. Can't explain why though! But I can safely say that it's impossible to rely solely on Blender's interface giving you enough hint to write python code, you really have to dig the manual (if you can make sense of it) and forums to get stuff done. $\endgroup$ Oct 2 '19 at 11:58

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.