Mesh Custom Properties editing through the Blender API

New mesh Custom Property can be created through the Blender python API by executing the following code:

with:

  • object_name – name of the mesh
  • property_name – new custom property name
  • property_value – value of this new property

After executing this command, the new property will be created and will be available in the Properties window – Object panel – Custom Properties sub-panel.

Like any object custom properties, the created property has a number of parameters that can be accessed by clicking the Edit button. These parameters can also be changed through the API.

If you access the custom property directly by name, you can only change its value. However, the RNA interface allows you to access its additional parameters through the API.

The following code creates a new property with the name “myCustomProp” for the active (selected) mesh, sets property value to 11, and sets some values to its additional parameters:

Force redraw of the scene.areas in two last lines of the script needs to update the Custom Properties sub-panel and make the created property visible and available in Blender interface.