0

I'm currently creating a script that I'm using to organize a lot of assets at once (I will share it once it works).

I want to use move_to_collection so that I don't have to keep track of all the collections where the asset currently is. But move_to_collection wants a Collection ID, and I only have the collection object retrieved from bpy.data.collections and I would love to get the collection ID from it.

batFINGER
  • 84,216
  • 10
  • 108
  • 233
  • Suggest do not use the operator. It is pretty easy to unlink and re-link the objects: https://blender.stackexchange.com/questions/175146/moving-many-objects-to-a-new-collection/175152#175152 Also to be on the safe side, consider to iterate through the collections in the current scene (bpy.context.scene*) not iterating over data blocks (bpy.data*) – brockmann Apr 20 '20 at 13:42
  • How to move a collection: https://blender.stackexchange.com/questions/172559/python-how-to-move-collection-into-another-collection/172579#172579 (in case) – brockmann Apr 20 '20 at 13:47
  • Are you sure, I will not get an error if I unlink from a collection but the object is not in it? – AntonioCorrenti Apr 20 '20 at 14:16
  • Not exactly sure what you're talking about... All I can say is that using the index operator Collection["CollectionName"] is even more error prone than anything else. Suggest add more details to your question. Please read: https://blender.stackexchange.com/help/how-to-ask – brockmann Apr 20 '20 at 14:27
  • 1
    To reiterate comment 1 above https://devtalk.blender.org/t/where-to-find-collection-index-for-moving-an-object/3289/2?u=batfinger – batFINGER Apr 21 '20 at 04:42

0 Answers0