Download latest devkit > copy devkit into dev kit folder in your Maya application folder
Modify your JSON
In Maya > Script Editor > Open ports by entering these code
import maya.cmds as cmds# Open new portscmds.commandPort(name=":7001", sourceType="mel", echoOutput=True)cmds.commandPort(name=":7002", sourceType="python", echoOutput=True)
To enable ports at startup create a file named userSetup.mel in the following folder:
#aimAtFirst.pyimport maya.cmds.as cmdsselectionList = cmds.ls (orderedSelection =True)iflen(selectionList)>=2:print'Selected itesms: %s'%(selectionList) targetName = SelecitonList[0] selectionList.remove(targetName)for objectName in SelectionList:print'Constraining %s towards %s'% (objectName, tartgetName) cmds.aimConstraint(targetName, objetName, aimVector = [ 0,1,0])else:print'Please select two or more objects.'
#randomInstances.pyimport maya.cmds as cmds import randomrandom.seed(1234)# selectionOrder result = cmd.ls(orderedSelection =True)print'result: %s'% (result) # replace string techniquetransformName = result[0]# create a group instanceGroupName = cmds.group(empty=True,name = transformName +'_instance_grp')#instancing with for loopfor i inrange(0,50): instanceResult = cmds.instance(transformName, name = transformName +' _instance#' cmds.parent(instanceRsult,instanceGroupName) x = random.uniform(10,10) y = random.uniform(0,20) z = random.uniform(-10,10) cmds.move(x,y,z, instanceResult)#randomize rotation xRot= random.uniform (0,360) yRot= random.uniform (0,360) zRot= random.uniform (0,360) cmds.rotation(xRot,yRot,zRot, instanceResult)# randomize factor scalingFactor = random.uniform(0.3, 1.5) cmds.scale(scalingFactor, scalingFactor,scalingFactor, instanceResult)# hide original cube & center pivitcmds.hide(transformName)cmds.xform(instanceGroupName, centerPiviots=True)
#randomCubes.pyimport maya.cmds as cmds import randomrandom.seed(1234)#commenting out multiple lines'''#fetch all objects who name starts with myCube + wildcardcubeList = cmds.ls('myCube*') #delete all cube items in cubeListif (len(cubeList)) > 0: cmds.delete(cubeList)'''result = cmds.polyCube(w=9,h=9,d=9, name ='myCube#')transformName = result[0]# create a group instanceGroupName = cmds.group(empty=True,name = transformName +'_instance_grp')#instancing with for loopfor i inrange(0,50): instanceResult = cmds.instance(transformName, name = transformName +' _instance#' cmds.parent(instanceRsult,instanceGroupName) x = random.uniform(10,10) y = random.uniform(0,20) z = random.uniform(-10,10) cmds.move(x,y,z, instanceResult)#randomize rotation xRot= random.uniform (0,360) yRot= random.uniform (0,360) zRot= random.uniform (0,360) cmds.rotation(xRot,yRot,zRot, instanceResult)# randomize factor scalingFactor = random.uniform(0.3, 1.5) cmds.scale(scalingFactor, scalingFactor,scalingFactor, instanceResult)# hide original cube & center pivitcmds.hide(transformName)cmds.xform(instanceGroupName, centerPiviots=True)