Practical One-Liner & Short Python Snippets That Save Hours in Blender

The best Blender scripts are not always giant add-ons. Sometimes the biggest productivity gains come from a tiny line of Python that deletes junk, renames a hundred objects, fixes pivots, or exports everything in one pass. This guide focuses on short, practical snippets you can paste into Blender’s scripting workspace and adapt in seconds.

Where these snippets fit

Use them as quick scripts, Text Editor macros, or the start of an add-on.

Most of these examples are intentionally tiny. That is the point. They solve repetitive tasks without the overhead of building a full tool first.

Good habit: test on duplicates first

Short scripts are powerful because they touch lots of data quickly. Before running anything destructive, save a versioned copy of the project or duplicate the affected collection.

Work on selected objects when possible.
Prefer filtering by type or collection.
Print object names before deleting them.
Turn a useful snippet into a reusable operator later.

Cleanup

Remove clutter before it becomes technical debt.
Cleanup 01

Purge orphan data in one shot

After deleting meshes, materials, or images, Blender can still keep unused datablocks around. This is the quick cleanup pass.

Python1 line
bpy.ops.outliner.orphans_purge(do_recursive=True)
Great before saving large production files or packing assets.
Cleanup 02

Delete all empties

Imported scenes often accumulate helper empties you no longer need. This removes them across the file.

Python2 lines
for obj in [o for o in bpy.data.objects if o.type == 'EMPTY']:
    bpy.data.objects.remove(obj, do_unlink=True)
Use carefully if empties are controlling rigs, constraints, or collection instances.
Cleanup 03

Remove all unused material slots on selected objects

Imported assets often contain bloated slot stacks. This trims only the selected objects.

Python5 lines
for obj in bpy.context.selected_objects:
    bpy.context.view_layer.objects.active = obj
    while obj.material_slots:
        bpy.ops.object.material_slot_remove_unused()
Useful after kitbash imports, CAD cleanup, or heavy FBX pipelines.
Cleanup 04

Hide every object that is not selected

This is a fast way to isolate the part of the scene you are actively editing.

Python2 lines
sel = set(bpy.context.selected_objects)
[o.hide_set(o not in sel) for o in bpy.context.scene.objects]
Perfect for debugging geometry or checking a cluttered layout scene.

Selection & organization

Batch operations are where tiny scripts really shine.
Organization 01

Rename selected objects with clean numbered names

When a scene is full of Cube.001-style noise, a short loop gives you readable object names instantly.

Python2 lines
for i, obj in enumerate(bpy.context.selected_objects, 1):
    obj.name = f"Asset_{i:03d}"
Swap Asset for Tree, Bolt, Window, or any project prefix.
Organization 02

Select all mesh objects in the scene

Sometimes you need to target only real geometry, skipping lights, cameras, armatures, and helpers.

Python3 lines
bpy.ops.object.select_all(action='DESELECT')
for obj in bpy.context.scene.objects:
    obj.select_set(obj.type == 'MESH')
This is a handy first step before applying transforms, modifiers, or export rules.
Organization 03

Move selected objects into a collection

Create a target collection if needed, then link every selected object into it for quick scene cleanup.

Python5 lines
col = bpy.data.collections.get("Exports") or bpy.data.collections.new("Exports")
if col.name not in bpy.context.scene.collection.children:
    bpy.context.scene.collection.children.link(col)
for obj in bpy.context.selected_objects:
    col.objects.link(obj)
This links objects to the collection, but does not automatically unlink them from old collections.
Organization 04

Print selected object names to the console

A tiny debugging helper when you want a quick report before doing something destructive.

Python1 line
print([obj.name for obj in bpy.context.selected_objects])
Simple, but extremely useful when testing scripts on large selections.

Transforms

Fix messy imported assets in seconds.
Transforms 01

Apply scale on every selected object

Many downstream problems come from unapplied scale. This makes the current selection safe for modifiers, physics, and export.

Python4 lines
for obj in bpy.context.selected_objects:
    bpy.context.view_layer.objects.active = obj
    obj.select_set(True)
    bpy.ops.object.transform_apply(location=False, rotation=False, scale=True)
