简体   繁体   中英

Blender Python API add property to object

Here's what I'm trying to do:

reference_object= bpy.context.active_object
reference_object.add_variable(name='some_property',value=5)
reference_object.some_property

and it would print back 5

I basically am trying to add a property to an object that's already been created and does not have the particular variable I'm trying to add in it's class. I tried looking up how to do this but I cannot seem to understand some of the other posts. Any advice would be great.

You can simply do:

reference_object['some_property'] = 5

And then access it:

reference_object['some_property']
# Prints back 5

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM