1
$\begingroup$

The following script creates Custom Property "TheNameOfTheSelectedObject_MyFloat" to the selected object, but it doesn't have "min" and "max" values:

import bpy
ob = bpy.context.active_object
ob[ob.name + "_MyFloat"]=0.0

How set 'min' and 'max' values for the created property to selected object from script?

The name of the created property needs to have object's name in it.

$\endgroup$

1 Answer 1

3
$\begingroup$

You can use the bpy.types.Object.id_properties_ui method that acts as a manager to change the custom properties settings on the fly.

import bpy
ob = bpy.context.active_object
prop_name = ob.name + "_MyFloat"
ob[prop_name] = 0.0
ob.id_properties_ensure()  # Make sure the manager is updated
property_manager = ob.id_properties_ui(prop_name)
property_manager.update(min=-10, max=10, soft_min=-5, soft_max=5)
$\endgroup$

You must log in to answer this question.

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