SHARE
TWEET

hair reducer test

a guest Jun 9th, 2013 52 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import bpy
  2.  
  3. bl_info = {
  4.     "name": "Hair Reducer",
  5.     "author": "William Chargin (WChargin)",
  6.     "version": (0, 0, 1),
  7.     "blender": (2, 67, 0),
  8.         "location": "File > Save",
  9.     "description": ("Reduces hair particles on save and restores on load."),
  10.     "warning": "",  # used for warning icon and text in addons panel
  11.     "category": "System"}
  12.  
  13. @persistent
  14. def hair_reduce(dummy):
  15.     for ps in bpy.data.particles:
  16.         if ps.type == 'HAIR' and not 'actual_hair_count' in ps:
  17.             ps['actual_hair_count'] = ps.count
  18.             ps.count = 1
  19.  
  20. @persistent
  21. def hair_apply(dummy):
  22.     for ps in bpy.data.particles:
  23.         if ps.type == 'HAIR' and 'actual_hair_count' in ps:
  24.             ps.count = int(ps['actual_hair_count'])
  25.             del ps['actual_hair_count']
  26.  
  27. def register():
  28.     bpy.utils.register_module(__name__)
  29.     if not hair_apply in bpy.app.handlers.load_post:
  30.         bpy.app.handlers.load_post.append(hair_apply)
  31.     if not hair_reduce in bpy.app.handlers.save_pre:
  32.         bpy.app.handlers.save_pre.append(hair_reduce)
  33.     if not hair_apply in bpy.app.handlers.save_post:
  34.         bpy.app.handlers.save_post.append(hair_apply)
  35.  
  36. def unregister():
  37.     bpy.utils.unregister_module(__name__)
  38.     if hair_apply in bpy.app.handlers.load_post:
  39.         bpy.app.handlers.load_post.remove(hair_apply)
  40.     if hair_reduce in bpy.app.handlers.save_pre:
  41.         bpy.app.handlers.save_pre.remove(hair_reduce)
  42.     if hair_apply in bpy.app.handlers.save_post:
  43.         bpy.app.handlers.save_post.remove(hair_apply)
  44.                
  45. if __name__ == "__main__":
  46.     register()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top