Inlakechh
09-17-2007, 11:28 AM
Hi,
I just started with MEL scripting an have 2 little problems that I just find no solution for.
1.
My script takes all used shaders in the scene, creates new shaders with part of the old names and assigns the new shaders to the selections the old shaders have been on.
The problem is the ":" in previously imported shaders that cause the script to stop as when creating the new shaders it names them only with the part following the ":" and cannot assign them because the names (Variables) are different.
Easy said: In the beginning of the script I need Maya to search for ":" in the shaders name end erase it out. How can I do that?
2.
- I'm creating vector values with the Sphrand command to assign them to the R,G and B color attributes of a new generated shader.
Whenever a value is negative it causes the shader to look black. So I'm looking for a way to make the Sphrand Values always positive. Here's my idea:
vector $randomPos =sphrand (1);
if ($randomPos.x<0)
($randomPos.x) = ($randomPos.x) *-1
Maybe it's just Syntax error, but I dont know whats wrong. I'm trying to multiply the x value of the vector by -1 if its smaller than zero to get it positive. I'm going to repeat this for y and z when it's working.
I really appreciate any kind of help.
Thank you very much in advance.
I just started with MEL scripting an have 2 little problems that I just find no solution for.
1.
My script takes all used shaders in the scene, creates new shaders with part of the old names and assigns the new shaders to the selections the old shaders have been on.
The problem is the ":" in previously imported shaders that cause the script to stop as when creating the new shaders it names them only with the part following the ":" and cannot assign them because the names (Variables) are different.
Easy said: In the beginning of the script I need Maya to search for ":" in the shaders name end erase it out. How can I do that?
2.
- I'm creating vector values with the Sphrand command to assign them to the R,G and B color attributes of a new generated shader.
Whenever a value is negative it causes the shader to look black. So I'm looking for a way to make the Sphrand Values always positive. Here's my idea:
vector $randomPos =sphrand (1);
if ($randomPos.x<0)
($randomPos.x) = ($randomPos.x) *-1
Maybe it's just Syntax error, but I dont know whats wrong. I'm trying to multiply the x value of the vector by -1 if its smaller than zero to get it positive. I'm going to repeat this for y and z when it's working.
I really appreciate any kind of help.
Thank you very much in advance.
