0

I'm looking for a way to have a dynamic amount of string properties. currently I have setup an array which appends a bunch of string properties to a list, this is all fine and well except i can't place the property in the layout due to it not having an identifier (well not that i know of).

    for _ in self.MATERIAL_LIST:
        self.TEXTURE_PROPERTIES.append(props.StringProperty(name=_, description='{} texture'.format(_)))       
        imageBox.prop(self.properties, 'TEXTURE_PROPERTIES')

above you can see I have a Material list which is a list of all the names of the materials

I wish to place each elemt of the array in a UIlayout box called 'imageBox' any help is appreciated and even alternative or more efficent ideas would be appreciated.

EDIT:imageBox.prop(self.properties, 'TEXTURE_PROPERTIES') causes an error as TEXTURE_PROPERTIES property cannot be found

  • See https://blender.stackexchange.com/questions/130911/how-can-i-create-multiple-variables-in-a-propertygroup and https://blender.stackexchange.com/questions/118118/blender-2-8-field-property-declaration-and-dynamic-class-creation (probable dupes) – batFINGER Oct 26 '20 at 09:04
  • Will look into it thank you. Gonna have to test it soon – Michael Holmes Oct 26 '20 at 23:36
  • I had better success with adding a class of property group, however I am struggling to placing properties defined in annotations, I have no problem placing imageBox.prop(self.TEXTURE_PROPERTIES, 'prop1')

    but if i had something like

    self.TEXTURE_PROPERTIES.__annotations__['mat_0'] = props.StringProperty(name = 'Material 0') imageBox.prop(self.TEXTURE_PROPERTIES, 'mat_0')

    I have no success

    ,also if I define the annotations in the class and not later I have no problems

    – Michael Holmes Nov 02 '20 at 08:06

0 Answers0