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(
name=“Wings”,
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 ?

thanks

here you go.

Attachments

example.zip (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

thanks

sorry

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):

thanks

The short answer is you probably want to use:

bpy.context.scene.Ckeckcycleson1

and not:

bpy.context.scene[‘Ckeckcycleson1’]

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

example2.zip (833 Bytes)

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

thanks

see
http://wiki.blender.org/index.php/Extensions:2.6/Py/API_Changes#Restricted_Context

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

anyway
thanks for this new link

all are restricted during startup, you can’t access anything in bpy.data 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(
name=“Integer”,
description=“Enter an integer”,
default=32)

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?

thanks

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

thanks