Well, I have posted the same question on Polycount, but i figured out it might be more efficient to ask here with you guys !
Since a few hours (maybe more) I’m trying to learn and make a custom tool for Maya and my workflow.
I have already programmed in C++ in the past, so the Mel language is not so hard to understand for me.The hard part is to find the name of the various function inside maya, but even with that, I still have some problems:
Currently, I’m trying to applying a shader on an object selected in the scene.
When my script start, I create my shaders like this :
global string $shaderRetopo; //red retopo shader global string $shaderHighpoly; //blue high poly shader //setup shaders $shaderRetopo = `shadingNode -asShader -shared -name "sh_Retopo" phong`; setAttr($shaderRetopo+".transparency") -type double3 0.25 0.25 0.25; //must be done just after, or we need to reselect the shader before setAttr($shaderRetopo+".color") -type double3 0.5 0.0 0.0; $shaderHighpoly = `shadingNode -asShader -shared -name "sh_Highpoly" lambert`; setAttr($shaderHighpoly+".transparency") -type double3 0.25 0.25 0.25; setAttr($shaderHighpoly+".color") -type double3 0.4 0.5 0.8;
This is the easiest part for me.
Now, even if I try to understand as much I can, I can’t figure out how to select the last object in my current selection and apply the shader on it.I have tested this :
global proc froApplyShader(int $input) { global string $shaderRetopo; global string $shaderHighpoly; string $temp = ""; if($input == 1) //apply red shader { $temp = $shaderRetopo+"SG"; } else //apply blue shader { $temp = $shaderHighpoly+"SG"; } sets -e -forceElement $temp; }
But in maya a get an error, it looks like my variable are empty, even if the shaders are well created in the hypershade. ---- My second attemp is to change the current component mode on the last selected object, i have tried this :
global proc froChangeSelectMode(int $input) { string $select[] = `ls -sl`; int $mxSel = `size($select)`; //select -cl; //clear selection //change mode on the last selected object if($input == 4) doMenuComponentSelection($select[$mxSel], "meshComponents"); else if ($input == 3) doMenuComponentSelection($select[$mxSel], "facet"); else if ($input == 2) doMenuComponentSelection($select[$mxSel], "edge"); else if ($input == 1) doMenuComponentSelection($select[$mxSel], "vertex"); else select -r $select[$mxSel]; //classic select, object mode }
But it’s not working and I can’t get why.
Any help will be greatly rewarded with my eternal gratitude!
This is the first time that I made a script in Mel, so it would be logical if some basic concept are ousted ! I have only learned by looking into other scripts.