why am I not seeing X number of duplicates when setAttr is added.

10 views
Skip to first unread message

jettam

unread,
Sep 15, 2017, 2:11:47 PM9/15/17
to Python Programming for Autodesk Maya
I am confused,  If I remove the part that says  mc.setAttr(dupObj+".translate",trX,trY,trZ,type="double3")    I will get 10 duplicates of my object. But if I add back in I only get 2 duplicates?   Could someone explain whats going on here. 





def makeStairs(number=10):
   
import random    
   
   
if number >= 1:
        masterGroup
= mc.group(empty=True, name='MasterGroup')
       
for x in range (10):
            step
= mc.polyCube(name='TED_'+str((x)+1))
            mc
.parent(step[0], masterGroup)
           
print 'making step_' + str((x)+1)
        stepsAreReady
= (1)
       
   
if stepsAreReady == (1) :
        trX
= random.uniform (-30,30)
        trY
= random.uniform (-30,30)
        trZ
= random.uniform (-30,30)
       
# duplicate and position steps #
       
for x in range (number):
            dupObj
= mc.duplicate(masterGroup)
            mc
.setAttr(dupObj+".translate",trX,trY,trZ,type="double3")
           
print "duplicate and position steps"
           
   
else:
       
print 'Dont make stairs'




makeStairs
(10)

jettam

unread,
Sep 15, 2017, 2:47:29 PM9/15/17
to Python Programming for Autodesk Maya
Solved it! I need to define the transform node[0] to the variable called dupObj.   dupObj = mc.duplicate(masterGroup)[0]   Once that was done setAttr knew what it had to operate on. 
Reply all
Reply to author
Forward
0 new messages