3
$\begingroup$

I have created a custom property and want to set a minimum and a maximum for it through python; I tried to make it using bpy.ops.wm.properties_edit but it didn't work,so how can I edit a custom property with Python?

Here is how I defined my property:

bpy.data.objects[name of my object]['name of my property'] = 2 
$\endgroup$
2
  • $\begingroup$ Can you show the code you used to create the property? Or is this a property you created via the UI? $\endgroup$ Commented Nov 29, 2014 at 17:00
  • $\begingroup$ @RayMairlot bpy.data.objects[name of my object]['name of my property'] = 2 $\endgroup$ Commented Nov 29, 2014 at 17:47

2 Answers 2

8
$\begingroup$

This is what you do to set min to 0 and max to 500, the soft_min and soft_max is optional and is only for dragging in gui:

ob = bpy.data.objects[name_of_my_object]

# this is a dictionary containing IDprops settings
# this creates it and erases it:
ob["_RNA_UI"] = {}

# add properties settings like this:
ob["_RNA_UI"]['name_of_my_property'] = {"min":0.0,
                                        "max": 500.0,
                                        "soft_min":0.0,
                                        "soft_max":500.0}
$\endgroup$
0
$\begingroup$

BLender 3.1 method.

lod_prop = "LOD"
control_object[lod_prop] = 1
id_props = control_object.id_properties_ui(lod_prop)
id_props.update(min=0,
                max=2,
                )
control_object.property_overridable_library_set('["LOD"]', True)
$\endgroup$

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.