<?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: Maya 2022 crashes when accessing MIntArray with negative indices in Maya Programming Forum</title>
    <link>https://forums.autodesk.com/t5/maya-programming-forum/maya-2022-crashes-when-accessing-mintarray-with-negative-indices/m-p/10197070#M4527</link>
    <description>&lt;P&gt;Thanks for reporting this issue. I can reproduce it with Maya 2022 in Python 3 mode, but not in Python 2 mode. I have logged a bug internally. We will fix it as soon as possible.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks again&lt;/P&gt;</description>
    <pubDate>Mon, 29 Mar 2021 20:02:18 GMT</pubDate>
    <dc:creator>WindXu</dc:creator>
    <dc:date>2021-03-29T20:02:18Z</dc:date>
    <item>
      <title>Maya 2022 crashes when accessing MIntArray with negative indices</title>
      <link>https://forums.autodesk.com/t5/maya-programming-forum/maya-2022-crashes-when-accessing-mintarray-with-negative-indices/m-p/10188166#M4525</link>
      <description>&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;I was testing the new Maya 2022 in its Python 3 mode and encountered some problem.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I realized that some scripts those worked in earlier version just crashes Maya 2022.&lt;/P&gt;&lt;P&gt;I did a quick research about that and extracted a simple code that can reproduce the error.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;from maya.api import OpenMaya

# create an OpenMaya.MIntArray object
temp_list = OpenMaya.MIntArray([0,1])
# accessing array's member using negative index crashes Maya 2022 with fatal error
print(temp_list[-1])&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm running Maya 2022.0 in Windows 10.&lt;/P&gt;&lt;P&gt;As a workaround, I'm using a little function to convert negative indices to positive ones.&lt;/P&gt;&lt;P&gt;Is it a problem that occurs just in my environment?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;Honda&lt;/P&gt;</description>
      <pubDate>Fri, 26 Mar 2021 03:13:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-programming-forum/maya-2022-crashes-when-accessing-mintarray-with-negative-indices/m-p/10188166#M4525</guid>
      <dc:creator>e_honda</dc:creator>
      <dc:date>2021-03-26T03:13:46Z</dc:date>
    </item>
    <item>
      <title>Re: Maya 2022 crashes when accessing MIntArray with negative indices</title>
      <link>https://forums.autodesk.com/t5/maya-programming-forum/maya-2022-crashes-when-accessing-mintarray-with-negative-indices/m-p/10188290#M4526</link>
      <description>&lt;P&gt;Just a quick update.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Other OpenMaya's array types also crashes Maya 2022.&lt;/P&gt;&lt;P&gt;It seems that launching Maya 2022 in Python 2 mode avoids the problem.&lt;/P&gt;&lt;P&gt;Maybe there is some problem in the Python 3 version of the Python API 2.0?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;from maya.api import OpenMaya

temp_list = OpenMaya.MFloatArray([0.0, 1.0])
print(temp_list[-1])&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;from maya.api import OpenMaya

temp_list = OpenMaya.MPointArray([OpenMaya.MPoint(), OpenMaya.MPoint()])
print(temp_list[-1])&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Mar 2021 04:41:55 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-programming-forum/maya-2022-crashes-when-accessing-mintarray-with-negative-indices/m-p/10188290#M4526</guid>
      <dc:creator>e_honda</dc:creator>
      <dc:date>2021-03-26T04:41:55Z</dc:date>
    </item>
    <item>
      <title>Re: Maya 2022 crashes when accessing MIntArray with negative indices</title>
      <link>https://forums.autodesk.com/t5/maya-programming-forum/maya-2022-crashes-when-accessing-mintarray-with-negative-indices/m-p/10197070#M4527</link>
      <description>&lt;P&gt;Thanks for reporting this issue. I can reproduce it with Maya 2022 in Python 3 mode, but not in Python 2 mode. I have logged a bug internally. We will fix it as soon as possible.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks again&lt;/P&gt;</description>
      <pubDate>Mon, 29 Mar 2021 20:02:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-programming-forum/maya-2022-crashes-when-accessing-mintarray-with-negative-indices/m-p/10197070#M4527</guid>
      <dc:creator>WindXu</dc:creator>
      <dc:date>2021-03-29T20:02:18Z</dc:date>
    </item>
    <item>
      <title>Re: Maya 2022 crashes when accessing MIntArray with negative indices</title>
      <link>https://forums.autodesk.com/t5/maya-programming-forum/maya-2022-crashes-when-accessing-mintarray-with-negative-indices/m-p/10197696#M4528</link>
      <description>&lt;P&gt;Hi WindXu,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope the bug would be fixed in future updates.&lt;/P&gt;&lt;P&gt;I checked that the OpenMaya.XXXXArray has other problem too, so I'll share here in this thread.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from maya.api import OpenMaya

temp_list = OpenMaya.MIntArray([0,1])

# should raise an IndexError, but returns the memory pointer's value?
print(temp_list[50])&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For now, I will use a simple function to avoid the error. Maybe not the best solution, but something like below:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from maya.api import OpenMaya


def get_item_at_index(omarray, index):
    """
        function made just to avoid problems when accessing Maya2022's OpenMaya.XXXXXXArray items.
    """
    len_array = len(omarray)
    index = len_array + index if index &amp;lt; 0 else index
    if index &amp;lt; 0:
        raise IndexError('list index out of range')
    elif index &amp;gt;= len_array:
        raise IndexError('list index out of range')
    return omarray[index]


temp_list = OpenMaya.MIntArray([0,1])
print(get_item_at_index(temp_list, -1)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your attention!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;Honda&lt;/P&gt;</description>
      <pubDate>Tue, 30 Mar 2021 02:10:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-programming-forum/maya-2022-crashes-when-accessing-mintarray-with-negative-indices/m-p/10197696#M4528</guid>
      <dc:creator>e_honda</dc:creator>
      <dc:date>2021-03-30T02:10:36Z</dc:date>
    </item>
    <item>
      <title>Re: Maya 2022 crashes when accessing MIntArray with negative indices</title>
      <link>https://forums.autodesk.com/t5/maya-programming-forum/maya-2022-crashes-when-accessing-mintarray-with-negative-indices/m-p/10198978#M4529</link>
      <description>&lt;P&gt;Yes, I noticed the issue with out of range index too when I did the test yesterday. I also logged it in the same bug.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 30 Mar 2021 13:28:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-programming-forum/maya-2022-crashes-when-accessing-mintarray-with-negative-indices/m-p/10198978#M4529</guid>
      <dc:creator>WindXu</dc:creator>
      <dc:date>2021-03-30T13:28:45Z</dc:date>
    </item>
    <item>
      <title>Re: Maya 2022 crashes when accessing MIntArray with negative indices</title>
      <link>https://forums.autodesk.com/t5/maya-programming-forum/maya-2022-crashes-when-accessing-mintarray-with-negative-indices/m-p/10206801#M4530</link>
      <description>&lt;P&gt;Thanks for this, I have been experiencing this as well!&lt;/P&gt;</description>
      <pubDate>Fri, 02 Apr 2021 08:11:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-programming-forum/maya-2022-crashes-when-accessing-mintarray-with-negative-indices/m-p/10206801#M4530</guid>
      <dc:creator>negow</dc:creator>
      <dc:date>2021-04-02T08:11:37Z</dc:date>
    </item>
  </channel>
</rss>

