<?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: I have a question about Maya API scripting in Maya Programming Forum</title>
    <link>https://forums.autodesk.com/t5/maya-programming-forum/i-have-a-question-about-maya-api-scripting/m-p/10912365#M3003</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I suppose you're talking about the Python's OpenMaya API and not the C++ API.&lt;BR /&gt;There are so many things that could be related to your question, so I'll point some of them.&lt;/P&gt;&lt;P&gt;&lt;A href="https://help.autodesk.com/view/MAYAUL/2022/ENU/?guid=Maya_SDK_cpp_ref_annotated_html" target="_blank"&gt;https://help.autodesk.com/view/MAYAUL/2022/ENU/?guid=Maya_SDK_cpp_ref_annotated_html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://help.autodesk.com/view/MAYAUL/2022/ENU/?guid=Maya_SDK_py_ref_namespace_open_maya_html" target="_blank"&gt;https://help.autodesk.com/view/MAYAUL/2022/ENU/?guid=Maya_SDK_py_ref_namespace_open_maya_html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;STRONG&gt;OpenMaya API&lt;/STRONG&gt;&lt;BR /&gt;Maya have two OpenMaya APIs. The "old" and the "new" one.&lt;BR /&gt;To use the old one, you must write the code in a more C-like way, allocating memory and passing pointers to functions.&lt;BR /&gt;The new one is more pythonic, but some functions are not yet implemented.&lt;BR /&gt;Both of them are fast, but it does not means that using them you'll get something faster than Python or MEL commands.&lt;BR /&gt;Sometimes MEL is the fastest option.&lt;BR /&gt;Everything depends on what you want to do and how.&lt;/P&gt;&lt;LI-CODE lang="general"&gt;# Maya Python cmds
from maya import cmds

# "old" API
from maya import OpenMaya
# "new" API
from maya.api import OpenMaya&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Faster&lt;/STRONG&gt;&lt;BR /&gt;To make a script faster, you have many things that you could do.&lt;BR /&gt;Some examples:&lt;BR /&gt;- Change language or API&lt;BR /&gt;- Change algorithm&lt;BR /&gt;- Find bottlenecks and try to avoid them&lt;BR /&gt;- Try to do threading or parallelization&lt;BR /&gt;- Minor optimizations (premature optimization is something to avoid)&lt;BR /&gt;- something else&lt;/P&gt;&lt;P&gt;Changing the programming language, the API and so on could have effect. It could make things really faster.&lt;BR /&gt;But it is not as simpler as just switching from one to another.&lt;BR /&gt;You must test every option and check the execution speed for your use case.&lt;BR /&gt;Sometimes the same script is the fastest for one type of geometry but very slow for others.&lt;BR /&gt;Make sure that what your choice is the best option for your task.(And unfortunately, it is not something easy)&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;That said:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;P&gt;1. Is there a way to use the API in conjunction with a mel script to run loops much faster for querying each UV shells position on a mesh for example, in mel this is too slow for my needs.&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;You can call a Python script from MEL and vice versa.&lt;/P&gt;&lt;P&gt;If it will be faster or not, just depends. You must do some profiling.&lt;/P&gt;&lt;P&gt;MEL calling python&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;A href="https://help.autodesk.com/cloudhelp/2022/ENU/Maya-Tech-Docs/Commands/python.html" target="_blank"&gt;https://help.autodesk.com/cloudhelp/2022/ENU/Maya-Tech-Docs/Commands/python.html&lt;/A&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;A href="https://help.autodesk.com/cloudhelp/2022/ENU/Maya-Tech-Docs/Commands/callPython.html" target="_blank" rel="noopener"&gt;https://help.autodesk.com/cloudhelp/2022/ENU/Maya-Tech-Docs/Commands/callPython.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Python calling mel&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;A href="https://download.autodesk.com/us/maya/2010help/CommandsPython/eval.html" target="_blank"&gt;https://download.autodesk.com/us/maya/2010help/CommandsPython/eval.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;P&gt;2. If the API does allow for fast loops, where should I go to start learning API scripting?&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;I'm sorry, it is not clear for me if you're looking for ways to learn how to use OpenMaya or Python itself (and the Python's maya.cmds).&lt;BR /&gt;In either way, you should do some google for github repositories and gists of simple Maya scripts.&lt;BR /&gt;Maybe just checking Maya's docs could be really helpful.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Anyway, somebody else should complement what I wrote.&lt;/P&gt;&lt;P&gt;Or have a totally different point of view.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope it helps&lt;/P&gt;</description>
    <pubDate>Fri, 28 Jan 2022 03:11:21 GMT</pubDate>
    <dc:creator>e_honda</dc:creator>
    <dc:date>2022-01-28T03:11:21Z</dc:date>
    <item>
      <title>I have a question about Maya API scripting</title>
      <link>https://forums.autodesk.com/t5/maya-programming-forum/i-have-a-question-about-maya-api-scripting/m-p/10911985#M3002</link>
      <description>&lt;P&gt;Hi, I don't know anything about the API, I was told it's much faster than mel script for running loops so I have two questions:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. Is there a way to use the API in conjunction with a mel script to run loops much faster for querying each UV shells position on a mesh for example, in mel this is too slow for my needs.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. If the API does allow for fast loops, where should I go to start learning API scripting?&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jan 2022 22:06:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-programming-forum/i-have-a-question-about-maya-api-scripting/m-p/10911985#M3002</guid>
      <dc:creator>malcolm_341</dc:creator>
      <dc:date>2022-01-27T22:06:24Z</dc:date>
    </item>
    <item>
      <title>Re: I have a question about Maya API scripting</title>
      <link>https://forums.autodesk.com/t5/maya-programming-forum/i-have-a-question-about-maya-api-scripting/m-p/10912365#M3003</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I suppose you're talking about the Python's OpenMaya API and not the C++ API.&lt;BR /&gt;There are so many things that could be related to your question, so I'll point some of them.&lt;/P&gt;&lt;P&gt;&lt;A href="https://help.autodesk.com/view/MAYAUL/2022/ENU/?guid=Maya_SDK_cpp_ref_annotated_html" target="_blank"&gt;https://help.autodesk.com/view/MAYAUL/2022/ENU/?guid=Maya_SDK_cpp_ref_annotated_html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://help.autodesk.com/view/MAYAUL/2022/ENU/?guid=Maya_SDK_py_ref_namespace_open_maya_html" target="_blank"&gt;https://help.autodesk.com/view/MAYAUL/2022/ENU/?guid=Maya_SDK_py_ref_namespace_open_maya_html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;STRONG&gt;OpenMaya API&lt;/STRONG&gt;&lt;BR /&gt;Maya have two OpenMaya APIs. The "old" and the "new" one.&lt;BR /&gt;To use the old one, you must write the code in a more C-like way, allocating memory and passing pointers to functions.&lt;BR /&gt;The new one is more pythonic, but some functions are not yet implemented.&lt;BR /&gt;Both of them are fast, but it does not means that using them you'll get something faster than Python or MEL commands.&lt;BR /&gt;Sometimes MEL is the fastest option.&lt;BR /&gt;Everything depends on what you want to do and how.&lt;/P&gt;&lt;LI-CODE lang="general"&gt;# Maya Python cmds
