import maya.cmds as cmds import MASH.api as mapi reload(mapi) import maya.mel as mel import flux.core as fx def runPreset(): cmds.select(clear=True) # create a new MASH network mashNetwork = mapi.Network() mashNetwork.createNetwork(name = "MASH_Explode", geometry="Instancer") # create the Drop Window fx.DropWindow.getDrop('Drag in an object to Explode:', callback=lambda data: smartPreset.send(data), title='MASH - Explode This Mesh', accepts=['mesh']) node = yield # split the dragged nodes into a list and only use the first object node = node.split('\n')[0] # freeze transforms cmds.makeIdentity(node, apply=True, t=True,s=True) bbox = cmds.exactWorldBoundingBox(node) scaleX = bbox[3] - bbox[0]; scaleY = bbox[4] - bbox[1]; scaleZ = bbox[5] - bbox[2]; pos = cmds.xform(node, q=True, ws=True, rp=True) # mesh distribute onto this node mashNetwork.meshDistribute(node) cmds.setAttr(mashNetwork.distribute + '.meshType', 4) cmds.setAttr(mashNetwork.distribute + '.floodMesh', 1) offsetNode = mashNetwork.addNode("MASH_Offset") cmds.setAttr(offsetNode.name + '.offsetType', 4) cmds.setAttr(offsetNode.name + '.enablePosition', 0) cmds.setAttr(offsetNode.name + '.scaleOffset0', 0) cmds.setAttr(offsetNode.name + '.scaleOffset1', 0) cmds.setAttr(offsetNode.name + '.scaleOffset2', 0) falloffShape = offsetNode.addFalloff() falloffTransform = cmds.listRelatives(falloffShape, p=True)[0] cmds.setAttr(falloffTransform+ '.translateX', pos[0]+scaleX*0.5) cmds.setAttr(falloffTransform+ '.translateY', pos[1]) cmds.setAttr(falloffTransform+ '.translateZ', pos[2]) explodeNode = mashNetwork.addNode("MASH_Explode") explodeNode.addExplodeMesh(node) directionLight = cmds.directionalLight(rotation=(180, -30, 90), intensity=3.0) ambientLight = cmds.ambientLight(intensity=0.3) cmds.setAttr("hardwareRenderingGlobals.ssaoEnable", 1) cmds.modelEditor("modelPanel4", edit=True, displayLights="all") cmds.modelEditor("modelPanel4", edit=True, shadows=True) yield # run the preset smartPreset = runPreset() smartPreset.next()