PDA

View Full Version : create rampNode with only one colorEntryList?


Redsand1080
06-03-2010, 01:34 AM
Hello, I'm trying to create a ramp node via MEL that only contains one colorEntry. Basically so I end up with a color swatch I can easily control. What I'm trying to do via MEL is first create the ramp via shadingNode, then delete the bottom two colorEntries after that. I am using the command removeMultiInstance. However, it will not let me create the texture and delete the colorEntries at the same time. Any idea why?

Here is the simple code that seems like it should work, but does not:

shadingNode -asTexture ramp;

select -r ramp1 ;
removeMultiInstance -b true ramp1.colorEntryList[0];

What's weird is that if I create the node first, THEN enter the removeMultiInstance command after the node as been created...it works. Does that make sense?

Any help would be awesome. :)

-Justin

jschieck
06-03-2010, 02:34 PM
that is kind of strange. running the command through evalDeferred works however: :buttrock:
$node = `shadingNode -asTexture ramp`;
evalDeferred("removeMultiInstance ($node + \".colorEntryList[1]\")");
evalDeferred("removeMultiInstance ($node + \".colorEntryList[2]\")");

Redsand1080
06-03-2010, 02:48 PM
that is kind of strange. running the command through evalDeferred works however: :buttrock:
$node = `shadingNode -asTexture ramp`;
evalDeferred("removeMultiInstance ($node + \".colorEntryList[1]\")");
evalDeferred("removeMultiInstance ($node + \".colorEntryList[2]\")");

Awesome! Thanks so much for that. I don't know quite enough about MEL yet...so I wasn't aware of evalDeferred. I'll do some research on that command. Great tip! :)

kojala
06-03-2010, 11:20 PM
{
string $node = `shadingNode -asTexture ramp`;
setAttr ($node+".colorEntryList[0].position") 0;
}

you dont have to delete any multiInstances from the ramp node.
just set some entrylists in it and maya wont create the default three ones
that it usually does.

Redsand1080
06-04-2010, 01:56 AM
you dont have to delete any multiInstances from the ramp node.
just set some entrylists in it and maya wont create the default three ones
that it usually does.

Man, that is so cool. That works like a charm. Thanks much for the tip!

I'm just kind of curios why maya does not create any color instances when you simply set the position of one of them?

Thanks again,

Justin

kojala
06-04-2010, 11:00 AM
It seems that there is a delayed command in maya, when it notices that a ramp node is created but its not set in anyway maya creates those three default entryLists.. prolly cos there is no desing for empty ramp node :P.

and with your first script you were wondering why the removeMultiInstance didnt work right after the node creation. answer is that you tried to remove them BEFORE the default ones were created and it worked with the evalDeferred which delayed your command as long as maya came to idle state.. and then it has already created those default entryLists :)

and by setting an entryList Im creating one. you can add them even after the node creation
just by setting color or position with a new index.

Redsand1080
06-04-2010, 01:34 PM
That makes perfect sense. Great explanation. Thanks much for the info...really good stuff to know! :)

CGTalk Moderation
06-04-2010, 01:34 PM
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.