ERROR WITH initSceneProperties(bpy.context.scene)

:evilgrin:hi again

I have this code:

import bpy
from bpy.props import *


        
        
def initSceneProperties(scn):
    
    print("initsceneprop",scn)
    # integer
    bpy.types.Scene.MyFloat = FloatProperty(
        name = "Calculadora", 
        description = "Calculadora basica",
        default = 00.00,
        )
 
    bpy.types.Scene.MyString = StringProperty(
        name = "Nota")
    scn['MyString'] = "escribe aqui"
    return
 
initSceneProperties(bpy.context.scene)

class SeleccionarAPanel(View3DPanel, Panel):
    bl_label = "edicion rapida"
    bl_space_type = "VIEW_3D"
    bl_region_type = "TOOLS" 
 
    
        
        
    def draw(self, context):
        layout = self.layout  
        scn = context.scene
        row = layout.row()
        layout.prop(scn, 'MyFloat') # crea el espacio calculadora
        row = layout.row()


row = layout.row()
        layout.prop(scn, 'MyString') #crea el espacio nota



if __name__ == "__main__":  # only for live edit.
    bpy.utils.register_module(__name__)

if I run into blender all is ok:


but if I save as default all disapear! :


but if I delet the initSceneProperties(bpy.context.scene) then is like any new code exist:


thanks for your help

Diego

your registration code is wrong

it should look like this:

import bpy
from bpy.props import *

class SeleccionarAPanel(bpy.types.Panel):
    bl_label = "edicion rapida"
    bl_space_type = "VIEW_3D"
    bl_region_type = "TOOLS" 
 
    def draw(self, context):
        layout = self.layout  
        scn = context.scene

        layout.prop(scn, 'MyFloat') # crea el espacio calculadora
        layout.prop(scn, 'MyString') #crea el espacio nota


def register():
    bpy.utils.register_module(__name__)

    bpy.types.Scene.MyFloat = FloatProperty(
        name="Calculadora", 
        description="Calculadora basica",
        default=0.00,
    )
 
    bpy.types.Scene.MyString = StringProperty(
        name="Nota",
        default="escribe aqui"
    )

def unregister():
    bpy.utils.unregister_module(__name__)
    del bpy.types.Scene.MyFloat
    del bpy.types.Scene.MyString

if __name__ == "__main__":

    register()

hi, thanks for it… but I don’t understant why I need to run the script even when I save that as default… :

also your code is really different to instructions in http://wiki.blender.org/index.php/Dev:2.5/Py/Scripts/Cookbook/Code_snippets/Interface why??

thanks

Diego

You may add a bl_info dict to make it a proper addon, install, enable and save as default.

The wiki pages are a bit dated, you should rather refer to other addons and the templates.

HI, thanks for answere… that really work… also I need add this at the begining of file:
bl_info = {“name”: “EXAMPLE”, “category”: “PANEL”}




Thanks again


:evilgrin::evilgrin: