You need to increment your names. I would also suggest you use the string 
format command, its much easier to read and handle variables

name = "What ever you want to call it"
instanceName="{0}s_{1}_inst".format(name, i)

https://docs.python.org/2/library/stdtypes.html#str.format

On Wednesday, 30 August 2017 14:14:52 UTC+10, jettam wrote:
>
> I am trying to get all 50 instances to go into the instanceGroup. But for 
> some I am only getting one instance object in to the group. Could someone 
> help me with this. Why is my script not nesting all 50 instance into the 
> group?
>
> import maya.cmds as cmds
> import random
> random.seed (1234)
>
> result = cmds.ls(orderedSelection=True)
>
> instanceGroup = cmds.group(empty=True, name='Grp_Inst_%s' % (result[0]))
>
> for i in range(0,50):
>
>     instObject = cmds.instance(result, name='%s_inst' % (result[0]))
>     *cmds.parent(instObject, instanceGroup)*
>     x=random.uniform(-10,10)
>     y=random.uniform(0,20)
>     z=random.uniform(-10,10)
>     cmds.move(x,y,z,instObject)
>     
>     rotX=random.uniform(0,360)
>     rotY=random.uniform(0,360)
>     rotZ=random.uniform(0,360)
>     cmds.rotate(rotX,rotY,rotX,instObject)
>     
>     uniformScale=random.uniform(.4,1.4)
>     uniformScale=random.uniform(.4,1.4)
>     uniformScale=random.uniform(.4,1.4)
>     cmds.scale(uniformScale,uniformScale,uniformScale,instObject)
>     
>     
>
>
>
>     
>     
>     
>     
>     
>
>

-- 
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/9568ecf3-1f84-42a3-a3f0-88f45a18a3f0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to