Custom Properties allow you to attach your own data to things in Blender. In this episode of Scripting for Artists Sybren shows how to create an importer that loads all OBJ files in a directory, and then allows reloading OBJ files with the click of a button.
Super cool ! Thank you for the list copy trick when iterating while altering the content !
Question about custom properties. Can they store a specific blender object type (or a pointer to a specific blender object !?).
Exemple for my use case on an active grease pencil object:
>>> bpy.context.object.data.layers['Lines'].frames[0].strokes[1]
bpy.data.grease_pencils['Suzanne']...GPencilStroke
I want to store direct access to this stroke, because data_path has good chance to become invalid (layer name can change, as for both frame and stroke index).
If I assign this in a variable it works well for the curent session, but once I save and reload/revert the file I lost the references...
Is there a way to store this type using properties ?
*@Samuel Bernou* You could have a look at bpy.props.PointerProperty
, that might do what you need.
*@Sybren A. Stüvel* Ok, I tried with a pointer prop, but I obviously don't understand how it work (or maybe it's not possible with GP strokes)
>>> strokeid_3 = C.object.data.layers.active.active_frame.strokes[3].rna_type
>>> bpy.types.Scene.three = bpy.props.PointerProperty(type = strokeid_3, name = "three")
TypeError: PointerProperty(...) expected an RNA type, failed with type 'GPencilStroke'
Traceback (most recent call last):
File "<blender_console>", line 1, in <module>
ValueError: bpy_struct "Scene" registration error: three could not register
But yeah PointerProperty would have been the way to go. Thank you for pointing this ;)
Join to leave a comment.