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

  • $\begingroup$ See blender.stackexchange.com/questions/130911/… and blender.stackexchange.com/questions/118118/… (probable dupes) $\endgroup$ – batFINGER Oct 26 '20 at 9:04
  • $\begingroup$ Will look into it thank you. Gonna have to test it soon $\endgroup$ – Michael Holmes Oct 26 '20 at 23:36
  • $\begingroup$ 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 $\endgroup$ – Michael Holmes Nov 2 '20 at 8:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.