from maya import cmds

# "old" API
from maya import OpenMaya
# "new" API
from maya.api import OpenMaya&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Faster&lt;/STRONG&gt;&lt;BR /&gt;To make a script faster, you have many things that you could do.&lt;BR /&gt;Some examples:&lt;BR /&gt;- Change language or API&lt;BR /&gt;- Change algorithm&lt;BR /&gt;- Find bottlenecks and try to avoid them&lt;BR /&gt;- Try to do threading or parallelization&lt;BR /&gt;- Minor optimizations (premature optimization is something to avoid)&lt;BR /&gt;- something else&lt;/P&gt;&lt;P&gt;Changing the programming language, the API and so on could have effect. It could make things really faster.&lt;BR /&gt;But it is not as simpler as just switching from one to another.&lt;BR /&gt;You must test every option and check the execution speed for your use case.&lt;BR /&gt;Sometimes the same script is the fastest for one type of geometry but very slow for others.&lt;BR /&gt;Make sure that what your choice is the best option for your task.(And unfortunately, it is not something easy)&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;That said:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;P&gt;1. Is there a way to use the API in conjunction with a mel script to run loops much faster for querying each UV shells position on a mesh for example, in mel this is too slow for my needs.&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;You can call a Python script from MEL and vice versa.&lt;/P&gt;&lt;P&gt;If it will be faster or not, just depends. You must do some profiling.&lt;/P&gt;&lt;P&gt;MEL calling python&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;A href="https://help.autodesk.com/cloudhelp/2022/ENU/Maya-Tech-Docs/Commands/python.html" target="_blank"&gt;https://help.autodesk.com/cloudhelp/2022/ENU/Maya-Tech-Docs/Commands/python.html&lt;/A&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;A href="https://help.autodesk.com/cloudhelp/2022/ENU/Maya-Tech-Docs/Commands/callPython.html" target="_blank" rel="noopener"&gt;https://help.autodesk.com/cloudhelp/2022/ENU/Maya-Tech-Docs/Commands/callPython.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Python calling mel&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;A href="https://download.autodesk.com/us/maya/2010help/CommandsPython/eval.html" target="_blank"&gt;https://download.autodesk.com/us/maya/2010help/CommandsPython/eval.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;P&gt;2. If the API does allow for fast loops, where should I go to start learning API scripting?&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;I'm sorry, it is not clear for me if you're looking for ways to learn how to use OpenMaya or Python itself (and the Python's maya.cmds).&lt;BR /&gt;In either way, you should do some google for github repositories and gists of simple Maya scripts.&lt;BR /&gt;Maybe just checking Maya's docs could be really helpful.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Anyway, somebody else should complement what I wrote.&lt;/P&gt;&lt;P&gt;Or have a totally different point of view.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope it helps&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jan 2022 03:11:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-programming-forum/i-have-a-question-about-maya-api-scripting/m-p/10912365#M3003</guid>
      <dc:creator>e_honda</dc:creator>
      <dc:date>2022-01-28T03:11:21Z</dc:date>
    </item>
    <item>
      <title>Re: I have a question about Maya API scripting</title>
      <link>https://forums.autodesk.com/t5/maya-programming-forum/i-have-a-question-about-maya-api-scripting/m-p/10914176#M3004</link>
      <description>&lt;P&gt;Thanks for your help, it's the OpenMaya API I guess that I'm looking for because Python is not supported in Maya LT.&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jan 2022 18:53:54 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-programming-forum/i-have-a-question-about-maya-api-scripting/m-p/10914176#M3004</guid>
      <dc:creator>malcolm_341</dc:creator>
      <dc:date>2022-01-28T18:53:54Z</dc:date>
    </item>
  </channel>
</rss>

