maya python 创建窗口_如何在Maya中通过Python创建进度窗口?

frommayaimportcmdsdefcheckProgressEscape():# check if dialog has been cancelledcancelled=cmds.progressWindow(query=True,isCancelled=True)ifcancelled:cmds.progressWindow(endProgress=1)returncancelleddefgetAllParticlesDictionary(shape):cmds.progressWindow(title='Fetch Particle Data',progress=0,status='Fetched: 0%',isInterruptable=True)ptcsDict={}minFrames=int(cmds.playbackOptions(q=True,min=True))maxFrames=int(cmds.playbackOptions(q=True,max=True))nFrames=float(maxFrames-minFrames)# better use the actual range, since you queried the playback optionsforcurrentFrameinrange(minFrames,maxFrames):ifcheckProgressEscape():returnamount=100.0/nFrames*(currentFrame-minFrames+1)cmds.progressWindow(edit=True,progress=amount,status='Fetched: %d%%'%amount)# cmds.pause(seconds=.001)cmds.currentTime(currentFrame,update=True,edit=True)forparticleCountinxrange(cmds.particle(shape,q=True,ct=True)):particleId=int(cmds.particle(shape,q=True,order=particleCount,at='id')[0])# better check the key exists first, then add your logicifparticleIdnotinptcsDict.keys():ptcsDict[particleId]={}ptcsDict[particleId][currentFrame]=cmds.particle(shape,q=True,order=particleCount,at='position')cmds.progressWindow(endProgress=1)returnptcsDictdefcurvesFromParticle(ptcsDict):cmds.progressWindow(title='Build Curves',progress=0,status='Building Curves: 0%',isInterruptable=True)# this section had to be de-indentedemptyFolder=cmds.group(em=True,n="Curves")ptcCount=len(ptcsDict)fori,(curveParticleId,data)inenumerate(ptcsDict.iteritems()):ifcheckProgressEscape():returnsortedKeyFrameList=sorted(data.keys())pointList=[]forkeyFrameinsortedKeyFrameList:pointList.append(ptcsDict[curveParticleId][keyFrame])curveObj=cmds.curve(name="pCurve%d"%curveParticleId,p=pointList)locators=cmds.spaceLocator(name="locator%d"%curveParticleId)cmds.pathAnimation(locators,stu=sortedKeyFrameList[0],etu=sortedKeyFrameList[-1],c=curveObj)# place all objects in Group called Curvescmds.parent(curveObj,emptyFolder)cmds.delete(locators)amount=100/ptcCount*float(i)cmds.progressWindow(edit=True,progress=amount,status='Building Curves: %d%%'%amount)cmds.progressWindow(endProgress=1)ptcs=cmds.ls(typ='nParticle')forshapeinptcs:cmds.setAttr("%s.lifespanMode"%(shape,),2)cmds.setAttr("%s.maxCount"%(shape,),100)cmds.setAttr("%s.lifespanRandom"%(shape,),3)ptcDict=getAllParticlesDictionary(shape)ifnotptcDict:print'data was not be fetched for %s; skipped'%(shape,)continuecurvesFromParticle(ptcDict)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值