2
$\begingroup$

I've got 2 properties. My first:

hT = EnumProperty(items=(('A', "None", ""),
                         ('B',"LeMans 40", ""),
                         ('C',"LeMans 45", ""),
                         ('D',"LeMans 50", ""),
                         ('E',"LeMans 60", "")), 
                         default='C', name="Hardeware type")

My second:

 fW = IntProperty(name="Width", 
             default=838, min=800, max=2700, description="Furniture width")

My first property is for choosing the hardware of my furniture. Each hardware needs a minimum dimension of its furniture. So, for example, if I choose "LeMans 60", the "default" and "min" value of my second property need to change to 998.

Is it possible to do that or do I need to create a property with its own default, min and max value ?

$\endgroup$
  • $\begingroup$ I don't think you can do that, but a work around is to use update function for the first prop to set the value of the second and have the largest range (from min to max ) set for the second vale, and use an other update function for the second to check the state of the first and do the clipping job(to overcome a fixed max min ) $\endgroup$ – Chebhou Apr 4 '15 at 14:45
4
$\begingroup$

You can't do that to an actual instance:

import bpy
bpy.types.Object.prop = bpy.props.IntProperty()

bpy.context.active_object.prop
# this evaluates what the value is and returns <class 'int'> - not subscriptable

enter image description here

To adjust the min max etc. you need to re-declare it:

bpy.types.Object.prop = bpy.props.IntProperty(min=100, max=300)
# note: re-declaring will change it for all the objects

Changing the default value will not change the actual value of that static property - you will need to assign it a new value in that case. But newly created objects will have this new default.

You can make it work like this:

  1. create callback function for your hT property
  2. have this function re-declare your fW property with new parameters based on hT value
| improve this answer | |
$\endgroup$
  • $\begingroup$ Thanks for your answer. Finally, i think i'll create property for each furniture, more simple for me. Hope i don't need tout create too much hardeware ^^ $\endgroup$ – pistiwique Apr 5 '15 at 8:50
  • $\begingroup$ Has Blender changed to where we have to use bpy.props.IntProperty instead of using bpy.types...? I can only get it to work using props. And accessing the dict via ['soft_max'] doesn't work for me either, I can only update the property by re-declaring it. $\endgroup$ – jdk1.0 Dec 7 '18 at 5:28
  • $\begingroup$ @jdk1.0 you are right, it no longer works. $\endgroup$ – Jaroslav Jerryno Novotny Dec 7 '18 at 10:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.