I am trying to write a function that will first make a spiral staircase, and then distribute the staircase randomly. I can get this script to generate only one spiral staircase, but it stops there. I can't get it to duplicate and distribute multiples of these. I have attached a logic path that I think the script should follow A,B,C,D (see attached image) Am I missing something ?
<https://lh3.googleusercontent.com/-KJqfSpoFRQE/WbsIvjelpmI/AAAAAAABOsw/CaX0WaGDW1sLSNXCD9I8ME1lURLocWUwgCLcBGAs/s1600/Capture.JPG> Here is the code: import maya.cmds as mc import random def distributeObjects(stairs=None): ''' This will make and randomly distribute a spiralStaircase ''' checkTest = 0 def makestairs(): ''' first make one spiral staircase ''' # make a dictionary steps = {'name':'Step','slide':5,'rotations':10,'spacing':1, 'stepDepth':2,'stepHeight':.75} stepName=steps.get('name') # make masterGroup groupAllSteps = mc.group(name="Group"+stepName+"s", empty=True) for x in range (0,100): #make stairs # make step stepObj = mc.polyCube(name=stepName+"#", w=5, h=steps.get( 'stepHeight'), d=steps.get('stepDepth'), ch=0) # make group stepGrp = mc.group(empty=True, name=stepName+'_Grp#') # parent stepObj to stepGrp mc.parent(stepObj, stepGrp) # rotate stepGrp mc.xform(stepGrp, ro=(0,(steps.get('rotations')*x),0)) # transform stepObj mc.xform(stepObj[0], t=(steps.get('slide'),steps.get( 'stepHeight')*steps.get('spacing')*x,0)) # parent stepObj to masterGroup mc.parent(stepObj, groupAllSteps) # delete stepGrp mc.delete(stepGrp) checkTest = 1 def distributeStairs(): ''' duplicate the pre-made spiral staircase X amount of times, and randomly distribute them ''' for i in range (stairs): trX = random.uniform(-30,30) trY = random.uniform(-30,30) trZ = random.uniform(-30,30) newGroup = mc.duplicate(GroupSteps,name=GroupSteps+i) mc.setAttr(newGroup+".translate",trX,trY,trZ,type='double3') if stairs >= 1: makestairs() if checkTest == 1: distributeStairs() distributeObjects(3) -- You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/ace92d3c-a34f-4a22-bc16-040f70e39715%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
