Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import c4d
- from c4d import gui
- from random import shuffle
- #Welcome to the world of Python
- def main():
- objs = doc.GetActiveObjects(2)
- if not objs:
- gui.MessageDialog('Please select some objects!')
- return
- mats = doc.GetActiveMaterials()
- if not mats:
- gui.MessageDialog('Please select some materials!')
- return
- n,l = 0,len(mats)
- doc.StartUndo()
- for obj in objs:
- n %= l
- if n == 0: shuffle(mats)
- tag = obj.MakeTag(c4d.Ttexture,obj.GetTags()[-1])
- doc.AddUndo(c4d.UNDOTYPE_NEW,tag)
- tag.SetMaterial(mats[n])
- n += 1
- doc.EndUndo()
- c4d.EventAdd()
- if __name__=='__main__':
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement