2
$\begingroup$

I am trying to read custom property data from a blend file using Python and Blender v4.1. In the model, custom properties (e.g. an Integer property called "ASSET_ID") was added in the Layout Workspace.

Custom property in Layout Workspace

I can access the object in Python using the bpy module using a command like:

o = bpy.data.objects["asset_1"]

The documentation says I should be able to find the property using a statement like:

bpy.data.objects["asset_1"]["ASSET_ID"]

but the key is not found. Does anyone know where the Layout Workspace properties are stored?

Note: the reason I'm asking specifically about the Layout Workspace trying to debug this problem I noticed that property set from Python showed up in the Modeling Workspace properties but not in the Layout Workspace:

bpy.data.objects["asset_1"]["FOO"] = 1
bpy.ops.wm.save_as_mainfile(filepath="test_props.blend")

Modeling Workspace custom property

$\endgroup$

1 Answer 1

3
$\begingroup$

The problem doesn't have anything to do with workspaces, but rather the data block the custom properties are attached to. Pretty much every data block can have custom properties in Blender. In your case you're looking at a material data block custom properties. Notice the red circle icon with a checker board in the properties editor.

import bpy

bpy.data.objects["asset_1"].active_material["prop"]

# Or directly with material name
bpy.data.materials["Material"]["prop"]

Custom property in Layout Workspace

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .