• Daz 3D
  • Shop
  • 3D Software
    • Daz Studio Premier
    • Daz Studio
    • Install Manager
    • Partnerships
    • AI Training data
    • Exporters
    • Daz to Roblox
    • Daz to Maya
    • Daz to Blender
    • Daz to Unreal
    • Daz to Unity
    • Daz to 3ds Max
    • Daz to Cinema 4D
  • 3D Models
    • Genesis 9
    • Genesis 8.1
    • Free 3D Models
  • Community
    • Gallery
    • Forums
    • Blog
    • Press
    • Help
  • Memberships
    • Daz Premier
    • Daz Plus
    • Daz Base
    • Compare
  • Download Studio
ADVANCED SEARCH
  • Menu
  • Daz 3D
ADVANCED SEARCH
Add image
  • Shop
  • 3d Software
    • Daz Studio Premier
    • Daz Studio
    • Install Manager
    • Partnerships
    • AI Training data
    • Exporters
    • Daz to Roblox
    • Daz to Maya
    • Daz to Blender
    • Daz to Unreal
    • Daz to Unity
    • Daz to 3ds Max
    • Daz to Cinema 4D
  • 3D Models
    • Genesis 9
    • Genesis 8.1
    • Free 3D Models
  • Community
    • Our Community
    • Gallery
    • Forums
    • Blog
    • Press
    • Help
  • Memberships
    • Daz Premier
    • Daz Plus
    • Daz Base
    • Compare

Notifications

You currently have no notifications.

Loading...
    • Categories
    • Recent Discussions
Daz 3D Forums > 3rd Party Software > Blender Discussion

Script to simply delete all cameras and lights

MartirillaMartirilla Posts: 190
July 2021 in Blender Discussion

Is there really no Python script that will delete all lights (lamps) and cameras from a Blender scene? And yet, after a great deal of searching, that appears to be the case. Does anyone have such a thing that they can share, please?

 

Comments

  • MartirillaMartirilla Posts: 190
    July 2021 edited July 2021

    Ok, I patched it together myself, from a Stack Overflow discussion on resetting a Blender file to the default.  This works in 2.7, which is where my target assets are... and I have added the 2.8 tweak in the script's header.

    #### Blender 2.7 script to simply delete all cameras and lights in a scene. # Blender 2.8 or higher requires you change = True and = False to:##       o.select_set(True)#   else:#       o.select_set(False)###import bpy# Delete Lightsfor o in bpy.context.scene.objects:    if o.type == 'LAMP':        o.select = True    else:        o.select = False# Do the Lights deletebpy.ops.object.delete()# Delect Camerafor o in bpy.context.scene.objects:    if o.type == 'CAMERA':        o.select = True    else:        o.select = False# Do the Camera deletebpy.ops.object.delete()

    I'm still astounded that such a simple helper script is not to be easily found.

    Post edited by Martirilla on July 2021
  • Krys KryngleKrys Kryngle Posts: 311
    July 2021

    Not sure if one exists, but in the meantime you can click on the filter in the top right, then isolate all the cameras and lights, then delete.

  • MartirillaMartirilla Posts: 190
    July 2021

    Thanks Krampus. Yes, I'm getting the distinct impression that the Blender crowd just love doing things manually, time after time, the hard way. :-)

  • DaremoK3DaremoK3 Posts: 798
    July 2021

    Great start, Martirilla.

    One thing to note, though;  For going from B2.7x to B2.8x, you also need to change the lights variable as you have with the select variable.

    Lights TYPE has changed from 'LAMP' in 2.7x to 'LIGHT' in 2.8x.

    So, your type selection code would be :

    o.type == 'LIGHT':

     

    I believe your opening post as to why you can't find a script for this is more want vs need, and maybe no coders saw a need for this yet, or this function already exists in a specific addon you haven't found yet.  I know of none, but that does not mean it does not exist.

    You have a need (and a great idea!), so creating the script (and sharing) was a good thing to do.

    I think this could be fleshed-out to a full (simple) addon with user selected preferences for where user would like to employ it.

    I believe 3 delete buttons would be good;  One for delete all cameras, one for delete all lights, and one for delete all (both).

    My idea would be to add 2 or 3 variables for it to be used from either an addon Tool Tab (SideBar -- user selectable location), the TopBar (or toggleable Header), or possibly from one of the Properties Tabs.

    * If usable from one of the Properties Tabs, which PT do you feel would be most appropiate to locate the delete buttons in?

    Regarding the Blender crowd just wanting to do everything manually, if this were true, there wouldn't be so many paid-for addons which basically are just automation macros combining many manual steps into single button operations, or modal actions.

    I do this heavily, myself, with my addons  --  So, I do not have to do everything manually (time after time, the hard way)...

Sign In or Register to comment.
Adding to Cart…

Daz 3D is part of Tafi

Connect

DAZ Productions, Inc.
7533 S Center View Ct #4664
West Jordan, UT 84084

HELP

Contact Us

Tutorials

Help Center

Sell Your 3D Content

Affiliate Program

Documentation Center

Open Source

Consent Preferences

JOIN DAZ

Memberships

Blog

About Us

Press

Careers

Bridges

Community

In the Studio

Gallery

Forum

DAZ STORE

Shop

Freebies

Published Artists

Licensing Agreement | Terms of Service | Privacy Policy | EULA

© 2025 Daz Productions Inc. All Rights Reserved.