Skip to content

Conversation

@kolibril13
Copy link
Contributor

Move objects from one collection into another, like this:

col = db.create_collection("A")
col = db.create_collection("B")
db.move_objects(cube, col)
db.move_objects([plane, sphere], col)

See here:

Screen.Recording.2025-11-17.at.15.55.03.mp4

Developed using this notebook:

%reload_ext autoreload
%autoreload 2
import sys
from pathlib import Path

project_root = Path.home() / "projects/databpy/"
sys.path.append(str(project_root))

import databpy
print(databpy.__file__)
import importlib
import databpy as db
import bpy

importlib.reload(databpy)

# Create the three objects first
bpy.ops.mesh.primitive_cube_add(location=(0, 0, 0))
cube = bpy.context.active_object
cube.name = "Cube"

bpy.ops.mesh.primitive_plane_add(location=(3, 0, 0))
plane = bpy.context.active_object
plane.name = "Plane"

bpy.ops.mesh.primitive_uv_sphere_add(location=(6, 0, 0))
sphere = bpy.context.active_object
sphere.name = "Sphere"
col = db.create_collection("A")
col = db.create_collection("B")
db.move_objects(cube, col)
db.move_objects([plane, sphere], col)

Copilot AI review requested due to automatic review settings November 17, 2025 15:01
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds functionality to move Blender objects between collections by introducing a new move_objects function. The function supports moving single objects or lists of objects by unlinking them from their current collections and linking them to a target collection.

  • Added move_objects function to handle single or multiple object transfers between collections
  • Exported the new function in the package's public API

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
databpy/collection.py Implements the move_objects function that unlinks objects from current collections and links them to a target collection
databpy/init.py Adds move_objects to the module's public exports

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@BradyAJohnston
Copy link
Owner

The co-pilot suggestions seem good if you could address them. I would additionally rename the function to something else as currently move_objects would imply moving their location in 3D space.

@kolibril13
Copy link
Contributor Author

Changes applied!
New name: move_to_collection

@BradyAJohnston
Copy link
Owner

Thanks, will also need you to add a couple of tests and also fix the linting issues that have been raised by ruff.

@codecov
Copy link

codecov bot commented Dec 2, 2025

Codecov Report

❌ Patch coverage is 25.00000% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.86%. Comparing base (5a11433) to head (6ca7aba).

Files with missing lines Patch % Lines
databpy/collection.py 14.28% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #62      +/-   ##
==========================================
- Coverage   90.53%   89.86%   -0.68%     
==========================================
  Files          13       13              
  Lines         782      789       +7     
==========================================
+ Hits          708      709       +1     
- Misses         74       80       +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants