<?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: Pass array of arguments into command in Maya Programming Forum</title>
    <link>https://forums.autodesk.com/t5/maya-programming-forum/pass-array-of-arguments-into-command/m-p/10954418#M2904</link>
    <description>&lt;P&gt;Thanks Kahylan! This seems to work, though it is sort of the case I was hoping to avoid by passing a simpler argument. Seems like Mel isn't well set up for that unfortunately. I've had a lot of trouble with the polySeparate command being convoluted in general (as you mentioned, the object gets renamed, and there isn't a distinction in the output between the original and new meshes), and as a result I've reimplemented this in my script by duplicating the object entirely with a selection set, inverting the selection and deleting. It ends up seeming to be much simpler.&lt;/P&gt;</description>
    <pubDate>Wed, 16 Feb 2022 15:37:11 GMT</pubDate>
    <dc:creator>bphoenix22YC2</dc:creator>
    <dc:date>2022-02-16T15:37:11Z</dc:date>
    <item>
      <title>Pass array of arguments into command</title>
      <link>https://forums.autodesk.com/t5/maya-programming-forum/pass-array-of-arguments-into-command/m-p/10945960#M2901</link>
      <description>&lt;P&gt;Hey folks, I'm new to Mel here so please excuse the beginner question. I'm writing a simple script to run polySeparate on the user's actively selected shells (returned from polyEvaluate).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I'm stuck on is that I'm not able to get the -sss argument to accept a list, it seems to need an explicit index (or an explicit int more accurately). Looking at the output of the command executed manually, it adds a separate -sss flag for each selected shell, and each argument is a separate int. Since I want to run this command on all of $shells[], entering them separately obviously won't work. I haven't found a solution to this so far in the documentation, but I may be looking in the wrong way.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The following script will return an error, but if I replace $shells[] with $shells[0] it executes correctly, though not as I intend.&lt;/P&gt;&lt;LI-CODE lang="general"&gt;// Separate selected shells
{
int $shells[]; 
$shells = `polyEvaluate -as`;

string $a[];
$a = `polySeparate -sss $shells[] Bone_1_Start_Mesh`;
print($a);
}&lt;/LI-CODE&gt;&lt;P&gt;Thanks in advance for any help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;P.S. Bone_1_Start_Mesh is just a test object, but will be replaced with a variable.&lt;/P&gt;</description>
      <pubDate>Sat, 12 Feb 2022 00:37:54 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-programming-forum/pass-array-of-arguments-into-command/m-p/10945960#M2901</guid>
      <dc:creator>bphoenix22YC2</dc:creator>
      <dc:date>2022-02-12T00:37:54Z</dc:date>
    </item>
    <item>
      <title>Re: Pass array of arguments into command</title>
      <link>https://forums.autodesk.com/t5/maya-programming-forum/pass-array-of-arguments-into-command/m-p/10950371#M2902</link>
      <description>&lt;P&gt;Hi!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Flags in MEL can't change type, if they are designed to take a single value, they will only take a single value, if they are designed to take an array with 3 values they will only take an array with 3 values.&lt;/P&gt;&lt;P&gt;You can however, loop through your values like this:&lt;/P&gt;&lt;LI-CODE lang="general"&gt;{
int $Shells[]; 
$Shells = `polyEvaluate -as`;

string $a[];
string $obj = "pCube1";
for($s = 0; $s &amp;lt; `size $Shells`; $s++){
    print($s);  
    $a = `polySeparate -sss ($Shells[$s]-$s) $obj`; 
    $obj = $a[1];
    
}

}&lt;/LI-CODE&gt;&lt;P&gt;I had to introduce the Mesh to separate from as it's own variable (in my case "pCube1" in yours "Bone_1_Start_Mesh"), since this value changes when the mesh gets separated. Also I had to indicate the shell that was separated as ($Shells[number of loop] - number of loop) because with every polySeparate the Shell ID drops by 1, since there is one Shell less in the Object.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope this helps!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Feb 2022 01:17:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-programming-forum/pass-array-of-arguments-into-command/m-p/10950371#M2902</guid>
      <dc:creator>Kahylan</dc:creator>
      <dc:date>2022-02-15T01:17:19Z</dc:date>
    </item>
    <item>
      <title>Re: Pass array of arguments into command</title>
      <link>https://forums.autodesk.com/t5/maya-programming-forum/pass-array-of-arguments-into-command/m-p/10951367#M2903</link>
      <description>&lt;P&gt;The correct way of doing what you want here is to create a string with your command, then evoking it using eval:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;int $shells[] = polyEvaluate( "-as" );
string $sel[] = ls( "-sl" );

if( size($shells) &amp;amp;&amp;amp; size($sel) )
{
    string $obj = plugNode( $sel[0] );
    string $c = "polySeparate ";
    for( $i=0; $i&amp;lt;size($shells); $i++ )
    {$c+=" -sss "+$shells[$i]+" ";}
    $c+=$obj;
    evalEcho( $c );
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Feb 2022 12:31:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-programming-forum/pass-array-of-arguments-into-command/m-p/10951367#M2903</guid>
      <dc:creator>BurkhardRammner</dc:creator>
      <dc:date>2022-02-15T12:31:53Z</dc:date>
    </item>
    <item>
      <title>Re: Pass array of arguments into command</title>
      <link>https://forums.autodesk.com/t5/maya-programming-forum/pass-array-of-arguments-into-command/m-p/10954418#M2904</link>
      <description>&lt;P&gt;Thanks Kahylan! This seems to work, though it is sort of the case I was hoping to avoid by passing a simpler argument. Seems like Mel isn't well set up for that unfortunately. I've had a lot of trouble with the polySeparate command being convoluted in general (as you mentioned, the object gets renamed, and there isn't a distinction in the output between the original and new meshes), and as a result I've reimplemented this in my script by duplicating the object entirely with a selection set, inverting the selection and deleting. It ends up seeming to be much simpler.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Feb 2022 15:37:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-programming-forum/pass-array-of-arguments-into-command/m-p/10954418#M2904</guid>
      <dc:creator>bphoenix22YC2</dc:creator>
      <dc:date>2022-02-16T15:37:11Z</dc:date>
    </item>
    <item>
      <title>Re: Pass array of arguments into command</title>
      <link>https://forums.autodesk.com/t5/maya-programming-forum/pass-array-of-arguments-into-command/m-p/10954424#M2905</link>
      <description>&lt;P&gt;Thanks Burkhard! I wasn't aware of the echo command, but it seems helpful more generally as well, so I appreciate the tip.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Feb 2022 15:40:05 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-programming-forum/pass-array-of-arguments-into-command/m-p/10954424#M2905</guid>
      <dc:creator>bphoenix22YC2</dc:creator>
      <dc:date>2022-02-16T15:40:05Z</dc:date>
    </item>
  </channel>
</rss>

