# Putting objects in collections, changing collection names, setting collection instsance offset

**URL:** <https://blenderartists.org/t/putting-objects-in-collections-changing-collection-names-setting-collection-instsance-offset/1465741>\
**Category:** Python Support\
**Created:** [May 22, 2023, 7:57pm UTC](https://blenderartists.org/t/putting-objects-in-collections-changing-collection-names-setting-collection-instsance-offset/1465741 "2023-05-22T19:57:16Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![thinsoldier](https://blenderartists.org/user_avatar/blenderartists.org/thinsoldier/32/619644_2.png) [@thinsoldier](https://blenderartists.org/u/thinsoldier)\
**Post date:** [May 22, 2023, 10:34pm UTC](https://blenderartists.org/t/putting-objects-in-collections-changing-collection-names-setting-collection-instsance-offset/1465741/2 "2023-05-22T22:34:32Z")

</div>

Using EasyBPY I came up with this

```auto
from easybpy import *

target = selected_objects()[0]
collection_name = target.name
create_collection( collection_name )
move_object_to_collection( target, collection_name)
target_position = location(target)
thecollection = get_collection( collection_name )
thecollection.instance_offset = target_position

```

```auto
from easybpy import *

target = selected_objects()[0]
thecollection = create_collection( target.name )
move_object_to_collection( target, thecollection )
thecollection.instance_offset = location(target)

```

* * *

```auto
import bpy

for obj in bpy.context.selected_objects:
    for existing_col in obj.users_collection:
        existing_col.objects.unlink(obj)
    col = bpy.data.collections.new(obj.name)
    bpy.context.scene.collection.children.link(col)
    col.objects.link(obj)
    col.instance_offset = obj.location

```

---

_[View the full topic](https://blenderartists.org/t/putting-objects-in-collections-changing-collection-names-setting-collection-instsance-offset/1465741)._
