Post #4719: I am not an expert, and I will do my best to provide accurate information. Pleas

📋 Metadata

🏷️ Tags

addon-preferences beginner solved

  • Property Editor
  • Addon Preferences

💬 Content

I am not an expert, and I will do my best to provide accurate information. Please be aware that there may be inaccuracies or unclear expressions in my explanation. If you find any mistakes in my explanation, please feel free to point them out.


When you click the “Store in Addon Preferences” option, a selection screen like the one in the image appears. This is asking you where to save the data.

Pasted image 20230502012231Pasted image 20230502012231501×501 27.6 KB

The list displayed here consists of subclasses called ID subclasses, which inherit from the ID class. These subclasses are chosen based on the scope to which the data is related.

The selection criteria are determined by considering the purpose for which the property is used and the scope in which the data is required. I will introduce the main ID subclasses used.

  1. Object: Used to save properties related to objects. For example, it is suitable for managing information unique to individual objects, such as an object’s position and size.

  2. Scene: Used to save properties related to the entire scene. For example, it is suitable for managing information applied to the entire scene, such as rendering settings and environmental settings.

  3. Material: Used to save properties related to materials. For example, it is suitable for managing information unique to individual materials, such as textures and color settings.

  4. Mesh: Used to save properties related to meshes. For example, it is suitable for managing information unique to individual meshes, such as vertex positions and polygon configurations.

Inappropriate settings may result in non-functioning or unexpected behavior. For example, if you assign a property related to an object to a scene, that property cannot have different values for each object, and all objects will share the same value. This would result in unexpected behavior if the property was intended to hold information related to individual objects.

The script I created for you last week stored the camera setup information in a Scene, when in fact it would have been more appropriate to store it in an Object.


Let’s take a look at the actual steps.

Pasted image 20230502013548Pasted image 202305020135482560×1410 819 KB

  1. Set the name: One thing to note is that the name of the property will be used directly as an identifier. So, it’s better to follow Python naming conventions.

  2. Click “Store in Addon Preferences.”

  3. Select the datablock (ID subclass).

  4. You can access it in the code shown in the preview. (If a “?” is displayed, I interpret that as not being usable.)

You can access it with C.active_object.my_property in the Preview, so if you want to use this with PME, write it in the same way in the “Property” tab of the editing screen. Of course, you can access it in the same way from your custom scripts. In that case, I will suggest that there are multiple access methods.

  1. C.active_object.my_property: This accesses the custom property of the currently active object (the selected object that was last operated on).

  2. C.object.my_property: C.object refers to the same currently active object as C.active_object. Therefore, this notation can also access the same custom property.

  3. C.selected_objects[0].my_property: This accesses the custom property of the first object (index 0) in the list of selected objects. In this case, assuming the active object is selected, it can access the same custom property.


Now, for those who have read this far and still don’t quite get it, I’d like to explain that registering data in Blender is not that difficult. This demonstration shows how to add, retrieve, and delete custom properties in a scene using Blender’s Python console.

Pasted image 20230501232312Pasted image 20230501232312849×655 63.9 KB

  1. In the first line, C.scene['monkey'] attempts to retrieve a custom property named “monkey” from the scene. However, at this point, a property named “monkey” does not exist, causing a KeyError.

  2. In the next line, C.scene['monkey'] = "banana" adds a custom property named “monkey” to the scene and sets its value to “banana”.

  3. In the following line, C.scene['monkey'] retrieves the value of the custom property named “monkey” that was just added. This time, “banana” is correctly returned.

  4. Then, del C.scene['monkey'] deletes the custom property named “monkey” from the scene.

  5. In the last line, C.scene['monkey'] attempts to retrieve the custom property named “monkey” from the scene again. However, since it was deleted earlier, a KeyError occurs again.

Please try it out in the Python console yourself. You should be able to get a feel for how registering data in Blender is not that difficult.


❤️ 3 likes


🔗 View on Blender Artists