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
    Commented Oct 2, 2019 at 9:56
  • $\begingroup$ It doesn't help me there is too much information and nothing about delete or remove. Thanks anyway. $\endgroup$ Commented Oct 2, 2019 at 11:01

1 Answer 1

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$ Commented Oct 2, 2019 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$
    – globglob
    Commented Oct 2, 2019 at 11:58

You must log in to answer this question.

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