2
$\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$
  • $\begingroup$ Can you show the code you used to create the property? Or is this a property you created via the UI? $\endgroup$ – Ray Mairlot Nov 29 '14 at 17:00
  • $\begingroup$ @RayMairlot bpy.data.objects[name of my object]['name of my property'] = 2 $\endgroup$ – Omar Emara Nov 29 '14 at 17:47
5
$\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$

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.