PDA

View Full Version : [MEL] disconnect shapeNode from its shadinggroup?


Leffler
04-15-2009, 01:21 PM
Hello!

I want to create a nurbs sphere that gets disconnected from itīs shader, so it turns up like a big solid dot in the maya UI. Its for rigging purposes

But I cant really figure out how to make the disconnection to work every time

This is the code so far

$nurbSph = `sphere -p 0 0 0 -ax 0 1 0 -ssw 0 -esw 360 -r .5 -d 3 -ut 0 -tol 0.01 -s 8 -nsp 4 -ch 0 -n "test"`;
select -r $nurbSph;
pickWalk -d down;
string $sel[] = `ls -sl`;
disconnectAttr ($sel[0] + ".instObjGroups[0]")("initialShadingGroup.dagSetMembers[0]");
setAttr($sel[0] + ".overrideEnabled")1;
setAttr($sel[0] + ".overrideColor")23;


What I want to make dynamic is this row
disconnectAttr ($sel[0] + ".instObjGroups[0]")("initialShadingGroup.dagSetMembers[0]");

I have tried to use listConnections and stuff like that but no luck. What can be used here?
What I want to do is basicly this:
# Get the shape node (which I have, by pickwalking down)
# Find out what connection it has to the shadingroup
# Break that connection

Help would be great, thanks in advance!

Otto

Robert Bateman
04-15-2009, 03:36 PM
$nurbSph = `sphere -p 0 0 0 -ax 0 1 0 -ssw 0 -esw 360 -r .5 -d 3 -ut 0 -tol 0.01 -s 8 -nsp 4 -ch 0 -n "test"`;
select -r $nurbSph;
pickWalk -d down;
sets -remove "initialShadingGroup";

Leffler
04-15-2009, 06:10 PM
So it was that easy, dammit :D Thanks Robert

Otto

strarup
04-15-2009, 11:57 PM
Hi,


well you don't need to pickwalk you can also do it like this... :)


proc removeDaShaderFromSphere()
{
$nurbSph = `sphere -p 0 0 0 -ax 0 1 0 -ssw 0 -esw 360 -r .5 -d 3 -ut 0 -tol 0.01`;
sets -rm "initialShadingGroup" $nurbSph;
}
removeDaShaderFromSphere;

kind regards

Strarup

Leffler
04-16-2009, 07:54 AM
Hehe great, one row of code less :D Thanks alot Starup

strarup
04-16-2009, 07:40 PM
Hi Otto,

and you're welcome... however you can also make it an oneliner... :D
eval("sets -rm \"initialShadingGroup\" `sphere -p 0 0 0 -ax 0 1 0 -ssw 0 -esw 360 -r .5 -d 3 -ut 0 -tol 0.01`");

one more row more less of code... :D

I had just forgot the power of the eval command yesterday to combine 2 commands into 1...
lol... and you don't even need to make a proc or variables for it in this case...

kind regards

Strarup

JamSession
04-16-2009, 08:17 PM
I would try to avoid using pickwalk where ever possible. It can give you very weird results!

$nurbSph = `sphere -p 0 0 0 -ax 0 1 0 -ssw 0 -esw 360 -r .5 -d 3 -ut 0 -tol 0.01 -s 8 -nsp 4 -ch 0 -n "test"`;
select -r $nurbSph;
pickWalk -d down;
sets -remove "initialShadingGroup";

Robert Bateman
04-17-2009, 09:09 AM
I would try to avoid using pickwalk where ever possible. It can give you very weird results!

Not in this case, or infact any case where you know exactly what you have selected (i.e. the node's have just been created).

Robert Bateman
04-17-2009, 09:12 AM
and you're welcome... however you can also make it an oneliner... :D

the eval is redundant. eval is only ever needed when you don't know the name of the procedure, or the arguments you are going to use, when you call it. In this case, it's not needed. (btw: it doesn't combine 2 commands together. It executes a text string which allows you to generate code on the fly)
sets -rm "initialShadingGroup" `sphere -p 0 0 0 -ax 0 1 0 -ssw 0 -esw 360 -r .5 -d 3 -ut 0 -tol 0.01`;

CGTalk Moderation
04-17-2009, 09:12 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.