Complex Custom Properties

I’m using Blender as a sortof level editing tool and some objects need some complex metadata associated with them.

The most convenient way I have to do that right now is to copy paste a large block of text somehow.

Imagine a property value like this:


None
    randomObjects/TEST/Generic_NoDoor_4x4.objDat
4x4
    Generic_Jamb randomObjects/empty.objDat
    Generic_Arch randomObjects/TEST/Generic_Arch_4x4.objDat
2x2
    Generic_Jamb randomObjects/TEST/Generic_Jamb_Room_2x2to4x4.objDat
    Generic_Arch randomObjects/TEST/Generic_Arch_Room_2x2to4x4.objDat

This would just export along with other object data like transform, etc… Is this currently possible? It seems like string custom properties can’t be multiline and are limited to 128 characters.

I may develop some plugins later that make setting these properties more convenient, but that’s for a later stage in the project.

you could use prop ID for objects
but this would add prop to all objects you create
may be try to split into several prop instead of a big one

happy bl

Well, I guess there’s no quick dirty solution. I do want to have a good solution later for sure, but for now I need something where I can copy paste the same large block of text into about 95% of the objects in my level. My idea for now is to export ascii data, and ugh… manually copy paste the other data in. It’ll be good for a prototype I guess.

you could take a chance in phython forum and see what you get there
who knows someone else might have had same problem before!

happy bl

A simple script can go a long way in this case.

For instance, to add a custom property to all MESH based objects would look like this.


import bpy

myPropertyData = "what ever ascii data you want here."
for ob in bpy.data.objects:
    if ob.type == 'MESH':
        ob["myProperty"] = myPropertyData

The main problem you will have is getting the exporter to detect and spit out any custom data you add (whatever the means).

What file format are you exporting to? You may want to just skip adding any data to any objects in Blender and just alter the exporter to spit out the data you need.

Right now it’s some Human Readable ASCII but the data is per object. For now I can add the data manually after exporting other data like transforms and object names.

Or I can try a version of that script you have. I should be able to add it to only the selected objects.

I looked around for a script that allows setting such things and Atom’s solution is the closest thing I’ve found that’s both quick and dirty but gets the job done until I have something better.

Heh, added this lil modifier:


bl_info = {    "name": "Add Text Prop",
    "author": "",
    "version": (1, 0),
    "blender": (2, 6, 8),
    "description": "Simply adds a custom text property to selected objects",
    "warning": "",
    "wiki_url": "",
    "tracker_url": ""}
'''
Add custom text property to selected objects
'''


import bpy
from bpy.props import *


class AddTextProperty(bpy.types.Operator):
    '''Add custom text property to selected objects.'''
    bl_idname = "ill.add_text_prop"
    bl_label = "Add Text Prop"
    
    @classmethod
    def poll(cls, context):
        #make sure there are selected objects
        return context.selected_objects
    
    def execute(self, context):
        for obj in context.selected_objects:
            obj["doorData"] = """
None
    randomObjects/TEST/Generic_NoDoor_4x4.objDat
4x4
    Generic_Jamb randomObjects/empty.objDat
    Generic_Arch randomObjects/TEST/Generic_Arch_4x4.objDat
2x2
    Generic_Jamb randomObjects/TEST/Generic_Jamb_Room_2x2to4x4.objDat
    Generic_Arch randomObjects/TEST/Generic_Arch_Room_2x2to4x4.objDat
"""
        
        return {'FINISHED'}


    def invoke(self, context, event):        
            return self.execute(context)




### REGISTER ###


def register():
    bpy.utils.register_module(__name__)


def unregister():
    bpy.utils.unregister_module(__name__)


if __name__ == "__main__":
    register()