Skip to main content

All Questions

2 votes
2 answers
204 views

Getting the direct objects contained in a collection

I'm using collection.objects to ask for the objects in a collection, and it gives me the whole object hierarchy. How do I get just the root of the hierarchy? So for ...
TomMelson's user avatar
4 votes
2 answers
860 views

Bpy get the name of a collection an object belongs to

For an if statement, I want to check if my current object is in collection 'coll' Here's what I have so far: ...
Zak Nelson's user avatar
1 vote
1 answer
234 views

How to select a collection from the 3D viewport by right-clicking on one of the objects in a collection

Recently, I asked a question about how to select a parent directly from the viewport by right-clicking. However, this time, I would like to know if it is achievable to select a collection using the ...
Yousuf Chaudhry's user avatar
0 votes
1 answer
371 views

Removing objects from collection with script works but gives an error

I'm sorry in advance if my script looks really messy and not optimised, it's my first time using python or a dev language for that matters. I've tried to setup a script that, among other things, ...
CédricF's user avatar
0 votes
1 answer
566 views

How to sort objects from a collection using python?

So I'm trying to animate a rubiks cube via a python script using the scripting capabilities given with Blender. My current cube looks like this: It consists of 27 separate objects (cubelets) that ...
Jakob Runge's user avatar
1 vote
1 answer
2k views

How to select objects by collection from selected objects in the scene with Python?

I just started using python and got stuck. I found this script which is used to take the selected objects from the scene and add them to a list based on the name of the material. I should do almost ...
daniele's user avatar
  • 81
5 votes
1 answer
8k views

How to move multiple objects into another collection?

I am using this code which works very well for one object. I select Object_A and it moves to the collection MyCollection. If I ...
Michael Teiniker's user avatar
3 votes
4 answers
3k views

How to duplicate a certain collection using Python?

Is it possible to duplicate a collection from a Python script? When I do it manually, the Console shows bpy.ops.outliner.collection_duplicate(), however if I call ...
user1566515's user avatar
0 votes
0 answers
31 views

How do I paint all of my objects in collection to different colors via python?

I want every object in my collection to have different color. How do I make it via python scripting?
cxnt 's user avatar
  • 397
0 votes
1 answer
1k views

Blender 2.8 How do I set object/collection active and apply my script for each of collection's objects in via python?

I have a collection of leaves in my scene which calls Lines: Here's a little snippet that creates another leaf from leaf and randomize it: ...
cxnt 's user avatar
  • 397
1 vote
1 answer
1k views

Change Object Index of Objects in a Collection Instance

If you make instanced copies of a bunch of objects (alt+D), then it is possible to give them different Object Indices from their originals. This is useful if you are using Object Index as a mix factor ...
Ascalon's user avatar
  • 6,647
8 votes
2 answers
11k views

How to get the collection an object belongs to?

I can access objects belonging to a collection like so: objects_in_collection = bpy.data.collections["My_Collection"].objects How can I access the collection a ...
coCoKNIght's user avatar
5 votes
4 answers
18k views

Whats the Blender 2.8 command for adding an object to a collection using python?

I currently have a method that does: self.myCol = bpy.data.collections.new(self.collection_name) bpy.context.scene.collection.children.link(myCol) This method ...
Inkplay_'s user avatar
  • 737