How to select shading group in Mel?

How to select shading group in Mel?

malcolm_341
Collaborator Collaborator
574 Views
2 Replies
Message 1 of 3

How to select shading group in Mel?

malcolm_341
Collaborator
Collaborator

Hi, today I was surprised to find out I can't store a shading group in a variable and then use that variable to select it. I created a blinn shader and manually selected it's shading group node, then I ran in the script editor

string $temp[] = `ls -sl`;

select $temp;

And that doesn't select my shading group, is there something I'm missing here?

0 Likes
Accepted solutions (1)
575 Views
2 Replies
Replies (2)
Message 2 of 3

stephenkmann
Collaborator
Collaborator
Accepted solution

Shading Groups,(SG) are sets  

 When you select a set (using mel/python) , it selects the items in the set by default.

 ( this works this way for all sets)

 

but  ,if you want to select the set itself. you want to use the noExpand flag (-ne -noExpand )

so if you run 

string $sel[] = `ls -sl`;

select -ne $sel;

 

but be aware that mel will return a single object from ls -sl if you have a single object. but an array , if you have multiple objects

 

so if you select multiple shaderGroups., you want to index the array

 

string $sel[] = `ls -sl`;

select -ne $sel[0];
select -ne $sel[1];

 

hth

-=s

 

 

 

 

 

 

 

Message 3 of 3

malcolm_341
Collaborator
Collaborator

@stephenkmann   That did the trick, thanks! I didn't know about this set workflow.

0 Likes