0
$\begingroup$

I have a code similar to this, that creates a custom property for objects and then assigns a data from file to it but it stops working in Blender 2.93. I tested it in 2.79 and 2.80 with no problems but 2.93 shows only "<_PropertyDeferred, , {'options': {'HIDDEN'}, 'subtype': 'BYTE_STRING'}>"

import bpy

class MyImportedItem(bpy.types.PropertyGroup):
    data = bpy.props.StringProperty(options={'HIDDEN'}, subtype='BYTE_STRING')


def register():
    bpy.utils.register_class(MyImportedItem)
    bpy.types.Object.my_imported_item = bpy.props.PointerProperty(type=MyImportedItem)

def unregister():
    bpy.utils.unregister_class(MyImportedItem)
    bpy.types.Object.my_imported_item = bpy.props.PointerProperty(type=MyImportedItem)
    
    
if __name__ == "__main__":
    register()
    
    
file_path = "C:\\test.data"

with open(file_path, 'rb') as f:
    data = f.read() 

print("file data is {}".format(data)) 
 
obj = bpy.data.objects.new("test", None)
obj.my_imported_item['data'] = data

print("object data is {}".format(obj.my_imported_item.data))
$\endgroup$
2
  • 1
    $\begingroup$ Hello, I can't be bothered finding a duplicate but basically, you need to replace data = ... with data : ... $\endgroup$
    – Gorgious
    Commented Feb 8, 2022 at 22:49
  • $\begingroup$ Thank you a lot, it's working! $\endgroup$ Commented Feb 8, 2022 at 23:29

0

You must log in to answer this question.

Browse other questions tagged .