Substance Painter
In this start to finish texturing project within Substance Painter we cover all the techniques you need to texture the robot character.
# 1 19-11-2011 , 08:34 PM
Jouri's Avatar
Lone Wolf Productions
Join Date: Nov 2011
Location: Belgium, Antwerp
Posts: 18

MEL script float problem??

Ok i didnt find a section specific for mel scripting so i think this is the best place to post it.
sorry if its in the wrong section.

I stumbled on the following error.

i declared a float in the beginning of my script then when i used it in a procedure to read uot the value of a floatslidergroup it was longer recognized as a float and produced an error for some reason when using the variable with sinh.

after checking it did hold the right data that i had put into it. and when changing the variable with the amount directly the error stopped. but thats not the solution as the variable is user input related.

now when i changed a line in the code (marked between a double //********* comment line) the code will work fine. but as you can see then i redefine that same float variable again as a float variable. because i already defined it at the beginning of the script.

so whats the point of declaring them all in the beginning? does this mean i will have to type everywhere "float" in front of my var's when i use them? doesnt make any sence right?

i isolated the error in a piece of code that still functions without having to upload the entire code.

the variable in question is : float $StellingMinimumAfstandStraal;

thanks in advance.

ps. i did try to make the variables global. it didnt make a difference.
pps : sorry for my not so perfect english ^^

Code:
string $TankStellingUI;

float $Ligger070;// = 0.732
float $Ligger100;// = 1.088
float $Ligger150;// = 1.572
float $Ligger200;// = 2.072
float $Ligger250;// = 2.572
float $Ligger300;// = 3.072

float $Diagonnal070;// = 2.095
float $Diagonaal100;// = 2.227
float $Diagonaal150;// = 2.478
float $Diagonaal200;// = 2.803
float $Diagonaal250;// = 3.173
float $Diagonaal300;// = 3.575

float $Angle070Minimum;
float $Angle100Minimum;
float $Angle150Minimum;
float $Angle200Minimum;
float $Angle250Minimum;
float $Angle300Minimum;

float $Angle070Maximum;
float $Angle100Maximum;
float $Angle150Maximum;
float $Angle200Maximum;
float $Angle250Maximum;
float $Angle300Maximum;

float $TankDiameter;
float $TankHoogte;
float $TankStraal;
float $TankOmtrek;
float $StellingMinimumAfstandStraal;
float $StellingMaximumAfstandStraal;
float $StellingBreedte;

//nakijken

//float $ScaffoldDistance;
//float $ScaffoldStraal;
//float $MoveScaffoldUp;
//float $NewTankOmtrek;
//float $NewTankDiameter;
//float $MoveTankUp;

// einde nakijken


////////////////////////////////////////////////////////////
//                    Procedures Start                    //
////////////////////////////////////////////////////////////

//////////////////////
// Updating Sliders //
//////////////////////

proc UpdateTankOmtrek(){
  $TankDiameter =  `floatSliderGrp -q -value TankDiameter`;
  floatSliderGrp -e -value (2*3.1415*($TankDiameter/2)) TankOmtrek;
}
proc UpdateTankDiameter(){
  $TankOmtrek =  `floatSliderGrp -q -value TankOmtrek`;
  floatSliderGrp -e -value (($TankOmtrek/(2*3.1415))*2) TankDiameter;
}

///////////////////
// Bouw Stelling //
///////////////////

proc BouwStelling(){
    
///////////////////////////////
// Lees Gebruikers Input uit //
///////////////////////////////

    $TankDiameter =  `floatSliderGrp -q -value TankDiameter`;
    $TankHoogte =  `floatSliderGrp -q -value TankHoogte`;
    $TankStraal =  $TankDiameter/2;
    $MoveTankUp = $TankHoogte / 2;
    $MoveScaffoldUp = $TankHoogte / 2;
//********************************************************************************
//********************************************************************************
    $StellingMinimumAfstandStraal =  `floatSliderGrp  -q -value MinimumAfstand`;
    //float $StellingMinimumAfstandStraal =  `floatSliderGrp  -q -value MinimumAfstand`;
//********************************************************************************
//********************************************************************************
    $StellingMinimumAfstandStraal = $StellingMinimumAfstandStraal + $TankStraal;
    $StellingMaximumAfstandStraal =  `floatSliderGrp -q -value MaximumAfstand`;
    $StellingMaximumAfstandStraal = $StellingMaximumAfstandStraal + $TankStraal;

    $Ligger070 = 0.732;    
    $Ligger100 = 1.088;
    $Ligger150 = 1.572;
    $Ligger200 = 2.072;
    $Ligger250 = 2.572;
    $Ligger300 = 3.072;

    $Diagonnal070 = 2.095;
    $Diagonaal100 = 2.227;
    $Diagonaal150 = 2.478;
    $Diagonaal200 = 2.803;
    $Diagonaal250 = 3.173;
    $Diagonaal300 = 3.575;

///////////////////////
// Tank Opbouw Start //
///////////////////////

    if(`objExists Tank`) 
        {  
            select -r Tank;
            doDelete;
        }  
    circle -name "Tank" -center 0 0 0 -normal 0 1 0 -sweep 360 -radius $TankStraal -degree 3 -useTolerance 0 -tolerance 0.01 -sections 8 -constructionHistory 1;    

//////////////////////
// Tank Opbouw Stop //
//////////////////////

///////////////////////////
// Stelling OpBouw Start //
///////////////////////////

    if(`objExists StellingMinimumAfstandBinnenRing`) 
        {  
            select -r StellingMinimumAfstandBinnenRing;
            doDelete;
        } 
    if(`objExists StellingMinimumAfstandBuitenRing`) 
        {  
            select -r StellingMinimumAfstandBuitenRing;
            doDelete;
        }  
    if(`objExists StellingMaximumAfstandBinnenRing`) 
        {  
            select -r StellingMaximumAfstandBinnenRing;
            doDelete;
        } 
    if(`objExists StellingMaximumAfstandBuitenRing`) 
        {  
            select -r StellingMaximumAfstandBuitenRing;
            doDelete;
        }
    $StellingBreedte = $Ligger100;
    circle -name "StellingMinimumAfstandBinnenRing" -center 0 0 0 -normal 0 1 0 -sweep 360 -radius $StellingMinimumAfstandStraal -degree 3 -useTolerance 0 -tolerance 0.01 -sections 8 -constructionHistory 1;
    //circle -name "StellingMinimumAfstandBuitenRing" -center 0 0 0 -normal 0 1 0 -sweep 360 -radius ($StellingMinimumAfstandStraal + $StellingBreedte) -degree 3 -useTolerance 0 -tolerance 0.01 -sections 8 -constructionHistory 1;
    circle -name "StellingMaximumAfstandBinnenRing" -center 0 0 0 -normal 0 1 0 -sweep 360 -radius $StellingMaximumAfstandStraal -degree 3 -useTolerance 0 -tolerance 0.01 -sections 8 -constructionHistory 1;
    //circle -name "StellingMaximumAfstandBuitenRing" -center 0 0 0 -normal 0 1 0 -sweep 360 -radius ($StellingMaximumAfstandStraal + $StellingBreedte) -degree 3 -useTolerance 0 -tolerance 0.01 -sections 8 -constructionHistory 1;
    


// new code start /////////////////////////////////////////////////////////////////////////////////////////:


$Angle250Minimum = 2*(sinh(($Ligger250/2)/($StellingMinimumAfstandStraal + $StellingBreedte)));
text -e -label ($Angle250Minimum+"     "+$Ligger250+"     "+$StellingMinimumAfstandStraal + "     "+$StellingBreedte) InfoLabel;

print("***************************************      " );
print($Angle250Minimum);
print("\n");


// new code end ///////////////////////////////////////////////////////////////////////////////////////////////////////////


//text -e -label $Angle250Minimum InfoLabel;

}



//////////////////////////
// Stelling OpBouw Stop //
//////////////////////////


////////////////////////////////////////////////////////////
//                     Procedures End                     //
////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////
//                     UI for the ScaffoldingWindow                     //
//////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////
//         check for window and delete if needed         //
///////////////////////////////////////////////////////////

if (`window -exists TankStellingUI`)
    {
        deleteUI -window TankStellingUI;
    }
    
///////////////////////////////////////////////
// Creating The TankStellingUI Window String //
///////////////////////////////////////////////

$TankStellingUI = `window -title "Scaffolding" -widthHeight 300 250 TankStellingUI`;

///////////////////////////////////////////
// Creating TankStellingUI Window Layout //
///////////////////////////////////////////

scrollLayout scrollLayout;
        columnLayout -adjustableColumn true;
            frameLayout  
                -labelVisible false
                -borderStyle "in";
                    
/////////////////////////////////////
// Creating TankStellingUI Sliders //
/////////////////////////////////////

columnLayout;
separator;
floatSliderGrp -field true
    -label "Tank Diameter"
    -minValue 0 -maxValue 50
    -step 0.01
    -value 10
    -changeCommand "UpdateTankOmtrek"
    -dragCommand "UpdateTankOmtrek"
    TankDiameter;
separator;
floatSliderGrp -field true
    -label "Tank Omtrek"
    -minValue 0 -maxValue 157    
    -step 0.01
    -value 31.42
    -changeCommand "UpdateTankDiameter"
    -dragCommand "UpdateTankDiameter"
    TankOmtrek;
separator;
floatSliderGrp -field true
    -label "Tank Hoogte"
    -minValue 0 -maxValue 50
    -step 0.01
    -value 12
    TankHoogte;
separator;
floatSliderGrp -field true
    -label "Minimum Afstand"
    -minValue 0 -maxValue 1
    -step 0.01
    -value 0.30
    MinimumAfstand;
separator;
floatSliderGrp -field true
    -label "Maximum Afstand"
    -minValue 0 -maxValue 1
    -step 0.01
    -value 0.40
    MaximumAfstand;
separator;
button -label "Bouw Stelling" -command "BouwStelling";
text -label "Onbekend" InfoLabel;


////////////////////////////////
// Show TankStellingUI Window //
////////////////////////////////

showWindow $TankStellingUI;

//////////////////////////////////////////////////////////////////////////
//                    End Of UI the ScaffoldingWindow                   //
//////////////////////////////////////////////////////////////////////////

# 2 20-11-2011 , 02:11 PM
Gen's Avatar
Super Moderator
Join Date: Dec 2006
Location: South FL
Posts: 3,522
It would be far more helpful if you also posted a screenie of the error.


- Genny
__________________
::|| My CG Blog ||::
::|| My Maya FAQ ||::
# 3 20-11-2011 , 02:23 PM
Jouri's Avatar
Lone Wolf Productions
Join Date: Nov 2011
Location: Belgium, Antwerp
Posts: 18

It would be far more helpful if you also posted a screenie of the error.

here you go.

as said before this only happens for one variable the one marked between a double //********* comment line changing the line with commented out one resolves the problem but doesnt make sense since it was already declared a float.

thanks.

Attached Thumbnails
# 4 20-11-2011 , 06:02 PM
Gen's Avatar
Super Moderator
Join Date: Dec 2006
Location: South FL
Posts: 3,522
The brackets were causing Maya to misread the number of arguments you were trying to pass.

$Angle250Minimum = 2*(sinh(($Ligger250/2)/($StellingMinimumAfstandStraal + $StellingBreedte)));

I deleted those two red brackets and the error was gone.


- Genny
__________________
::|| My CG Blog ||::
::|| My Maya FAQ ||::
# 5 20-11-2011 , 06:07 PM
Jouri's Avatar
Lone Wolf Productions
Join Date: Nov 2011
Location: Belgium, Antwerp
Posts: 18
Doh, stupid me lol.

Thanks, i guess was typing to fast to get it done.
looking at formulas for over 16h makes me hate brackets atm lol


There are no stupid questions, only stupid answers.


© All grammar errors are Copyrighted to me
# 6 20-11-2011 , 06:32 PM
Jouri's Avatar
Lone Wolf Productions
Join Date: Nov 2011
Location: Belgium, Antwerp
Posts: 18

The brackets were causing Maya to misread the number of arguments you were trying to pass.

$Angle250Minimum = 2*(sinh(($Ligger250/2)/($StellingMinimumAfstandStraal + $StellingBreedte)));

I deleted those two red brackets and the error was gone.


Wow too fast again. the calculation is incorrect now. user added image

this is how the formula should look like. (colord the brackets to see better wich ones go together)

$Angle250Minimum = 2*(sinh(($Ligger250/2)/($StellingMinimumAfstandStraal + $StellingBreedte)));

ok i can drop the green ones but i place them so i can see clearly what is all used for the sinh calculation.

i think i just have to live with the fact that i have to redeclare some variables as floats again where needed.

by changing
Code:
$StellingMinimumAfstandStraal =  `floatSliderGrp  -q -value MinimumAfstand`;
to
Code:
float $StellingMinimumAfstandStraal =  `floatSliderGrp  -q -value MinimumAfstand`;
while $StellingMinimumAfstandStraal is already decleared at the beginning of the script as a float.


anyway, thanks for you time.


There are no stupid questions, only stupid answers.


© All grammar errors are Copyrighted to me

Last edited by jouri; 20-11-2011 at 06:34 PM.
Posting Rules Forum Rules
You may not post new threads | You may not post replies | You may not post attachments | You may not edit your posts | BB code is On | Smilies are On | [IMG] code is On | HTML code is Off

Similar Threads