propertie problem ?

i defined a scene propertie for a boolean prop

but when running script as an addon it gives an error
but no error if run from text edtior !

bpy.types.Scene.Ckeckcycleson1 = BoolProperty(
description=“True or False?”)
#bpy.context.scene[‘Ckeckcycleson1’] = False

how can this be corrected

thanks for any feedback

Basically because when you run it as an addon there is no way to really be sure if a scene instance has been fully initialized, so “bpy.context.scene[‘Ckeckcycleson1’] = False” which is trying to reference the current scene instance will cause an error. I believe they did let you do this before but they changed it a while back, so you can’t set them like that any more, I guess this has to do with making it more multithreading safe.

The right why (or at least the way that seems the right way to me) is to initialize your custom properties in an operator. I’m still very new to Blender scripting so I maybe wrong about that, but it seems to work for me that way.

can you give an example
cause i need to make this works

now all the other ones for int float are working why not the boolean ?


here you go.

Attachments (709 Bytes)

is there a way to make it works either in text editor and with addon too?

would make it a lot easier to debug



i can now see it is working in scene propertie
i was exepecting it in the tool or tool pro panel!

i’ll see if i can make the big script to accept these

now doe it means i have to do that for all float int properties ?
caue the other seem to work fine

so why is it dong this for the bool only ?

you defined a new class for init
but don’t see how where it is called?

class InitProps(bpy.types.Operator):


The short answer is you probably want to use:


and not:


As far as I know you cannot set any property types in an addon like this:

bl_info = {
“name”: “Test”,
“category”: “User”}

import bpy
from bpy.props import IntProperty
bpy.types.Scene.int_foobar = IntProperty()
bpy.context.scene.int_foobar = 1;

the last line will cause a restricted context error.

I’m not a big python fan so my skills are very limited but hopefully this will clear it up for you.

Attachments (833 Bytes)

ok i’l study these
and see how we can get this working in big script



not certain why scene properties are restricted!
i mean it is a general scene prop not a local prop!

thanks for this new link

all are restricted during startup, you can’t access anything in and bpy.context (other than user_preferences IIRC). This was a neccessary change, otherwise addons could crash blender or corrupt data.

i got anothe fiel with several props
for int float ect

and looking at the wiki page

can we simply move the prop inside the register part
to make these works normaly ?

bpy.types.Scene.Int2 = IntProperty(
description=“Enter an integer”,

bpy.types.Object.MyInt2 = IntProperty(name=‘int2’,default=0)

bpy.types.Scene.MyFloat1 = FloatProperty( # Myfloat is the name of the Float variable = Scene property
name=“Float”, # Name printed in button
description=“Enter a float”, # Tip tool
attr= “test”,
default = 33.33,
min = -100,
max = 100)

ect for other prop type

or can i include all these def inside an init class
and call it from inside the register or panel class?


use a distinct init operator, init on first operator run if you don’t want the user to hit an init button, or use an invoke() function in case of panels (you might need to call the invoke super class in derived classes).

got something in another thread