How to link a new object to a scene in Blender 2.80 Python API

In Blender 2.79 Python API we can add a new object to a scene with:

If we try to do this in Blender 2.80, it throws an error:

‘bpy_prop_collection’ object has no attribute ‘link’

In Blender 2.80 API new objects mast be linked not to the scene, but to the scene collections:

To link a new object to the active scene collection:

To link a new object to the collection by its name:

 

0 0 votes
Article Rating
Subscribe
Notify of
guest
2 Comment
Newest
Oldest Most Voted
Inline Feedbacks
View all comments
Terefere
Terefere
1 month ago

you can also assign object to a scene without using context, by:

Last edited 1 month ago by Terefere
NikitaD
Admin
1 month ago
Reply to  Terefere

Yes. Thank you!