PDA

View Full Version : Two MEL challenges (attrControlGrp & list)


Mikademius
08-11-2005, 02:27 PM
case1:

I was introduced to the attrControlGrp in the MEL UI thread and I could actually need it for the script I'm currently producing.
Example:

- I have a lambert named "martin"
- I want to control martins transparency
- I want to use the attrControlGrp due to updating etc.
BUT
-I only want the slider. Not the name, colorPicker and the checkerBoard.

I did a quick test and got this result:
(code)

window -t "test";
columnLayout;
attrControlGrp -attribute "lambert1.transparency";
showWindow;
http://www.final3.com/images/temp/testAttrControlGrp.gif

Is there a way to manipulate this so I only get the slider? And if so. Is there a way to edit it so I get the correct widht. Apparently this command easily overrules the columnwidth command...

case2:

Say I want to delete "martin" and its shadingGrp. I can easily select them and delete them, but I want to delete the whole hierarchy and not just the shader and the shadingGrp.

I have looked into listRelatives, but I'm struggeling getting it to leave my mesh alone... I want to delete the whole shadingNetwork, but not the mesh attached to it.

http://www.final3.com/images/temp/hypershade.gif

This because I want to clean the unused nodes when I delete the shader and shadingGrp.
I want the user to be able to mess the whole thing up without getting stuck with alot of unused nodes when he/she hits the delete-button in the GUI.

And also, is there a list of classificationStrings I can use for the listNodeTypes documented somewhere?

Not that I think this will solve my challenge, but it'd be nice to know..
Thanks in advance...

Iconoklast
08-11-2005, 04:59 PM
if you use the command listConnections, you'll get a list of the connections for whatever you specified.. Then you can go ahead and delete those aswell.

drGonzo
08-12-2005, 06:57 AM
-I only want the slider. Not the name, colorPicker and the checkerBoard

Like so:

//==================================
if (`window -exists transpWin`)
deleteUI transpWin;
window transpWin;

columnLayout
-adjustableColumn true
mainCol
;

floatSlider
-min 0
-max 1
-value 0
-cc "changeTransp()"
transpSlider;

showWindow transpWin;
//==================================

global proc changeTransp()
{
float $floatValue = `floatSlider -q -v transpSlider`;
setAttr "lambert1.transparencyR" $floatValue;
setAttr "lambert1.transparencyG" $floatValue;
setAttr "lambert1.transparencyB" $floatValue;
}

drGonzo
08-12-2005, 07:13 AM
This because I want to clean the unused nodes when I delete the shader and shadingGrp.
If I understand correctly, this is already in Maya’s “Optimize scene” functionality > Remove unused rendering nodes. The proc called when you use this is :

scOpt_performOneCleanup( { "shaderOption" } );
The specifics of which you can find in : cleanUpScene.mel

Mikademius
08-12-2005, 08:01 AM
Iconoklast: I'll look into that at work rtoday. Thanks

dr. Gonzo Thx for your replies. I haven't tested your slidersollution, but I can't see you're using the attrControlGrp... ? That was the whole point. I have another slidersollution, but due to updating etc. I want to use the attrControlGrp.

And if I use the delete unused nodes command I risk deleting nodes the user wants to keep. What if he/she is in the middle of building a shader?

drGonzo
08-12-2005, 08:40 AM
but I can't see you're using the attrControlGrp... ? That was the whole point.
I don’t think you can omit the text and swatch in an attrControlGrp, since their sheer existence is exactly why this control was built. Nor can you set their -cw to 0.

Tell us why you want to leave them out, so I can see the purpose a bit clearer.


And if I use the delete unused nodes command I risk deleting nodes the user wants to keep. What if he/she is in the middle of building a shader?

Yes.

So, specifically, which shading nodes should be deleted?

Mikademius
08-12-2005, 09:48 AM
I don’t think you can omit the text and swatch in an attrControlGrp, since their sheer existence is exactly why this control was built. Nor can you set their -cw to 0. Tell us why you want to leave them out, so I can see the purpose a bit clearer.

