gd-3d / bless

blender level editor software suite
MIT License
22 stars 2 forks source link

blender: dynamic properties #50

Closed yankscally closed 1 week ago

yankscally commented 3 months ago

I still havent been able to load dynamic properties into blender.

I'm trying to read json for engine and game profiles generated by the user.

yankscally commented 2 weeks ago

# iterate over our list of property groups
for groupName, attributeDefinitions in propertyGroupLayouts.items():
    # build the attribute dictionary for this group
    attributes = {}
    for attributeDefinition in attributeDefinitions:
        attType = attributeDefinition['type']
        attName = attributeDefinition['name']
        if attType == 'float':
            attributes[attName] = FloatProperty(name=attName.title())
        elif attType == 'string':
            attributes[attName] = StringProperty(name=attName.title())
        else:
            raise TypeError('Unsupported type (%s) for %s on %s!' % (attType, attName, groupName))

    # now build the property group class
    propertyGroupClass = type(groupName, (PropertyGroup,), attributes)

    # register it with Blender
    bpy.utils.register_class(propertyGroupClass)

    # apply it to all Objects
    setattr(bpy.types.Object, groupName, PointerProperty(type=propertyGroupClass))

the code from this article explains how to load dynamic properties. but it also looks like its able to use this to automate reading the property groups at the beginning as well? I will try this out today.

Valery-AA commented 2 weeks ago

i've switched priorities for the automation thinking about it, the json data management is not a crucial to an addon as this, i'll be working on it in these next few days