Question about scripting Custom Property controls

Hello,

I have a scripting question which may or may not be challenging. Currently I’m maintaining a set of custom Blender import/export scripts for MDB formatted files that are used in a game engine. The imported MDB files carry information about some game-related texture properties that I’d like to retain in preparation for export. This information consists of a set of eight bit flags, some of which are pretty useful in controlling how a model will work in the game.

From web searches, it looks like I can store these custom properties on the material. However, I would also like to be able to modify these flags on a per material basis within Blender. I was thinking I could manage the bit flags using stateful controls located in the Custom Property section at the bottom of the Material Properties panel. If possible, the import would automatically create these controls, then the Export would query the control states. If possible, I’d like to maintain these controls and their states across saves to the .blend files.

Does this seem like a feasible approach? If so, please could you give me some pointers about the right way to get started?

I’m by no means an expert in Blender or python, and at present I know just enough to be useful for my modding needs. Thank you.

Nobody knows? Oh well.

you can either use ID properties on the material, or bpy.props properties on bpy.types.Material. Note that it’s not possible to have custom properties at MaterialSlot or TextureSlot level.

The advantage of ID props are that you don’t need an addon to show the properties, although the Custom Properties panel doesn’t allow you to customize the way they are represented and you can’t add own UI elements (and booleans show as ints for instance, no checkbox, no support for enums etc.).

They are easy to create, try this with the default cube (with material) in Python console and move mouse over Custom Properties panel:

C.object.data.materials[‘Material’][‘my_prop’] = 123

Thank you, CoDEmanX.