2.5 propreties bug for operation like X ?

i did a multiplication of an integer propertie and a float propretie
but get an error that this cannot be done ?

is there another way to write this so it works fine?


 
import bpy
from bpy.props import *
from mathutils import *
from math import *
 
 
 
global filesubtypes
filesubtypes = ['FILE_PATH', 'DIR_PATH', 'FILENAME']
 
last_iesmenu1 = 'None'
last_iesmenu1menu1= 'None'
 
 
# Integer Property
 
 
bpy.types.Scene.qtylamps1 = IntProperty(
name="qtylamps1",
description="Enter Lamps Qty")
bpy.context.scene['qtylamps1'] = 7
 
 
# Integer Properties
 
bpy.types.Scene.gridsize1 = IntProperty(name='Grid size')
bpy.context.scene['gridsize1'] = 4
 
 
print ('^^^^^^^^^^^^^^^^^^^^     Propertie  Qty Lamps =',bpy.context.scene['qtylamps1'] )  #  Print value of the propertie
 
 
 
# Float Numbers Properties
 
bpy.types.Scene.wattsperlampfile = FloatProperty(       #  Myfloat is the name of the Float variable = Scene property
 name="Total Watts",              #  Name printed in button
 description="Enter Distance to floor",         #  Tip tool
 default = 150.0,
 min = 0.0,
 max = 10000.0)
 
 
bpy.types.Scene.wattstotal1 = FloatProperty(       #  Myfloat is the name of the Float variable = Scene property
 name="Total Watts",             #  Name printed in button
 description="Total Watts",           #  Tip tool
 default = 3.0,
 min = 0.0,
 max = 100.0)
 
print ()
print ('Qtylamp =',bpy.context.scene['qtylamps1'] )
print ('Watts per lamp =',bpy.context.scene.wattsperlampfile)
 
bpy.context.scene.wattstotal1=bpy.context.scene['qtylamps1']*bpy.types.Scene.wattsperlampfile 
print ()
 
bpy.types.Scene.lumensperlamp = FloatProperty(        #  Myfloat is the name of the Float variable = Scene property
 name="Lumens per lamp from file",           #  Name printed in button
 description="Lumens per lamp from file",        #  Tip tool
 default = 2000.0,
 min = 0.0,
 max = 1000000.0)
 
 
 
 
bpy.types.Scene.lumenstotal1 = FloatProperty(       #  Myfloat is the name of the Float variable = Scene property
 name="Total Watts",             #  Name printed in button
 description="Enter Distance to floor",        #  Tip tool
 default = 3.0,
 min = 0.0,
 max = 100.0)
 
 
bpy.context.scene.lumenstotal1=bpy.context.scene['qtylamps1']*bpy.types.Scene.lumensperlamp
 
print ()
print ('Qtylamp =',bpy.context.scene['qtylamps1'] )
print ('Lumen s per lamp =',bpy.context.scene.lumensperlamp )
print ('Watts per lamp =',bpy.context.scene.wattsperlampfile)
print ()
print ('Lumens Total =',bpy.context.scene.lumenstotal1 )
print ('Watts Total =',bpy.context.scene.wattstotal1)
print ()
 
 
 
 
 

Thanks for any help

What’s the error message say?

And, you know, bpy.types.Scene.wattsperlampfile is a FloatProperty.

as i said cannot add a float with an integer as properties

Traceback (most recent call last):
File “bugpropr1.py”, line 58, in <module>
TypeError: bpy_struct: item.attr = val: Scene.wattstotal1 expected a float typ
location:<unknown location>:-1

so wondering if this is a bug or not the proper way to add 2 properties?
normally theses properties are like variables so should be able to add 2 properties i think!

tested in ver 32045 a few days old and also in ver 31970

Thanks

Like I said, “bpy.types.Scene.wattsperlampfile is a FloatProperty

i added this answer by error yesteday in another thread!

i found a way to make it work !

but not certain why it is working

if i use this
bpy.context.scene.wattstotal1 =bpy.context.scene[‘qtylamps1’]*bpy.context.scene.wattsperlampfile
it does not work !
and bpy.context.scene.wattstotal1 is the value of the var and should work

but if i use this
bpy.types.Scene.wattstotal1 =bpy.context.scene[‘qtylamps1’]*bpy.context.scene.wattsperlampfile
it does work!
and here bpy.types.Scene.wattstotal1 is the class for this var !

si not certain why it is wokring like this !

i tough this would work like normal variables but seems it’s not!

i can upload the latest working script if needed!

happy 2.5

Uncle Entity is correct Ricky. Merrily fetching variables from the bpy and hoping they are the correct type will just lead to bugs as you are experiencing.

You can always force the type, if you are having problems.


float(bpy.something) * float(bpy.otherthing)

http://docs.python.org/library/stdtypes.html

ok but i tough that the value as such was with
bpy.context.scene.wattstotal1 and not working for adding or X!
but is working when printing but not with sum or multiply operation

seems that when you add ( multiply ) values you need to use
bpy.types.Scene.wattstotal1 which is supposed to be the class for this var!
and it is working

but if i use the value it does not work why ?
this properties value should be like anyother variable value like X= X +1!
so should be able to use the same with properties values

jsut found something strange here

seems that you can assign a value with
bpy.context.scene[‘angfloor1’] = 36

any be this is the way to go instead of using bpy.types.Scene.wattstotal1 ?

Thanks

@ Atom sorry PM is not working!
can you have a look at http://blenderartists.org/forum/showthread.php?t=171630&p=1740476#post1740476
i added some comments for you 2 or 3 posts before the end!
if you have any specific ideas requirement
you can always add the theses to that thread
cause i’m working a lot on this right now
so time to take any feedback into consideration!

happy 2.5

What I was saying is you can’t (as the very helpful error message was saying) multiply a float and a bpy.props.FloatProperty as is done here;

bpy.context.scene.wattstotal1=bpy.context.scene['qtylamps1']*bpy.types.Scene.wattsperlampfile 

But of course not directly saying it because hunting down bugs is a good learning experience.

there seems to be 3 ways

1 - bpy.context.scene.wattstotal1
this can be use to print the value
but what else ?

2- bpy.types.Scene.wattstotal1
which simply gives acces to the class for this propertie

3 - bpy.context.scene[‘angfloor1’] = 36

which seems to be the way to assign values like = 3 or = A X b

but i was also able to assign with bpy.context.scene.angfloor1

so which one would be the way to assign a value to a propertie?

and wondering here if there more then one way to assign a value !

Thanks