Especially useful before bevels, arrays, booleans, or game-engine export.
Transforms 02

Set origin to geometry for selected objects

Imported assets often arrive with awful pivots. This snaps the origin to each object’s geometry center.

Python4 lines
for obj in bpy.context.selected_objects:
    bpy.context.view_layer.objects.active = obj
    obj.select_set(True)
    bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY', center='BOUNDS')
Useful for prop rotation, kitbash libraries, and export-ready pivots.
Transforms 03

Center selected objects on world origin

Quickly reset object locations without touching their mesh data or hierarchy.

Python2 lines
for obj in bpy.context.selected_objects:
    obj.location = (0, 0, 0)
Handy when normalizing assets for previews, turntables, or asset browsers.
Transforms 04

Parent selected objects to a new empty

This creates a clean control object for grouped transforms without joining geometry.

Python7 lines
empty = bpy.data.objects.new("CTRL_Master", None)
bpy.context.collection.objects.link(empty)
for obj in bpy.context.selected_objects:
    obj.parent = empty
A great way to build reusable scene controls for motion graphics or layout shots.

Modifiers & data tweaks

Mass-edit common settings instead of doing them one by one.
Modifiers 01

Add a bevel modifier to all selected meshes

One of the fastest ways to improve hard-surface readability is to bevel everything consistently.

Python5 lines
for obj in bpy.context.selected_objects:
    if obj.type == 'MESH':
        mod = obj.modifiers.new(name="Bevel", type='BEVEL')
        mod.width = 0.01
        mod.segments = 2
Change width values to suit your scene scale.
Modifiers 02

Enable auto smooth-style shading with sharp edges preserved

For imported hard-surface assets, this is often a faster fix than manually correcting normals object by object.

Python4 lines
for obj in bpy.context.selected_objects:
    if obj.type == 'MESH':
        bpy.context.view_layer.objects.active = obj
        bpy.ops.object.shade_auto_smooth()
Useful after CAD import or low-effort asset cleanup.
Modifiers 03

Set viewport display color for selected objects

Solid viewport colors can make scene organization much easier before materials are finalized.

Python3 lines
for obj in bpy.context.selected_objects:
    obj.color = (0.2, 0.7, 1.0, 1.0)
Switch viewport shading to display object color for instant color-coded organization.
Modifiers 04

Make every selected object single-user

When linked duplicates are getting in the way, this separates object and data ownership for the selection.

Python1 line
bpy.ops.object.make_single_user(object=True, obdata=True)
Run only when those shared datablocks are truly no longer desirable.

Render & export shortcuts

Automate the boring parts of output setup.
Output 01

Set render output path and format

Before running test renders or animation batches, lock in the output destination with one tiny snippet.

Python3 lines
scene = bpy.context.scene
scene.render.filepath = "//renders/shot01_"
scene.render.image_settings.file_format = 'PNG'
The // prefix makes the path relative to the current .blend file.
Output 02

Export each selected object as its own FBX

This is one of those scripts that pays for itself immediately in game-art or asset-store workflows.

Python9 lines
import os
folder = bpy.path.abspath("//exports/")
os.makedirs(folder, exist_ok=True)
for obj in bpy.context.selected_objects:
    bpy.ops.object.select_all(action='DESELECT')
    obj.select_set(True)
    bpy.context.view_layer.objects.active = obj
    bpy.ops.export_scene.fbx(filepath=os.path.join(folder, f"{obj.name}.fbx"), use_selection=True)
A massive time-saver when exporting prop libraries or modular environment pieces.
Output 03

Render the current frame from script

Great for test loops, look-dev automation, or button-driven mini tools.

Python1 line
bpy.ops.render.render(write_still=True)
Pair this with output-path setup for reliable one-click previews.
Output 04

Save the file with an incremented version number

Versioned saves are one of the safest habits in Blender, and this shortcut makes them painless.

Python1 line
bpy.ops.wm.save_as_mainfile(filepath=bpy.data.filepath.replace(".blend", "_v002.blend"))
For production use, wrap this in smarter version parsing so numbers increment automatically.