For example:
camera_obj = bpy.data.camera.new("Camera")
obj = bpy.data.objects.new("Camera", camera_obj)
works as expected. But is it possible to create obj and camera_obj in separate places, then link(is it even the correct term?) them together?
camera_obj = bpy.data.camera.new("Camera")
# Much code later...
obj = bpy.data.objects.new("Camera", None)
# Much much code later...
obj.data = camera_obj # Doesn't work. What should this line look like?
Noneas data is an empty and cannot be converted elsewise to another object type by setting the data. Nor can you make a mesh a camera or any other type once created. You can only assign another datablock of same type to an objects data. I'm sure this has been asked and answered before, but cannot find. – batFINGER Mar 29 '20 at 17:47bpy.data.objects.new? And it's decided by what kind ofobject_datais passed tonew...? Even after reading https://docs.blender.org/api/current/info_overview.html and https://docs.blender.org/api/current/info_api_reference.html several times I'm still confused. What's the relationships between Object, Datablock, and ID? Is ID just a baseclass of all of other subclasses? – Lai Yu-Hsuan Mar 29 '20 at 18:24bpy.data.collections have ID as a base class. egObjectinobjects,Meshinmeshesetc. – batFINGER Mar 29 '20 at 18:24