Some One Pls Help Me With My Script

Hi

Can some one out there can pls help me with this script of mine it is on the creation of stairs but right now it is giving me problem at the time of execution the problem is with the results which i am getting after the execution of the script.
i am posting you the script pls check it and tell me what is the problem.

with regards
sid's

following is the script for stairs creation:

global proc stairs(float $Angle , float $stairsLength , float $stairsHeight , float $stairsSteps , float $dis_base , float $dis_height)

{

// variables for steps,height,length,angle,etc.

float $stairsAngle = 45; // setting angle to default value of 45.

float $stairsHeight;//setting stairs height.

float $stairsLength;//setting stairs length.

float $stairsSteps;//setting stairs steps.

float $dis_base;//distance from the base.

float $dis_height;// distance from the height.

// creating a array variable for object to use as base of the stairs.

string $temp[];

// creating a second array variable for object to use as side of the stairs.

string $temps[];

//finding the angle of stairs according to the pythagoras theorem which is tan angle = opposite / adjacent

float $stairsAngle = atand ( $stairsHeight / $stairsLength);

//finding the length of stairs.

float $stairsLength = ( $stairsLength / $stairsSteps);

//finding the height of stairs.

float $stairsHeight = ( $stairsHeight / $stairsSteps);

//checking if stairs angle is more than or less than 45 degree.

if (($stairsAngle < 45) || ($stairsAngle > 45))
{
print("Stairs Angle is" + $stairsAngle + "\n");
}

$dis_base = ($stairsLength * $stairsSteps);

$dis_height = ($stairsHeight * $stairsSteps);

$temp = polyPlane -w ($stairsLength * 1.0) -h $stairsHeight -sx 1 -sy 1 -ax 0 1 0 -ch 0;
$temps = polyPlane -w ($stairsLength * 1.0) -h $stairsHeight -sx 1 -sy 1 -ax 0 1 0 -ch 0;
move -r ($stairsLength *0.5) ($stairsLength *-0.5) 0;

rotate 0 0 90;

int $i = 0;
for($i=0;$i<$stairsSteps;$i++)
{
$temp = `duplicate -rr`;
$temps = `duplicate -rr`;
move -r ($stairsLength * 0.5) ($stairsHeight * 0.1) 0;
$temp = $temps;
}

}
stairs(45,100,300,20,50,70);

Hi,

can you describe your problem a bit more? The code runs well but it produces only the vertical parts of your step system. What I didn't understand is the use of $stairsAngle. What is this supposed to do?

The horizontal part of the steps is one produced once here. So you have to make sure that you include that in your for-loop in a proper way as well. Looks as if you are not far away from your solution, I encourage you to keep trying...

The part

if (($stairsAngle < 45) || ($stairsAngle > 45))
{
print("Stairs Angle is" + $stairsAngle + "\n");
}

makes no sense to me either because the if-condition is always true. But I guess that was only for debugging purposes.

gentlesea

the stairs angle i added because i want to take that as a input from the user but i have also kept that as 45 degree by default but at the same time if the user want to change that value say he want to enter a lesser value than the 45 degree or he wants to enter bigger than the 45 degree than he can do that ,that's why i am having the $ stairs angle over there and the second thing which you have told me about the if statement so i want that if the user wants to change the default value and wants to enter something else then the default 45 value should be ommited and the new value should come in place of that,now my problem is that that i am not getting how should i get this properly and secondly how to get that horizontal steping in my script.

with regards
sid's

hai sid

allready this type scripts you can get it from highend3d

try this this

[b][url=http://www.highend3d.com/maya/downloads/mel_scripts/modeling/poly_tools/Davveys-Stair-Generator-4609.html]link 1[/url]

Link2
[/b]

ya i too know about these scripts and have already tried them but i want to develop something of my own and if you check my script you will find that there is a huge difference between their scripts and mine now my question to you is that can you please give me some time and can improve my script only because what i feel is that i am doing some very small mistake for which i am not getting the desired result and which i am unable to find so i need help from you all so kindly please check my script and tell me what it is........

regards
sid's

this will seem harsh but its just pure analytical of your code.

Well first of making a declaration

CODE
proc foo(float $foo){
float $foo;
}

does not make any sense whatsoever. thinking out from syntax point of view iTS something very close to:

CODE
{
  float $foo;
  $foo=20.0;
  print $foo; // prints 20.0
  {
    float $foo; //declares a new $foo for within the bracket (its called scope)
    $foo=10.0;
    print $foo; // prints 10.0
  }
  print $foo; // prints 20.0 not 10. as 10 was only available inside the last scope
}

Anyway don't do it, even if it worked right it would be superfluous and confusing for any reader so omit lines, as they are already declared:

CODE
float $stairsHeight;//setting stairs height.
float $stairsLength;//setting stairs length.
float $stairsSteps;//setting stairs steps.
float $dis_base;//distance from the base.
float $dis_height;// distance from the height.

secondly mels not strongly typed so lines:

CODE
string $temp[];
string $temps[];

are also just noise

the comparasion:
CODE
if (($stairsAngle < 45) || ($stairsAngle > 45))
{
print("Stairs Angle is" + $stairsAngle + "\n");
}

is not very good practice you should allow some tolerance as floats aren't that accurate. but if you must this if statement can be written. if ($stairsAngle!=45) wich is slightly faster and more readable.

following calculations make the definition parameters more or less redundant:
CODE
$dis_base = ($stairsLength * $stairsSteps);
$dis_height = ($stairsHeight * $stairsSteps);

So why have them hooked in the definition first place because they are never used anyway. Same applies to $angle, never used. (theres also no default values for assignments in mel, its a all or nothing thing)

your asked problem is here
CODE
$temp = duplicate -rr;
$temps = duplicate -rr;
move -r ($stairsLength * 0.5) ($stairsHeight * 0.1) 0;
$temp = $temps;

this is chaining issue

move -r ($stairsLength * 0.5) ($stairsHeight * 0.1) 0;

moves the selection uless you define a object behind

move -r ($stairsLength * 0.5) ($stairsHeight * 0.1) 0 $listOfObjs;

so best write the duplicate also in form duplicate -rr $listOfObjs. while your at it. Anyway sufficient to say you duplicate the last plane ONLY.

line:
CODE
$temp = $temps;

does not do anything meaningful. at all, during the entire code evaluation. Its just a extra assignment thats never used trough the course of the script.

Anyway theres not much I would salvage in this code. So start over form 0.