import MASH.api as mapi import maya.cmds as cmds #new file cmds.file(force=True, new=True) #move the camera cmds.setAttr('persp.translateX', 50) cmds.setAttr('persp.translateY', 35) cmds.setAttr('persp.translateZ', 50) #create a poly cube ptorus = cmds.polyTorus(r=20, sr=2, sh=60, sx=400) pcube = cmds.polyCube(w=0.4, h=1.0, d=0.4) #create a new MASH network mashNetwork = mapi.Network() mashNetwork.createNetwork(name="OffsetMapNetwork", geometry="Repro") shape = cmds.listRelatives(ptorus[0], s=True)[0] mashNetwork.meshDistribute(shape, 4) cmds.setAttr(mashNetwork.distribute + '.floodMesh', 1) #add a World node offsetNode = mashNetwork.addNode("MASH_Offset") cmds.setAttr(offsetNode.name + '.positionOffsetY', 5) cmds.setAttr(offsetNode.name + '.scaleOffset1', 5) cmds.setAttr(offsetNode.name + '.transformationSpace', 2) noiseShader = cmds.shadingNode('noise', asTexture=True) place2dTexture = cmds.shadingNode('place2dTexture', asUtility=True) cmds.connectAttr(place2dTexture+'.outUV', noiseShader+'.uv') cmds.connectAttr(noiseShader+'.outColor', offsetNode.name+'.mColour') cmds.setAttr(noiseShader + '.noiseType', 2) cmds.setKeyframe( noiseShader, attribute='time', t=['0sec'], v=0.0 ) cmds.setKeyframe( noiseShader, attribute='time', t=['5sec'], v=1.0 ) colorNode = mashNetwork.addNode("MASH_Color") cmds.setAttr(colorNode.name + '.color', 0.859,0.31,0.251 , type='double3') cmds.setAttr(colorNode.name + '.enableBackgroundColor', 1) cmds.setAttr(colorNode.name + '.backgroundColor', 0.239,0.663,0.576 , type='double3') colourFalloff = colorNode.addFalloff() cmds.connectAttr(shape+'.worldMesh[0]', colourFalloff+'.shapeIn') cmds.setAttr(colourFalloff + '.falloffShape', 6) cmds.setAttr(colourFalloff + '.searchRadius', 4) cmds.setAttr(colourFalloff + '.innerRadius', 0) #tell Maya to finish what it's doing before we continue cmds.flushIdleQueue() #playblast cmds.playbackOptions( animationEndTime='5sec') cmds.playblast(format="qt", viewer=True )