How to reach old bpy.prop values stored in Blend file

Hi all,

Im wondering how i can get to the data of old bpy.prop values. Being Booleans, string or int values. I have replaced my custom bpy.prop values from scene to to world so i can store multple variations of the settings using different worlds.

Normal the variables where stored like this in a bpy.data.scenes["Scene].thea_DispISO
This was a value for ISO value for a camera setting. But now that i replaced the prop bpy.types.Scenes with bpy.types.World the old values are still in the file but show now as bpy.data.scenes["Scene][“thea_DispISO”]
No matter what ive tried to reach them it keeps raising errors that the keys dont exist???
Even adding it exactly like this; print (bpy.data.scenes["Scene][“thea_DispISO”]) still gives me errors that this key doesnt exist.

Im pushing all the old values through a for loop say i can transfer them all to the world now, then when done i delete all custom prop settings.

Does anyone know a trick orso.

I tried going over all keys, by doing this loop;

For item in bpy.data.scenes["Scene"].keys:
    print("Key itm: %s" % item)

Then they dont show, cause there key naming is different. Ive attached another image from data-blocks panel>scenes>Scene

Attachments


Im believing the way i compare them is wrong. But it worked in some files earlier when the types where still registered.
This is the complete loop code.

class WORLD_PT_TransferOldWorldSettings(bpy.types.Operator):    bl_idname = "world.transferset"
    bl_label = "Transfer Old World Settings"
    bl_description = "Transfer all Display, Environment & Render Channels settings over from old setup to the new setup. New setup uses world preset, this means you can have multiple Environment, Display & Render Channels settings in one scene. Each world will have is own environment lighting setup, display settings & render channels. Please note that when IBL images are used, you need to update the texture link names by opening the the file picker and closing it, this simply updates the name in the texture slots. Also you should delete the old textures then."


    oldDisplay = ["thea_DispISO","thea_DispShutter", "thea_DispFNumber","thea_DispGamma","thea_DispBrightness","thea_DispCRFMenu","thea_DispSharpness","thea_DispSharpnessWeight",
"thea_DispBurn","thea_DispBurnWeight","thea_DispVignetting","thea_DispVignettingWeight","thea_DispChroma","thea_DispChromaWeight","thea_DispContrast","thea_DispContrastWeight","thea_DispTemperature","thea_DispTemperatureWeight","thea_DispBloom","thea_DispBloomItems","thea_DispBloomWeight","thea_DispGlareRadius","thea_DispMinZ","thea_DispMaxZ"]


    oldIBL = ["thea_IBLEnable","thea_IBLTypeMenu","thea_IBLWrappingMenu","thea_IBLFilename","thea_IBLRotation","thea_IBLIntensity","thea_IBLColorFilename"
,"thea_BackgroundMappingEnable","thea_BackgroundMappingWrappingMenu","thea_BackgroundMappingFilename","thea_BackgroundMappingRotation","thea_BackgroundMappingIntensity","thea_ReflectionMappingEnable","thea_ReflectionMappingWrappingMenu","thea_ReflectionMappingFilename","thea_ReflectionMappingRotation","thea_ReflectionMappingIntensity","thea_RefractionMappingEnable","thea_RefractionMappingWrappingMenu","thea_RefractionMappingFilename","thea_RefractionMappingRotation","thea_RefractionMappingIntensity",]


    oldPhySky = ["thea_EnvPSEnable","thea_SkyTypeMenu","thea_EnvPSTurb","thea_EnvPSOzone","thea_EnvPSWatVap","thea_EnvPSTurbCo","thea_EnvPSWaveExp","thea_EnvPSalbedo"]


    oldLoc = ["thea_Envlocation", "thea_EnvLat", "thea_EnvLong", "thea_EnvTZ", "thea_EnvDate", "thea_EnvTime"]


    oldGlobMed = ["thea_GlobalMediumEnable","thea_GlobalMediumIOR","thea_MediumAbsorptionCol","thea_MediumAbsorptionFilename","thea_MediumScatterCol","thea_MediumScatterFilename","thea_MediumAbsorptionDensity","thea_MediumAbsorptionDensityFilename","thea_MediumScatterDensity","thea_MediumScatterDensityFilename","thea_MediumCoefficient","thea_MediumMenu","thea_MediumPhaseFunction","thea_Asymetry"]


    oldChannels = ["thea_channelNormal","thea_channelPosition","thea_channelUV","thea_channelDepth","thea_channelAlpha","thea_channelObject_Id","thea_channelMaterial_Id","thea_channelShadow","thea_channelRaw_Diffuse_Color","thea_channelRaw_Diffuse_Lighting","thea_channelRaw_Diffuse_GI","thea_channelDirect","thea_channelAO","thea_channelGI","thea_channelSelf_Illumination","thea_channelSSS","thea_channelReflection","thea_channelRefraction","thea_channelTransparent","thea_channelIrradiance","thea_channelMask","thea_channelInvert_Mask"]


    transfer = bpy.props.StringProperty()


    from TheaForBlender.thea_properties import worldFilenameUpdated


    def execute(self, context):
        world = context.scene.world
        scn = context.scene
        scene = bpy.data.scenes[scn.name]
        wldName = bpy.data.worlds[world.name]
        thea_globals.displayPreset = False
        k = 0

        for display in self.oldDisplay:
            try:
                if scene[display] != None:
                    k+=1
                    thea_globals.log.debug("## Transfer Display: %s" % scene[display])
                    if self.transfer=="True":
                        world[display] = scene[display]
                        thea_globals.log.debug("## Transfer Display: %s" % scene[display])
                        k-=1
                        thea_globals.log.debug("## K: %s" % k)
                        del scene[display]
                    if self.transfer=="Delete":
                        k-=1
                        del scene[display]
            except:
                pass

        for IBL in self.oldIBL:
            try:
                if scene[IBL] != None or scene[IBL] != "":
                    k+=1
                    if self.transfer=="True":
                        world[IBL] = scene[IBL]
                        if IBL[-8:] == "Filename":
                            if len(scene[IBL])>0:
                                self.worldFilenameUpdated(scene,origin=IBL)
                                thea_globals.log.debug("## IBL: %s" % scene[IBL][-8:])
                        thea_globals.log.debug("## Transfer IBL: %s" % scene[IBL])
                        k-=1
                        del scene[IBL]
                    if self.transfer=="Delete":
                        k-=1
                        del scene[IBL]


            except KeyError as e:
                thea_globals.log.debug("## Transfer skipped: %s" % e)




        for PhySky in self.oldPhySky:
            try:
                if scene[PhySky] != None or scene[PhySky] != "":
                    k+=1
                    if self.transfer=="True":
                        world[PhySky] = scene[PhySky]
                        k-=1
                        thea_globals.log.debug("## Transfer Phys: %s" % scene[PhySky])
                        del scene[PhySky]
                    if self.transfer=="Delete":
                        k-=1
                        del scene[PhySky]


            except KeyError as e:
                thea_globals.log.debug("## Transfer skipped: %s" % e)






        for locations in self.oldLoc:
            try:
                if scene[locations] != None or scene[locations] != "":
                    k+=1
                    if self.transfer=="True":
                        world[locations] = scene[locations]
                        k-=1
                        thea_globals.log.debug("## Transfer Locations: %s" % scene[locations])
                        del scene[locations]
                    if self.transfer=="Delete":
                        k-=1
                        del scene[locations]


            except KeyError as e:
                thea_globals.log.debug("## Transfer skipped: %s" % e)






        for globMed in self.oldGlobMed:
            try:
                if scene[globMed] != None or scene[globMed] != "":
                    k+=1
                    if self.transfer=="True":
                        world[globMed] = scene[globMed]
                        k-=1
                        thea_globals.log.debug("## Transfer Ren Channels: %s" % scene[globMed])
                        del scene[globMed]
                    if self.transfer=="Delete":
                        k-=1
                        del scene[globMed]


            except KeyError as e:
                thea_globals.log.debug("## Transfer skipped: %s" % e)

        for channels in self.oldChannels:
            try:
                if scene[channels] != None or scene[channels] != "":
                    k+=1
                    if self.transfer=="True":
                        world[channels] = scene[channels]
                        k-=1
                        del scene[channels]
                    if self.transfer=="Delete":
                        k-=1
                        del scene[channels]
                    thea_globals.log.debug("## Transfer Settings: %s" % scene[channels])


            except KeyError as e:
                thea_globals.log.debug("## Transfer skipped: %s" % e)

        if k == 0:
            thea_globals.transferWorld = True
            scene.thea_transferCleaned = True
        if k != 0 and scene.thea_transferCleaned == True:
            thea_globals.transferWorld = True
        if thea_globals.transferWorld:
            self.report({'WARNING'}, "Transfer completed")
        if self.transfer == "Delete":
            self.report({'WARNING'}, "Old settings deleted")
        thea_globals.log.debug("## Transfer Settings Left: %s" % k)
        return{'FINISHED'}

The list is all the props which i want to copy to new prop. All the old props arent active no more cause i replaced them with bpy.types.World instead of bpy.types.Scene

When i test a print now adding the old bpy.types.Scene.thea_DispISO and print it using, print(“Old: %s” % scene.thea_DispISO) it does get print. However the for loop it made suddenly doesnt work.

But when i run a operator with adding the attribute “transfere=True” it does copy all items. I dont understand why it can copy it, but when i want to check and print them it doesnt work and raises errors that Key is not found

why not save values on a custom object variable
then this will always be saved with file and readable writtable anytime!

happy bl

Well so do the scene and world props. I think i have some mistake where it doesnt properly read a file when open a new file. I have a hadler for doing a check when a scene is loaded.

But what i dont understand is why it does read the values when i want to transfer them using the operator???

my guess is that on a new file the Vars don’t exist yet or not yet saved
and might give an error !

how do you check these prop when opening a file ?
have to check if exist yet or not.

happy bl

They are in the scene tab in a custom property. yet instead of being like this for example.

bpy.data.scenes["Scene'].thea_IBLFilename

they are like this

bpy.data.scenes["Scene']["thea_IBLFilename"]

.

the initial props where like this

bpy.types.Scene.thea_IBLFilename = bpy.prop.StringProperty(etc etc)

but i changed all of these to

bpy.types.World.thea_IBLFilename = bpy.prop.StringProperty(etc etc)

and now those custom properties show thus as the second example,

bpy.data.scenes["Scene']["thea_IBLFilename"]

So when now when i test it direct to call the property like

print(bpy.data.scenes["Scene']["thea_IBLFilename"]) 

it returns an error

I hope this explaines it better.

I just tested it and and actually print(bpy.data.scenes[“Scene”][“thea_IBLFilename”]) does return it properly. But when i want to loop over a list of items it does seem to work properly if the are like this [“thea_IBLFilename”] so when i tried this scene[self.oldIBL[3]] beeing that “thea_IBLFilename” is the 4th in the list it return error. I think it looks then for the property liek this scene.thea_IBLFilename cause its a variable beeing replaced. How can i get to check using brackets and the double quotes??

So this works;print(scene[“thea_locationEnable”])
but this doesnt work; print(scene[self.oldIBL[3]])

did you check the prop’s on the right of UI
to see if vars are defined ?

happy bl

got this old note here

property reregister
Can do simplywith ID props.

The value of a prop, lets call itscene.some_prop remains the same and is stored in blender. If yousave the file with scene.some_prop and dont definebpy.types.Scene.some_prop when you open it next, you wont be able toaccess it via scene.some_prop, however when you do define it, it willhave the previously set value.

The parameters of the prop arechanged, really its akin to running a script after an edit in thetext_editor.

hope it helps

happy bl

I was thinking about it indeed to add them all back, but i that would mean tons of extra code. How ever i also seem to have made some typo i guess or perhaps the way i call for the old properties. It seems both ways do work actually. So perhaps i need to recheck how i call for them in for in loop.

I believei can access them actually, there most have been something wrong perhaps in earlier part of code. Im not sure, in some scenes it did work while in others it did not. But im also using other global variables to let it go excecute or just look at those variables. In both methods i call the same operator but only if i add .transfer = “True” will it also execute it.

Each time i do an edit i restart Blender, that way im sure the code is properly loaded.