import maya.cmds as mc
import random
''' Build a spiral staircase and distribute it randomly X amount of times.'''
def makeRobot(numRobots=10):
def makeSpiralStairs () :
inc = str(x +1)
steps = {'name':'Step','slide':5,'rotations':10,'spacing':1,'stepDepth':2,'stepHeight':.75}
stepName=steps.get('name')
groupAllSteps = mc.group(name="Group"+stepName+"s"+inc, empty=True)
for x in range (numRobots):
stepObj = mc.polyCube(name=stepName+inc, w=5, h=steps.get('stepHeight'), d=steps.get('stepDepth'), ch=0)
stepGrp = mc.group(empty=True, name=stepName+inc)
mc.parent(stepObj, stepGrp)
mc.xform(stepGrp, ro=(0,(steps.get('rotations')*x),0))
mc.xform(stepObj[0], t=(steps.get('slide'),steps.get('stepHeight')*steps.get('spacing')*x,0))
mc.parent(stepObj, groupAllSteps)
mc.delete(stepGrp)
return groupAllSteps
for x in range(numRobots):
AAA = random.uniform(-20,20)
BBB = random.uniform(-20,20)
CCC = random.uniform(-20,20)
Grp2 = makeSpiralStairs()
mc.setAttr(Grp2[0] + ".translate", AAA,BBB,CCC, type="double3")
makeRobot(10)
--
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 python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/548d7be6-b3fc-4785-8a95-cd0df7ea3ae7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/548d7be6-b3fc-4785-8a95-cd0df7ea3ae7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
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 python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/abaa7765-b08b-4f7a-9eab-c544c28216ac%40googlegroups.com.
--
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 python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/21848d44-b30b-46b2-822f-f9d37427f567%40googlegroups.com.
The declaration of x is in the local scope of A.The variable x inside makespiralstairs has no declaration because x is not declared as global. Not a matter of order, it's a matter of scope. Passing x to the function will fix your issue. That or declare x as a global which I don't suggest. There's a lot of info online about local and global scope in Python and most other languages. It's important to utilize this so as not to accidentally override your values later
On Wed, Sep 13, 2017 at 11:26 AM jettam <justin...@gmail.com> wrote:
Inc = str(x+1) has been defined in the earlier "for x in" command has it not ?--
On Wednesday, September 13, 2017 at 10:40:10 AM UTC-7, damonshelton wrote:Inc = str(x+1)X is not defined before this lineX is defined when you execute the for x in range loop. You have to pass x into the makespiralstairs function to use it. X is a local variable
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 python_inside_maya+unsub...@googlegroups.com.