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$
2
  • $\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, 2015 at 14:45
  • $\begingroup$ Related blender.stackexchange.com/questions/195459/… $\endgroup$
    – batFINGER
    Sep 23, 2020 at 14:21

1 Answer 1

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
$\endgroup$
3
  • $\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, 2015 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$ Dec 7, 2018 at 5:28
  • $\begingroup$ @jdk1.0 you are right, it no longer works. $\endgroup$ Dec 7, 2018 at 10:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .