View Full Version : memory problems with duplicate

02 February 2008, 12:52 AM

In my script I need to duplicate a certain object more the 1000 times... maya naturally keeps crashing. I tried instancing instead, same problem...

Is there any technique better (or smarter :P) to do something like this??

Thank you a lot!

PS: here is the script, it is in python
def duplicateOnNormal():
# gets an obj named "element" and duplicates it align to each face's normal of the selected polygon
# get the poly name:
sel =
if (len(sel) != 1):
mm.eval('warning "You need to select an object!";')
obj = sel[0]
print "Selected object: " + obj

#get number of face on obj
nFaces = cmds.polyEvaluate(obj, vertex=1)

#for each face, get its normal, duplicate "element" and position on it, and normalConstraint "element" to the normal
newGroup =, name="elements")
while i <= nFaces:
f = obj+".vtx["+str(i)+"]"
#find face position
fPos = cmds.xform(f, q=1, t=1, ws=1)
#duplicate "element" and position it on the face's coordinates
newObj = cmds.instance("element") #cmds.duplicate("element")
cmds.xform(newObj[0], t=(fPos[0], fPos[1], fPos[2]), ws=1)
#normalConstraint it
cmds.normalConstraint( f, newObj[0], aimVector = (0,0,1))
# and group it
cmds.parent(newObj ,newGroup)


02 February 2008, 08:43 AM
try ways of iterating less on the duplicate command. So, instead of looping every face initially, try duplicating or extruding all faces, and then separating them, then looping through that result and performing your normal constraint-

02 February 2008, 10:11 AM
Well, duplicate was giving me too much trouble, to I went for creating another polygon on each place, with history turned of... goes smootlhy now...


CGTalk Moderation
02 February 2008, 10:11 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.