setting Props... min and max... weird results

Hi everyone,

I’m working on setting up my own script to create a rig, and when I’m setting the props, I get weird results, especially with min and max. For example, this code bellow works fine with only one prop. But when I have 2, the min and max are only applied to my second one… but the first one can still go bellow 0 and above 1.

Did anybody faced the same kind of problem?
How do you set properties?

bpy.ops.object.mode_set(mode='POSE')    
arma.pose.bones[leg_IK_01_L_n.replace("IK","SK")]['scaleVolume'] = 1.0
arma.pose.bones[leg_IK_01_L_n.replace("IK","SK")]["_RNA_UI"] = {"scaleVolume": {"min":0, 
"max":1, "soft_min":0.0, "soft_max":1.0}}   
arma.pose.bones[leg_IK_01_L_n.replace("IK","SK")]['scaleFactorSlider'] = 1.0
arma.pose.bones[leg_IK_01_L_n.replace("IK","SK")]["_RNA_UI"] = {"scaleFactorSlider": {"min":0, 
"max":1, "soft_min":0.0, "soft_max":1.0}}

Thank you in advance for your answers

It seems that nobody has the answer for now… maybe it wasn’t clear enough :confused:

here is a better example:

this code will create an empty and add 2 props. when both of them should have min and max, when I run it, only the second one is limited… do you have the same problem? Is there a way to do it differently?


import bpy


bpy.ops.object.empty_add()
thisEmpty = bpy.context.active_object
thisEmpty.location = 0,0,0


bpy.data.objects[thisEmpty.name]['test01'] = 1.0
bpy.data.objects[thisEmpty.name]['_RNA_UI'] = {"test01": {"min":0, "max":1, "soft_min":0.0, "soft_max":1.0}}   


bpy.data.objects[thisEmpty.name]['test02'] = 1.0
bpy.data.objects[thisEmpty.name]['_RNA_UI'] = {"test02": {"min":0, "max":1, "soft_min":0.0, "soft_max":1.0}}   

Thnak you.

Mathias.

after searching quite a bit, I found the solution… so if anyone is wondering, the proper way to create props is:


import bpy
from bpy.props import *


bpy.ops.object.empty_add()
thisEmpty = bpy.context.active_object
thisEmpty.location = 0,0,0


 
bpy.types.Object.myRnaFloat = FloatProperty(
    name = "RNA float", 
    default = 1,
    min = 0, max = 1)


bpy.types.Object.myRnaFloat02 = FloatProperty(
    name = "RNA float02", 
    default = 1,
    min = 0, max = 1) 


bpy.data.objects[thisEmpty.name].myRnaFloat = 1
bpy.data.objects[thisEmpty.name].myRnaFloat02 = 1

hope that will help other people!

Mathias.

It’s not the “proper” way, there are actually two types of properties (they are stored identical however): ID props and bpy.props props (also API-defined properties). See e.g. http://blender.stackexchange.com/questions/6544/how-to-check-if-an-object-has-a-custom-property-with-python

Well, thank you for the clarification!
I understand, but honestly, the first way I tried is really buggy! So I’m glad that I found a way that works!

:slight_smile:
Mathias.