I am building a shaderAssigner that lets you create lamberts for modeling. When you create one the script expands its window and adds controls where one of them is a slider for transparency. I have built this, but if I close the window and opens it again the sliders reset to value 0 and the transparency goes black on the shader of course. I built a checkproc that took the value of the transparency at startup and set the value of the slider to that value. That was ehen I came to think about the attrControlGrp. I was thinking that this command would let me avoid all that hassle...

Yes. So, specifically, which shading nodes should be deleted?

Imagine this:
-The script creates a blackHoleShader called "final3_blackHole" and a shadingGrp called "final3_blackHoleSG"
-If I want to delete this I can just select both of them and delete them.
-BUT what if the user decided to add a fractal bump or something stupid to the shader...
Then the deleteproc would leave the "bumbNodes" floating without the connection to the
blackHoleShader (because it is now gone). I tried listConnections and listRelatives etc. , but
my problem here is that I can't get it to select the whole shadingNetwork without
selectiong the mesh... If I could exclude the mesh somehow I could just go delete the selection.
I'd have the whole hierarchy deleted and the mesh still intact. Noone wants to delete their
mesh :)

Better explaination?

drGonzo
08-12-2005, 10:11 AM
I have built this, but if I close the window and opens it again the sliders reset to value 0 and the transparency goes black on the shader of course.
How very odd. Normally setting the -value flag should remedy that.
Can you send me your code, so I can have a look?

Mikademius
08-12-2005, 10:38 AM
Sorry, I don't want to release any of the code yet. My plan was to release the script this weekend.

What should I set the -v flag to then? It has to be the same as the user had it set to earlier before closing the window.

My slider is an intSlider that goes from -min 0 to -max 4

the -cc looks like this to change the transparencyValue 0.25 each time the user slides it:

proc changeCommandModelingLambertSecondIntSlider()
{ if (`objExists final3_ModelingLambertSecond`)
{ string $intSliderSecondParts;
int $queryIntSliderSecond = `intSlider -q -v intSliderSecondParts`;
setAttr final3_ModelingLambertSecond.transparency -type double3
(0.25*$queryIntSliderSecond) (0.25*$queryIntSliderSecond)
(0.25*$queryIntSliderSecond);
}
}

I was thinking that I could set the value of the slider at startup like this:

proc openingSliderMain()
{ float $transparencyMain[] = `getAttr final3_ModelingLambertMain.transparency`;
string $openingSliderMain = ($transparencyMain[0] * 0.25);
}

And maybe use $openingSliderMain as the -v. Using the whole proc doesn't work. I have to go
intSlider -e I guess... This is why I wanted to use the attrControlGrp so I could avoid all this...

zylphyr
08-12-2005, 12:35 PM
attrColorSliderGrp (without colorpicker, label, etc):

attrColorSliderGrp -l "" -cw 1 1 -cw 2 1 -cw 4 1 -sb 0 -at ($yourmaterial + ".transparency");


Remove all shading history including shading engine:

Select one or more materials (or other nodes...it deletes all history, and just the shading group in the future), run script.


$objects = `ls -sl`;

for ($object in $objects) {
if (`objExists $object`) {
$conns = `listHistory -f 0 $object`;
for ($conn in $conns) {
$type = `objectType $conn`;
if ($conn != $object) {
delete $conn;
}
}
}
if (`objExists $object`) {
$conns = `listHistory -f 1 $object`;
for ($conn in $conns) {
$type = `objectType $conn`;
if ($type == "shadingEngine") {
delete $conn;
}
}
}
delete $object;
}


Have a wonderful weekend! I'm heading out to see Sonic Youth :thumbsup:

Nå som dette problemt er løst er det på tide å fokusere litt på jobb igjen martin!

-z

Mikademius
08-12-2005, 01:06 PM
I love you :bounce:
Marcus?

onkelandy
08-12-2005, 03:03 PM
Thanks zylphyr!

I think that's a nice part of script to assign to a hotkey.

zylphyr
08-13-2005, 05:08 PM
>Marcus?

Hvem ellers? :D

Mikademius
08-13-2005, 10:17 PM
back to work then ;)

CGTalk Moderation
08-13-2005, 10:17 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.