0

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.

1 Answers1

0

You just do:

import bpy 

bpy.context.object.data["some_property"] = "Some value"
Martynas Žiemys
  • 24,274
  • 2
  • 34
  • 77
  • 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. –  Oct 22 '19 at 07:16
  • 2
    Nvm, found the answer. If somebody else is wondering https://blender.stackexchange.com/questions/143975/how-to-edit-a-custom-property-in-a-python-script –  Oct 22 '19 at 07:39