bpy.props.2.py 659 B

12345678910111213141516171819202122232425262728
  1. """
  2. PropertyGroup Example
  3. +++++++++++++++++++++
  4. PropertyGroups can be used for collecting custom settings into one value
  5. to avoid many individual settings mixed in together.
  6. """
  7. import bpy
  8. class MaterialSettings(bpy.types.PropertyGroup):
  9. my_int: bpy.props.IntProperty()
  10. my_float: bpy.props.FloatProperty()
  11. my_string: bpy.props.StringProperty()
  12. bpy.utils.register_class(MaterialSettings)
  13. bpy.types.Material.my_settings = bpy.props.PointerProperty(type=MaterialSettings)
  14. # test the new settings work
  15. material = bpy.data.materials[0]
  16. material.my_settings.my_int = 5
  17. material.my_settings.my_float = 3.0
  18. material.my_settings.my_string = "Foo"