I've been Googling for two days now and trying every suggestion, so far nothing is working.
I've tried append, add, insert, in every syntax I can think of and nothing works.
I'm using Python script because there are things (working) that I couldn't figure out with MEL
I's starting out with a polymesh array with a length of 1 called 'transforms'
And a matrix array with 3 xforms called matrices
This is the current error
# Error: AttributeError: file <maya console> line 1: 'unicode' object has no attribute 'insert'
And here is the code snippit
num = 1
print '-------------------------Starting Outer Loop\n'
for x in range(2):
print '-------------------------Starting Inner Loop\n'
print '===loop:' + str(x)
for matrix in matrices:
cmds.select(transforms)
cmds.duplicate()
cmds.xform( m = matrix )
cmds.makeIdentity( apply=True )
num += 1
print 'Number of objects = ' + str(num)
obj = cmds.ls(sl=True)
transforms.insert(num, obj)
print(matrix)
Surely someone has figured this out?
Solved! Go to Solution.
I've been Googling for two days now and trying every suggestion, so far nothing is working.
I've tried append, add, insert, in every syntax I can think of and nothing works.
I'm using Python script because there are things (working) that I couldn't figure out with MEL
I's starting out with a polymesh array with a length of 1 called 'transforms'
And a matrix array with 3 xforms called matrices
This is the current error
# Error: AttributeError: file <maya console> line 1: 'unicode' object has no attribute 'insert'
And here is the code snippit
num = 1
print '-------------------------Starting Outer Loop\n'
for x in range(2):
print '-------------------------Starting Inner Loop\n'
print '===loop:' + str(x)
for matrix in matrices:
cmds.select(transforms)
cmds.duplicate()
cmds.xform( m = matrix )
cmds.makeIdentity( apply=True )
num += 1
print 'Number of objects = ' + str(num)
obj = cmds.ls(sl=True)
transforms.insert(num, obj)
print(matrix)
Surely someone has figured this out?
Solved! Go to Solution.
Solved by jmreinhart. Go to Solution.
It just occurred to me I may need another include statement?
I only have one for maya commands
import maya.cmds as cmds
sel = cmds.ls(sl = True)
matrices =[]
It just occurred to me I may need another include statement?
I only have one for maya commands
import maya.cmds as cmds
sel = cmds.ls(sl = True)
matrices =[]
That error means that your variable "transforms" is a string not an array/list. Check whichever line you are using to get that value.
That error means that your variable "transforms" is a string not an array/list. Check whichever line you are using to get that value.
I had declared transforms as an array then set it equal a single object basically getting rid of the array.
transforms = sel[len(sel)-1]
Where I should have done this (which works)
obj = sel[len(sel)-1]
transforms.insert(0, obj)
Now if I could just get the new meshes to stat where they are and reset the transformation this simple script would be done
Manually Modify>FreezeTransformations followed by Modify>ResetTransformations does exactly what I want
But the "ResetTransformations" doesn't even register in the script editor so I have no idea what comand to use in my script
I had declared transforms as an array then set it equal a single object basically getting rid of the array.
transforms = sel[len(sel)-1]
Where I should have done this (which works)
obj = sel[len(sel)-1]
transforms.insert(0, obj)
Now if I could just get the new meshes to stat where they are and reset the transformation this simple script would be done
Manually Modify>FreezeTransformations followed by Modify>ResetTransformations does exactly what I want
But the "ResetTransformations" doesn't even register in the script editor so I have no idea what comand to use in my script
Can't find what you're looking for? Ask the community or share your knowledge.