def properties(object):
for object in bpy.data.collections["furniture"].all_objects:
    object.orient_vector = object.matrix_local[0:3][0][0:3][:]
object.object_front_name = object.name.split("_")[0]
object.object_last_name = object.name.split("_")[1]

Above showed is a part of my work, I'm trying to custom some unique properties for one object. But seems not work when I entered "object.xxx = 1" and printed.

(by the way object can be called solely right? Don't need to type "bpy.xxx.object")

  • $\begingroup$ object['my_prop'] = 'hello' $\endgroup$
    – X Y
    Apr 16, 2022 at 7:16
  • $\begingroup$ TypeError: 'type' object does not support item assignment. Seems object class don't have setitem @XY $\endgroup$
    – P. Scotty
    Apr 16, 2022 at 7:52
  • $\begingroup$ don't use object as a variable. this is python's general class designed for other purposes. you can assign bpy.context.object to some variable like obj (instead of object) so you can use it later. $\endgroup$ Apr 16, 2022 at 8:01

1 Answer 1

import bpy

oj = bpy.data.objects["Cube"]
oj["my_prop"] = "hello"

print("Object name: ", oj.name)

enter image description here

  • $\begingroup$ if the properties is not data version? Do I still have to define it in bpy.data.object instead of context? $\endgroup$
    – P. Scotty
    Apr 16, 2022 at 14:31
  • $\begingroup$ if your active object is "Cube", that means bpy.context.object and bpy.data.objects["Cube"] are same. $\endgroup$
    – X Y
    Apr 16, 2022 at 14:44

You must log in to answer this question.

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