Python script: Give every scene a unique number Is it possible to give every scene the user creates an unique number? I thought about using the UUID lib for that so here is what I got so far:

def register():
    pow2_31 = 2**31
    mask32b = 0xFFFFFFFF
    p_uuid = uuid.uuid4().int
    p_uuid1 = p_uuid &gt;&gt; 96
    p_uuid1 -= pow2_31 if p_uuid1 &gt;= pow2_31 else 0
    p_uuid2 = (p_uuid &gt;&gt; 64) &amp; mask32b
    p_uuid2 -= pow2_31 if p_uuid2 &gt;= pow2_31 else 0
    p_uuid3 = (p_uuid &gt;&gt; 32) &amp; mask32b
    p_uuid3 -= pow2_31 if p_uuid3 &gt;= pow2_31 else 0
    p_uuid4 = p_uuid &amp; mask32b
    p_uuid4 -= pow2_31 if p_uuid4 &gt;= pow2_31 else 0
    bpy.types.Scene.mhfc_uuid1 = IntProperty(
                                name="projectUUID",
                                description="An unique ID. DON'T TOUCH THIS UNLESS YOU ARE SURE WHAT YOU DO.",
                                subtype="UNSIGNED",
                                default= p_uuid1, # most uniqueness possible??
                                options=set()
                                )
    bpy.types.Scene.mhfc_uuid2 = IntProperty(
                                name="projectUUID",
                                description="An unique ID. DON'T TOUCH THIS UNLESS YOU ARE SURE WHAT YOU DO.",
                                subtype="UNSIGNED",
                                default= p_uuid2, # most uniqueness possible??
                                options=set()
                                )
    bpy.types.Scene.mhfc_uuid3 = IntProperty(
                                name="projectUUID",
                                description="An unique ID. DON'T TOUCH THIS UNLESS YOU ARE SURE WHAT YOU DO.",
                                subtype="UNSIGNED",
                                default= p_uuid3, # most uniqueness possible??
                                options=set()
                                )
    bpy.types.Scene.mhfc_uuid4 = IntProperty(
                                name="projectUUID",
                                description="An unique ID. DON'T TOUCH THIS UNLESS YOU ARE SURE WHAT YOU DO.",
                                subtype="UNSIGNED",
                                default= p_uuid4, # most uniqueness possible??
                                options=set()
                                )


The problem is that all scenes have the same uuid while Blender is not restarted. How can I generate a new random number for each scene the user creates?
You have added a property called mhfc_uuid1 to the Scene class and set the default value to the pre-calculated value of p_uuid1. Every scene will then get this same value when it is created.

You may want to set the default to zero and then before using it check if it is zero and then set it to a generated value.

class MyOperator(bpy.types.Operator):

    def execute(self, context):
        if context.scene.mhfc_uuid1 == 0:
            context.scene.mhfc_uuid1 = generateuuid()
        do_interesting_stuff()
        return {'FINISHED'}


You could setup existing scenes as your addon is enabled by adding something like this after you add the properties.

for sc in bpy.data.scenes:
    sc.mhfc_uuid1 = generateuuid()