Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2017
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. import c4d
  2. from c4d import gui
  3. from random import shuffle
  4. #Welcome to the world of Python
  5.  
  6.  
  7. def main():
  8. objs = doc.GetActiveObjects(2)
  9. if not objs:
  10. gui.MessageDialog('Please select some objects!')
  11. return
  12. mats = doc.GetActiveMaterials()
  13. if not mats:
  14. gui.MessageDialog('Please select some materials!')
  15. return
  16. n,l = 0,len(mats)
  17. doc.StartUndo()
  18. for obj in objs:
  19. n %= l
  20. if n == 0: shuffle(mats)
  21. tag = obj.MakeTag(c4d.Ttexture,obj.GetTags()[-1])
  22. doc.AddUndo(c4d.UNDOTYPE_NEW,tag)
  23. tag.SetMaterial(mats[n])
  24. n += 1
  25.  
  26. doc.EndUndo()
  27. c4d.EventAdd()
  28.  
  29. if __name__=='__main__':
  30. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement