When a set node is selected, the default behaviour is for Maya to expand the selection to include all the items in that set.
If you want Maya to simply select the node and ignore its contents, use the -noExpand flag.
Let's say you want to preview the nodes that Maya will export when you perform an Export Selection.
1) open Maya 2013
2) create a couple of spheres
3) create a Blinn material and assign to the spheres
4) select one of the spheres
5) execute the following MEL commands:
//
string $export[] = `file -preview -exportSelected -constructionHistory 0 -expressions 1 -shader 1`;
select -replace $export;
//
You'll notice that now both spheres are selected.
This may lead you to think that both spheres would be exported, were you to remove the preview flag from the command, which is not what you want.
Query the selection you'll read the following:
//
pSphere1
pSphereShape1
materialInfo1
blinn1
lightLinker1
pSphereShape2
pSphere2
blinn1SG
//
We're assuming that this list reflects the results of the file -preview command. this is not the case. this list reflects the result of the select command.
Replace the select command with a print statement and you'll see a different result:
//
string $export[] = `file -preview -exportSelected -constructionHistory 0 -expressions 1 -shader 1`;
print $export;
pSphere1
pSphereShape1
materialInfo1
blinn1SG
blinn1
lightLinker1
//
This result is accurate.
So why did Maya select the second sphere in the previous example ? Well, one of the nodes in the list is a set node: blinnSG
When a set node is selected, Maya will by default expand the selection to include the contents of the set.
Selecting the nodes on the above list, Maya expands blinnSG and selects sphere1 and sphere2.
You can avoid this behaviour by adding the -noExpand flag to the select command, like this:
//
string $export[] = `file -preview -exportSelected -constructionHistory 0 -expressions 1 -shader 1`;
select -replace -noExpand $export;
ls -sl;
// Result: pSphere1 pSphereShape1 materialInfo1 blinn1SG blinn1 lightLinker1 //
//
To select a set node without expanding the selection to the contents of the set, use the -noExpand flag.
Owen
This report is very interesting. thanks you so much. I will apply it :)
Posted by: Coupon Mage Software | 03/11/2012 at 10:50 AM