<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Python script to append an array(list) in Maya Programming Forum</title>
    <link>https://forums.autodesk.com/t5/maya-programming-forum/python-script-to-append-an-array-list/m-p/9691894#M5554</link>
    <description>&lt;P&gt;I had declared transforms as an array then set it equal a single object basically getting rid of the array.&lt;/P&gt;&lt;LI-CODE lang="general"&gt;transforms = sel[len(sel)-1]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Where I should have done this (which works)&lt;/P&gt;&lt;LI-CODE lang="general"&gt;obj = sel[len(sel)-1]
transforms.insert(0, obj)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now if I could just get the new meshes to stat where they are and reset the transformation this simple script would be done&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Manually Modify&amp;gt;FreezeTransformations followed by Modify&amp;gt;ResetTransformations does exactly what I want&lt;/P&gt;&lt;P&gt;But the "ResetTransformations" doesn't even register in the script editor so I have no idea what comand to use in my script&lt;/P&gt;</description>
    <pubDate>Fri, 14 Aug 2020 15:42:42 GMT</pubDate>
    <dc:creator>thresholdengineering</dc:creator>
    <dc:date>2020-08-14T15:42:42Z</dc:date>
    <item>
      <title>Python script to append an array(list)</title>
      <link>https://forums.autodesk.com/t5/maya-programming-forum/python-script-to-append-an-array-list/m-p/9691501#M5551</link>
      <description>&lt;P&gt;I've been Googling for two days now and trying every suggestion, so far nothing is working.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've tried &lt;U&gt;&lt;EM&gt;&lt;STRONG&gt;append, add, insert&lt;/STRONG&gt;&lt;/EM&gt;&lt;/U&gt;, in every syntax I can think of and nothing works.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm using Python script because there are things (working) that I couldn't figure out with MEL&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I's starting out with a polymesh array with a length of 1 called 'transforms'&lt;/P&gt;&lt;P&gt;And a matrix array with 3 xforms called&amp;nbsp;matrices&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the current error&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;# Error: AttributeError: file &amp;lt;maya console&amp;gt; line 1: 'unicode' object has no attribute 'insert'&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And here is the code snippit&lt;/P&gt;&lt;LI-CODE lang="general"&gt;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)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Surely someone has figured this out?&lt;/P&gt;</description>
      <pubDate>Fri, 14 Aug 2020 12:52:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-programming-forum/python-script-to-append-an-array-list/m-p/9691501#M5551</guid>
      <dc:creator>thresholdengineering</dc:creator>
      <dc:date>2020-08-14T12:52:26Z</dc:date>
    </item>
    <item>
      <title>Re: Python script to append an array(list)</title>
      <link>https://forums.autodesk.com/t5/maya-programming-forum/python-script-to-append-an-array-list/m-p/9691650#M5552</link>
      <description>&lt;P&gt;It just occurred to me I may need another include statement?&lt;/P&gt;&lt;P&gt;I only have one for maya commands&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;import maya.cmds as cmds
sel = cmds.ls(sl = True)
matrices =[]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Aug 2020 13:50:02 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-programming-forum/python-script-to-append-an-array-list/m-p/9691650#M5552</guid>
      <dc:creator>thresholdengineering</dc:creator>
      <dc:date>2020-08-14T13:50:02Z</dc:date>
    </item>
    <item>
      <title>Re: Python script to append an array(list)</title>
      <link>https://forums.autodesk.com/t5/maya-programming-forum/python-script-to-append-an-array-list/m-p/9691791#M5553</link>
      <description>&lt;P&gt;That error means that your variable "transforms" is a string not an array/list. Check whichever line you are using to get that value.&lt;/P&gt;</description>
      <pubDate>Fri, 14 Aug 2020 14:55:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-programming-forum/python-script-to-append-an-array-list/m-p/9691791#M5553</guid>
      <dc:creator>jmreinhart</dc:creator>
      <dc:date>2020-08-14T14:55:18Z</dc:date>
    </item>
    <item>
      <title>Re: Python script to append an array(list)</title>
      <link>https://forums.autodesk.com/t5/maya-programming-forum/python-script-to-append-an-array-list/m-p/9691894#M5554</link>
      <description>&lt;P&gt;I had declared transforms as an array then set it equal a single object basically getting rid of the array.&lt;/P&gt;&lt;LI-CODE lang="general"&gt;transforms = sel[len(sel)-1]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Where I should have done this (which works)&lt;/P&gt;&lt;LI-CODE lang="general"&gt;obj = sel[len(sel)-1]
transforms.insert(0, obj)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now if I could just get the new meshes to stat where they are and reset the transformation this simple script would be done&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Manually Modify&amp;gt;FreezeTransformations followed by Modify&amp;gt;ResetTransformations does exactly what I want&lt;/P&gt;&lt;P&gt;But the "ResetTransformations" doesn't even register in the script editor so I have no idea what comand to use in my script&lt;/P&gt;</description>
      <pubDate>Fri, 14 Aug 2020 15:42:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-programming-forum/python-script-to-append-an-array-list/m-p/9691894#M5554</guid>
      <dc:creator>thresholdengineering</dc:creator>
      <dc:date>2020-08-14T15:42:42Z</dc:date>
    </item>
  </channel>
</rss>

