0
$\begingroup$

I can create a custom property for my object by pressing "Add" on the "Custom Properties" tab. I would like to do this via script. I tried this way:

bpy.ops.wm.properties_add(data_path="object")
bpy.ops.wm.properties_edit(data_path="object", property="MyProperty", value="0", min=0, max=1, use_soft_limits=False, soft_min=0, soft_max=1, description="")

But I get a compiler error RuntimeError: Error: Direct execution not supported.

Is it possible to do this via script?

I'm using version 2.79. The purpose of the custom property is to use it to drive other properties.

$\endgroup$

1 Answer 1

0
$\begingroup$

You just do:

import bpy 

bpy.context.object.data["some_property"] = "Some value"
$\endgroup$
2
  • $\begingroup$ Thanks! Do you know how to edit the min/max values via script? When I add a property it shows in the UI that the min/max value is 0.0/1.0, but it goes way past one when using the slider to edit the property value. $\endgroup$
    – user56873
    Commented Oct 22, 2019 at 7:16
  • 2
    $\begingroup$ Nvm, found the answer. If somebody else is wondering blender.stackexchange.com/questions/143975/… $\endgroup$
    – user56873
    Commented Oct 22, 2019 at 7:39

You must log in to answer this question.