0
$\begingroup$
elif attr_format == 'Decimal':
    if attr_name.lower() == 'length':
        obj[attr_name] = obj.scale.x  
    elif attr_name.lower() == 'width':
        obj[attr_name] = obj.scale.y   
    obj[attr_name + "_min"] = attr_min_value  
    obj[attr_name + "_max"] = attr_max_value

So, looking at the above code, I am defining a custom property for the object 'obj'. What I want to do is, using python api, i want to edit the custom property and set the min and max for that property to 'attr_min_value' and 'attr_max_value' using python api.

$\endgroup$

1 Answer 1

1
$\begingroup$

Here's an example how to do this:

import bpy
from bpy import context


context.object['length'] = context.object.scale.x
length = context.object.id_properties_ui("length")
length.update(min=5, max=10.0)

context.object['width'] = context.object.scale.y 
width = context.object.id_properties_ui("width")
width.update(min=5, max=10.0)

In your case that would be:

elif attr_format == 'Decimal':
    if attr_name.lower() == 'length':
        obj[attr_name] = obj.scale.x
        length = obj.id_properties_ui("length")
        length.update(min=attr_min_value, max=attr_max_value)

    elif attr_name.lower() == 'width':
        obj[attr_name] = obj.scale.y
        width = obj.id_properties_ui("width")
        width.update(min=attr_min_value, max=attr_max_value)
$\endgroup$
0

You must log in to answer this question.

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