---------------------------------------------------------------------

import maya.cmds as cmd

import maya.mel as mel

import random

def cm(fun):

   ret=mel.eval_r(fun)

   return ret


footage=cmd.ls(sl=True,l=True)  ####素材


##########################

num=1000       ###放置得数量

rangescale=0.3   ###随机大小得范围

minscale=0.1     ###最小得模型尺寸

#####################


selobj=cmd.ls(sl=True,l=True)

emi=cm('emitter -type surface -r '+str(num*66.5)+' -sro 0 -nuv 0 -cye none -cyi 1 -spd 0 -srn 0 -nsp 1 -tsp 0 -mxd 0 -mnd 0 -dx 1 -dy 0 -dz 0 -sp 0 ;')

par=cm('particle;')

cm('connectDynamic -em emitter1 particle1;')


cmd.connectAttr(selobj[1]+".outColor",emi[1]+".textureRate",f=True)

cm('setAttr "emitter1.enableTextureRate" 1;')

cm('setAttr "emitter1.emitFromDark" 1;')

cm("playButtonStepForward")


count=cmd.particle("particleShape1",q=True,ct=True)


for i in range(count):

pos=cmd.particle(par[1],q=True,at="position",order=i)


cmd.select(cl=True)

insobj= cmd.instance(random.choice(footage))[0]

cmd.select(insobj)

cmd.move(pos[0],pos[1],pos[2])

sc=random.random()*rangescale+minscale

cmd.setAttr(insobj+".sx",sc)

cmd.setAttr(insobj+".sy",sc)

cmd.setAttr(insobj+".sz",sc)

cmd.setAttr(insobj+".ry",random.random()*360)

cm("playButtonStart")

cmd.delete(emi[1],par[0])

####################################

,Maya安装,Maya技巧