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.

  • $\begingroup$ Suggest do not use the operator. It is pretty easy to unlink and re-link the objects: blender.stackexchange.com/questions/175146/… 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*) $\endgroup$
    – brockmann
    Apr 20 '20 at 13:42
  • $\begingroup$ How to move a collection: blender.stackexchange.com/questions/172559/… (in case) $\endgroup$
    – brockmann
    Apr 20 '20 at 13:47
  • $\begingroup$ Are you sure, I will not get an error if I unlink from a collection but the object is not in it? $\endgroup$ Apr 20 '20 at 14:16
  • $\begingroup$ 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: blender.stackexchange.com/help/how-to-ask $\endgroup$
    – brockmann
    Apr 20 '20 at 14:27
  • 1
    $\begingroup$ To reiterate comment 1 above devtalk.blender.org/t/… $\endgroup$
    – batFINGER
    Apr 21 '20 at 4:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.