How to write __annotations__ (scene property) in new scene?

by Pastrokkio   Last Updated September 06, 2019 05:15 AM

I have a scene with custom properties, written in a class, I am now able to access the values of these properties, I would like to know how to write these values in a new scene. For example:

This is the properties:

class MySceneProperty(bpy.types.PropertyGroup):

    my_bool: BoolProperty(default=false)
    my_int: IntProperty(default=0)
    my_float: FloatProperty(default=0.0)

def register():

    bpy.types.Scene.scene_prop = bpy.props.PointerProperty(type=MySceneProperty)

I would like to create a new scene and use the previous parameters, as they could be changed by the default value, so the approach would be.

def my_function(self,context):
    first_scene = bpy.context.scene

    ###get attributes:
    for key in first_scene.scene_prop.__annotations__.keys():
        first_attributes = getattr(first_scene.scene_prop, key)

    ###new scene creation:
    new_scene= bpy.data.scenes.new("New scene")    
    context.window.scene = new_scene

    Here I would like to set the attributes of the previous scene but I 
    don't know how to do it

    ###set attributes???  (this obviously produces an error)

    for key in new_scene.scene_prop.__annotations__.keys():
        setattr(new_scene.scene_prop, key) = first_attributes 


Related Questions


Updated April 25, 2015 21:06 PM

Updated July 14, 2015 13:06 PM

Updated May 25, 2018 16:15 PM

Updated October 10, 2018 17:15 PM

Updated July 31, 2016 08:06 AM