At a first glance, you do not need the BlockList at all because you so
not use the contents. You only use it to get a number of elements to
iterate over. You would get the same result if you simply do a:
for i in range(10):
cmds.duplicate()
....
Just in case you want to give the new objects a name, you can do a:
newName = "BLOCK{0}".format(i)
haggi
Am 19.08.2017 um 15:31 schrieb Johnathan Scoon:
Hey guys, I'm just playing around with simple for loops trying to get
my head around it. I wrote a script that creates a series of cubes and
places them a certain distance apart on the translate X axis.
from maya import cmds
BlockList = ("BLOCK", "BLOCK1", "BLOCK2", "BLOCK3", "BLOCK4", "BLOCK5")
cmds.polyCube(n="BLOCK")
for s in BlockList:
cmds.duplicate()
Name = cmds.ls (selection = True)
movevalue = 2
postvalue = cmds.getAttr(Name[0]+".tx")
shift = movevalue + postvalue
cmds.move(shift,0,0)
Now this works fine but what if I wanted to increase the number of
cubes to say 100 or more? It would be inefficient for me to have to
type all those names out into Blocklist. I know you can represent a
long list of numbers in a range, but I can't seem to find any
information on how to make a range what would include object names
with the numbers. Any help here is greatly appreciated!
--
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]
<mailto:[email protected]>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/python_inside_maya/6509bf81-3b30-4099-a1c8-de3358da91cd%40googlegroups.com
<https://groups.google.com/d/msgid/python_inside_maya/6509bf81-3b30-4099-a1c8-de3358da91cd%40googlegroups.com?utm_medium=email&utm_source=footer>.
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/python_inside_maya/e88860fb-7171-bcba-4685-8e20a3c9f15c%40haggi.de.
For more options, visit https://groups.google.com/d/optout.