builtin_keyingset.py 1004 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. import bpy
  2. class BUILTIN_KSI_hello(bpy.types.KeyingSetInfo):
  3. bl_label = "Hello World KeyingSet"
  4. # poll - test for whether Keying Set can be used at all
  5. def poll(ksi, context):
  6. return context.active_object or context.selected_objects
  7. # iterator - go over all relevant data, calling generate()
  8. def iterator(ksi, context, ks):
  9. for ob in context.selected_objects:
  10. ksi.generate(context, ks, ob)
  11. # generator - populate Keying Set with property paths to use
  12. def generate(ksi, context, ks, data):
  13. id_block = data.id_data
  14. ks.paths.add(id_block, "location")
  15. for i in range(5):
  16. ks.paths.add(id_block, "layers", i, group_method='NAMED', group_name="5x Hello Layers")
  17. ks.paths.add(id_block, "show_in_front", group_method='NONE')
  18. def register():
  19. bpy.utils.register_class(BUILTIN_KSI_hello)
  20. def unregister():
  21. bpy.utils.unregister_class(BUILTIN_KSI_hello)
  22. if __name__ == '__main__':
  23. register()