import maya.cmds as cmds import MASH.api as mapi import maya.mel as mel import flux.core as fx def runPreset(): # new file cmds.file(force=True, new=True) # move the camera cmds.setAttr('persp.translateX', -38) cmds.setAttr('persp.translateY', 55) cmds.setAttr('persp.translateZ', -9) cmds.setAttr('persp.rotateX', -56) cmds.setAttr('persp.rotateY', -823) cmds.setAttr('persp.rotateZ', 0) # create a poly cube pcube = cmds.polySphere() # create a new MASH network mashNetwork = mapi.Network() mashNetwork.createNetwork(name = "SmartPreset", geometry="Instancer") cmds.setAttr(mashNetwork.distribute + '.pointCount', 1) # temporary reduction in point count # create the Drop Window fx.DropWindow.getDrop('Drag in an object to distribute on:', lambda data: smartPreset.send(data)) node = yield # split the dragged nodes into a list and only use the first object node = node.split('\n')[0] # mesh distribute onto this node mashNetwork.meshDistribute(node) cmds.setAttr(mashNetwork.distribute + '.areaBasedScatter', 1) # create a world node worldNode = mashNetwork.addNode("MASH_World") cmds.setAttr(worldNode.name + '.pointsPerCluster', 1) cmds.setAttr(worldNode.name + '.prevousPointsMode', 4) cmds.setAttr(worldNode.name + '.radius', 0.1) cmds.setAttr(worldNode.name + '.radiusVariance', 4) cmds.setAttr(worldNode.name + '.collisionIterations', 1) # set the point count cmds.setAttr(mashNetwork.distribute + '.pointCount', 3000) # roll it in glitter 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()