MEL scritp problem

MEL scritp problem

Anonymous
Not applicable
933 Views
4 Replies
Message 1 of 5

MEL scritp problem

Anonymous
Not applicable

Hi everyone,

I'm tring to make a script in MEL that allow me to disconnect the shading groups from an object selection... I saved two strings variables, one that containts the shapes list and another that contains the SG list of the selected objects... Then I used this command to disconnect the attributes: 

 

disconnectAttr ($geoShapes[$i] + ".instObjGroups[]") ($geoSG[$i] + ".dagSetMembers[]");

 

This line is placed into a for loop... When I run the script I get this error message:

 

// Error: Line 15.95: Unterminated string.

 

Someone could help to understand what's wrong with my script?

Thanks!

0 Likes
Accepted solutions (1)
934 Views
4 Replies
Replies (4)
Message 2 of 5

mspeer
Consultant
Consultant

Hi!

 

You can only use single attributes not arrays.

disconnectAttr (attribute1) (attribute2).

 

I can't check for other problems with only one single line of your script.

0 Likes
Message 3 of 5

Anonymous
Not applicable

Hi!

So, there are no way to disconnect every Dag Set Members of a shading group?

I share with you the entire script.

 

// Set Selection Variables //
string $geoSelection[] = `ls -sl`;
$selection = size($geoSelection);

// Start Loop //
for ($i=0; $i<$selection; ++$i)
{
select -cl;
select -r $geoSelection[$i];

// Set SG Variables //
string $geoShapes[] = `listRelatives $geoSelection[$i]`;
string $geoSG[] = `listConnections -type "shadingEngine" $geoShapes`;
print ($geoSG);

disconnectAttr ($geoShapes[$i] + ".instObjGroups") ($geoSG[$i] + ".dagSetMembers");

//ConvertSelectionToFaces;
//sets -e -forceElement initialShadingGroup;

//select -r $geoSelection[$i];
//sets -e -forceElement $geoSG{$i};
}

// End Loop //
select -cl;

 

I'm tring to do this script to solve a prbolem I have swhen I use the material override in render layer ... I get a warning message that say that material override doesn't work with per-face material ... To solve that problem I need to select all the faces of the geometry and apply the initialShadingGroup, then I have to reapply the original material ... When I have many geometries in the scene with this problme, I'd waste a lot of time doing it by hand and I'd like to do this automatically using this script...

0 Likes
Message 4 of 5

mspeer
Consultant
Consultant
Accepted solution

Hi!

 

"...I need to select all the faces of the geometry and apply the initialShadingGroup, then I have to reapply the original material..."

Sorry i don't understand what you want to do, or what this has to do with your script, but if you want to disconnect one specific connection you have to name the attributes correct and if you want to disconnect multiple connections, you have to use a loop for this.

0 Likes
Message 5 of 5

Anonymous
Not applicable

Hi,

Ok, I got it, Thank you for help!

0 Likes