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 //
//////////////////////////////////////////////////////////////////////////