Skip to content

Move objects from one collection into another - #62

Merged
BradyAJohnston merged 8 commits into
BradyAJohnston:mainfrom
kolibril13:move
Mar 5, 2026
Merged

Move objects from one collection into another#62
BradyAJohnston merged 8 commits into
BradyAJohnston:mainfrom
kolibril13:move

Conversation

@kolibril13

Copy link
Copy Markdown
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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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.

Comment thread databpy/collection.py Outdated
Comment thread databpy/collection.py Outdated
Comment thread databpy/collection.py Outdated
@BradyAJohnston

Copy link
Copy Markdown
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 and others added 2 commits December 1, 2025 13:52
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@kolibril13

Copy link
Copy Markdown
Contributor Author

Changes applied!
New name: move_to_collection

@BradyAJohnston

Copy link
Copy Markdown
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

codecov Bot commented Dec 2, 2025

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.65%. Comparing base (de10a6c) to head (97efa00).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #62      +/-   ##
==========================================
+ Coverage   90.57%   90.65%   +0.08%     
==========================================
  Files          13       13              
  Lines         785      792       +7     
==========================================
+ Hits          711      718       +7     
  Misses         74       74              

☔ 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.

@kolibril13

Copy link
Copy Markdown
Contributor Author

better late then never, just added tests and linting also got fixed.

There is one error in the tests for blender 5.1, but I think that's unrelated to this pr.

  × No solution found when resolving dependencies:
  ╰─▶ Because only the following versions of bpy are available:
          bpy<5.1.dev0
          bpy==5.1.0b0
          bpy>5.2.dev0
      and bpy==5.1.0b0 has no wheels with a matching Python implementation tag
      (e.g., `cp311`), we can conclude that bpy==5.1.* cannot be used.
      And because you require bpy==5.1.*, we can conclude that your
      requirements are unsatisfiable.

      hint: You require CPython 3.11 (`cp311`), but we only found wheels for
      `bpy` (v5.1.0b0) with the following Python implementation tag: `cp313`

@BradyAJohnston

Copy link
Copy Markdown
Owner

I'm going to bump versions and set up databpy bpy>=5.1. I'll drop the 5.1 tests (#68) and then merge this and create a 0.6.2 release. Then I'll create a new 0.7 release which will be for bpy=>=5.1 going forward.

@BradyAJohnston
BradyAJohnston merged commit 8bc819b into BradyAJohnston:main Mar 5, 2026
21 checks passed
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.

3 participants