Strange results

 Thread Tools Search this Thread Display Modes
 02 February 2013 #1 Dancindavid Explorer portfolio David Tonkin Toorak, AU   Join Date: Sep 2012 Posts: 11 Strange results This is my first script doing more then saying hello world.... I'm making a basic UI that creates different types of stair cases - Its all going well except for one particular calculation... It's probably easiest if you just paste it into the script editor and run it, but I'll attempt to explain the problem. The user can input how many steps, their dimensions, as well as the number or landings (the flat bit between 2 flights of stairs). My procedure runs a loop for the number of stairs, creating and moving each one into position as it goes. It also figures out how many steps between each landing and creates it when ever the loop gets to that number..... The problem - when ever the step depth is greater then 1, the placement of the landings on the Z axis goes funny.... for example, if the depth is 2 or 3 all the landings are 1 unit off, if the depth is 4 or 5 the landings are 2 units off, 6 and 7 are 3 off and so on and so forth.... If it was a consistent difference it would be easy to fix but its got me banging my head against the wall.... Please help!! `````` // This procedure gets the values of the sliders then passes those values to the respective create procedure proc getSliderValue(int \$stairChoice) { if (\$stairChoice == 1) { int \$numStep = `intSliderGrp -q -v numberStepStdSlider`; int \$widthStep = `intSliderGrp -q -v widthStepStdSlider`; int \$heightStep = `intSliderGrp -q -v heightStepStdSlider`; int \$depthStep = `intSliderGrp -q -v depthStepStdSlider`; int \$landingsStep = `intSliderGrp -q -v landingsStdSlider`; int \$stairAttributes[] = {\$numStep, \$widthStep, \$heightStep, \$depthStep, \$landingsStep}; createStandard(\$stairAttributes); } if (\$stairChoice == 2){ int \$numStep = `intSliderGrp -q -v numberStepSprlSlider`; int \$widthStep = `intSliderGrp -q -v widthStepSprlSlider`; int \$heightStep = `intSliderGrp -q -v heightStepSprlSlider`; int \$depthStep = `intSliderGrp -q -v depthStepSprlSlider`; int \$rotationsStep = `intSliderGrp -q -v roationsStepSprlSlider`; int \$stairAttributes[0] = {\$numStep, \$widthStep, \$heightStep, \$depthStep, \$rotationsStep}; createSpiral(\$stairAttributes); } if (\$stairChoice == 3){ int \$numStep = `intSliderGrp -q -v numberStepGrndSlider`; int \$widthStep = `intSliderGrp -q -v widthStepGrndSlider`; int \$heightStep = `intSliderGrp -q -v heightStepGrndSlider`; int \$depthStep = `intSliderGrp -q -v depthStepGrndSlider`; int \$stairAttributes[] = {\$numStep, \$widthStep, \$heightStep, \$depthStep}; createGrand(\$stairAttributes); } } // dragCommandProcedure copies the current value to the target slider global proc dragWidthCommandProcedure(){ int \$widthValue = `intSliderGrp -q -v widthStepSprlSlider`; int \$depthValue = `intSliderGrp -q -v depthStepSprlSlider`; if (\$widthValue < (\$depthValue *2)) { intSliderGrp -e -v (\$depthValue-1) depthStepSprlSlider; } } // dragCommandProcedure copies the current value to the target slider global proc dragDepthCommandProcedure(){ int \$widthValue = `intSliderGrp -q -v widthStepSprlSlider`; int \$depthValue = `intSliderGrp -q -v depthStepSprlSlider`; if (\$depthValue >= (\$widthValue / 2)) { intSliderGrp -e -v (\$depthValue * 2) widthStepSprlSlider; } } // -- Create Standard Staircase Procedure proc createStandard(int \$stairAttributesPassed[]) { // put the user inputs to variables int \$numberOfSteps = \$stairAttributesPassed[0]; int \$widthOfSteps = \$stairAttributesPassed[1]; int \$heightOfSteps = \$stairAttributesPassed[2]; int \$depthOfSteps = \$stairAttributesPassed[3]; int \$numberOfLandings = \$stairAttributesPassed[4]; //////////////////// int \$stepsPerLanding = \$numberOfSteps / \$numberOfLandings; // calculate the number of steps between each landing int \$landingDepth = \$depthOfSteps *5; // <---- The Landing will be this many times longer then each step int \$half = \$landingDepth *.5; // calculate the "half depth" of the landing int \$stepCount = 1; // assorted counters int \$landingMove = 0;// assorted counters int \$landingCount = 0;// assorted counters int \$actualCount = 0;// assorted counters print ("number of steps between each landing: " + \$stepsPerLanding + "\n"); for (\$i=0; \$i<\$numberOfSteps; \$i++) // continue making and moving steps { \$actualCount ++; polyCube -width \$widthOfSteps -height \$heightOfSteps -depth \$depthOfSteps; DeleteHistory; string \$step[] = `ls -sl`; rename \$step[0] ("step"+(\$i+1)); if (\$landingCount > 0) \$landingMove = \$landingCount*5; move 0 ((\$i+\$landingCount) * \$heightOfSteps) ((\$depthOfSteps*\$i)+\$landingMove*\$depthOfSteps); print ("step " + \$stepCount +" created \n"); if (\$stepCount == \$stepsPerLanding) //if its time for a landing then make one here { polyCube -width \$widthOfSteps -height \$heightOfSteps -depth \$landingDepth; string \$landing[] = `ls -sl`; rename \$landing[0] ("landing" + (\$landingCount +1)); \$landingCount ++; move 0 //x (\$i * \$heightOfSteps + (\$heightOfSteps * \$landingCount))//y (((\$actualCount+\$landingMove)*\$depthOfSteps)+\$half ); //z This is the problem Im having.... print ("landing " + \$landingCount + " created \n"); \$stepCount = 0; // this must be reset so we know how many steps have been created between each landing } \$stepCount ++; } } // -- Create Spiral Staircase Procedure proc createSpiral(int \$stairAttributesPassed[]) { // put the user inputs to variables int \$numberOfSteps = \$stairAttributesPassed[0]; int \$widthOfSteps = \$stairAttributesPassed[1]; int \$heightOfSteps = \$stairAttributesPassed[2]; int \$depthOfSteps = \$stairAttributesPassed[3]; int \$rotations = \$stairAttributesPassed[4]; //////////////////// string \$name; int \$zero = 2; for (\$i=0; \$i<\$numberOfSteps; \$i++) { polyCube -width \$widthOfSteps -height \$heightOfSteps -depth 1; //create step string \$step[] = `ls -sl`; rename \$step[0] ("step"+(\$i+1)); string \$stepName = ("step"+(\$i+1)); float \$targetVert0[] = `pointPosition -w (\$stepName+".vtx[0]")`; float \$targetVert2[] = `pointPosition -w (\$stepName+".vtx[2]")`; float \$targetVert5[] = `pointPosition -w (\$stepName+".vtx[5]")`; // this is just for the pivot reference move -r \$targetVert5[0] 0 \$targetVert5[2] (\$stepName + ".rotatePivot"); //move the pivot point print ("\npivot point moved to : " + \$targetVert5[0] + " " + 0 + " " + \$targetVert5[2]+"\n"); move -a -ws \$targetVert0[0] \$targetVert0[1] (\$targetVert0[2]+\$depthOfSteps) (\$stepName + ".vtx[0]"); move -a -ws \$targetVert2[0] \$targetVert2[1] (\$targetVert2[2]+\$depthOfSteps) (\$stepName + ".vtx[2]"); print ("vert 0 moved to: " + \$targetVert0[0] + " " + \$targetVert0[1] + " " + (\$targetVert0[2]+\$depthOfSteps)+"\n"); print ("vert 2 moved to: " + \$targetVert2[0] + " " + \$targetVert2[1] + " " + (\$targetVert2[2]+\$depthOfSteps)+"\n"); move -a -ws 0 (\$heightOfSteps*\$i) 0 \$stepName; rotate -a -ws 0 (((\$rotations/\$numberOfSteps)*\$i)+\$widthOfSteps+(\$depthOfSteps*2 )) 0 \$stepName; /*if (\$i > 0) { float \$oldVert0[] = `pointPosition -w ("step"+(\$zero-1) +".vtx[0]")`; float \$oldVert2[] = `pointPosition -w ("step"+(\$zero-1) +".vtx[2]")`; print ("\nOld vert position is from: " + "step" +(\$zero-1)); \$zero++; move -r -ws (\$oldVert0[0]) 0 (\$oldVert0[2]) (\$stepName + ".vtx[4]"); move -r -ws (\$oldVert2[0]) 0 (\$oldVert2[2]) (\$stepName + ".vtx[6]"); print ("\nvert 4 moved to: " + \$oldVert0[0] + " " + 0 + " " + \$oldVert0[2]+"\n"); print ("vert 6 moved to: " + \$oldVert2[0] + " " + 0 + " " + \$oldVert2[2]+"\n"); }*/ DeleteHistory; print (\$stepName + " finished \n"); select \$stepName; } float \$polePos[] = `pointPosition -w ("step1.vtx[5]")`; polyCylinder -h (\$numberOfSteps*\$heightOfSteps)-r 1; move \$polePos[0] (((\$numberOfSteps*\$heightOfSteps)*.5)-(\$heightOfSteps*.5)) \$polePos[2]; } // -- Create Grand Staircase Procedure proc createGrand(int \$stairAttributesPassed[]) { polyCube -width \$stairAttributesPassed[1] -height \$stairAttributesPassed[3] ; } // Set the name and title of the window string \$winName = "stairMaster"; string \$winTitle = "Stair Master"; // Check is Window exists and delete if necessary if (`window -exists \$winName`) deleteUI \$winName; //create the window window -rtf on -title \$winTitle \$winName; columnLayout; text -label "\n Standard Stair Case \n"; intSliderGrp -label "Number of Steps" -field true -value 10 -minValue 1 -maxValue 100 numberStepStdSlider; intSliderGrp -label "Width of Steps" -field true -value 5 -minValue 1 widthStepStdSlider; intSliderGrp -label "Height of Steps" -field true -value 1 -minValue 1 heightStepStdSlider; intSliderGrp -label "Depth of Steps" -field true -value 1 -minValue 1 depthStepStdSlider; intSliderGrp -label "Number of landings" -field true -value 2 -minValue 1 landingsStdSlider; button -label "Create it" -command "getSliderValue(1)" standardBtn; // -------------------------------------------------------------- separator -width 400 -style "double" - horizontal 1; // -------------------------------------------------------------- text -label "\n Spiral Stair Case \n"; intSliderGrp -label "Number of Steps" -field true -value 10 -minValue 1 -maxValue 100 numberStepSprlSlider; intSliderGrp -label "Width of Steps" -field true -value 5 -minValue 2 -dc "dragWidthCommandProcedure()" widthStepSprlSlider; intSliderGrp -label "Height of Steps" -field true -value 1 -minValue 1 heightStepSprlSlider; intSliderGrp -label "Depth of Steps" -field true -value 1 -minValue 1 -maxValue 50 -dc "dragDepthCommandProcedure()" depthStepSprlSlider; intSliderGrp -label "Degrees of Rotations" -field true -value 90 -minValue 1 -maxValue 720 roationsStepSprlSlider; button -label "Create it" -command "getSliderValue(2)" sprialBtn; // -------------------------------------------------------------- separator -width 400 -style "double" - horizontal 1; // -------------------------------------------------------------- text -label "\n Grand Stair Case \n"; intSliderGrp -label "Number of Steps" -field true -value 1 -minValue 1 -maxValue 100 numberStepGrndSlider; intSliderGrp -label "Width of Steps" -field true -value 5 -minValue 1 widthStepGrndSlider; intSliderGrp -label "Height of Steps" -field true -value 1 -minValue 1 heightStepGrndSlider; intSliderGrp -label "Depth of Steps" -field true -value 1 -minValue 1 depthStepGrndSlider; button -label "Create it" -command "getSliderValue(3)" grandBtn; showWindow \$winName; //lock the window size window -e -sizeable false -rtf on \$winName; `````` share quote
 02 February 2013 #2 depakeen Veteran portfolio Jerome Pourcel Paris, FR   Join Date: Sep 2011 Posts: 45 Hi, I just had a look at your script and, before solving your specific problem, you've got several mistakes. Obviously, you made your script whithin the script editor in Maya. This is a bad idea: scriptEditor is fine to do some quick tests and to debug, but you have to write and test your final code in another soft and call it whithin maya. Everything in scriptEditor (or scripts written in shelf) is in global, even variables, even if you didn't specify it. So if you write: ``````proc MyProc () { string \$myVariable; }`````` Maya reads it as: ``````global proc MyProc () { global string \$myVariable; }`````` Not a big deal if you just test a function or a process, but you can miss some big issues. For instance, in your code, you call local procedures that are written later. There's no problem in the scriptEditor, as everything is in global. But it won't work when you save your script and call it. When Maya parses the code, it doesn't recognize the procedure (Maya didn't see the procedure already), the script won't work. So you must write local procedures before calling them (the same way you declare variables before using them). Also, this is a better idea to have your GUI in a global proc. Your code will be nicer (very important) and you may want, for some reason, to have an input later on. share quote
 02 February 2013 #3 Dancindavid Explorer portfolio David Tonkin Toorak, AU   Join Date: Sep 2012 Posts: 11 Thanks for your feeback. You are indeed right it was written in script editor. I have fixed up all my errors, and now will take your advice and clean up my code a bit. Thanks again for the constructive feed back share quote
 02 February 2013 #4 zeroeffect Code Junkie portfolio Chris Zurbrigg Software Developer Independent Canada   Join Date: Jul 2005 Posts: 221 Focusing on the problem at hand, I see a couple of things that are contributing to this behaviour. The fact that it works occasionally is due to truncation. Focusing just on the createStandard procedure, you are making \$half an int and then dividing it by 2. If you divide 3 by 2, the expected result is 1.5. But, with an int the decimal value is dropped, leaving you with a value of 1. So, whenever your landing depth is odd, it is being rounded down to the nearest integer. It's a simple idea, but a critical thing to remember for languages such as MEL or C++. ``float \$half = \$landingDepth * 0.5; // calculate the "half depth" of the landing`` The second is the positioning of the landing. The origin of the first step is at 0, so only half of it should be used to calculate the final position of the landing. By subtracting half the depth of the the first step, the landing is positioned correctly: ``````move 0 //x (\$i * \$heightOfSteps + (\$heightOfSteps * \$landingCount))//y (((\$actualCount+\$landingMove)*\$depthOfSteps) + \$half - (0.5 * \$depthOfSteps)); //z`````` This is a quick fix, but it should help point you in the right direction. ChrisZ Last edited by zeroeffect : 02 February 2013 at 02:34 PM. share quote
 02 February 2013 #5 depakeen Veteran portfolio Jerome Pourcel Paris, FR   Join Date: Sep 2011 Posts: 45 i tried to rearrange your script, solving the problem in the createStandard proc. I removed all your comments so that you can see clearly mines. ``````proc createGrand(int \$stairAttributesPassed[]) { polyCube -width \$stairAttributesPassed[1] -height \$stairAttributesPassed[3] ; } //I didn't change anything here (almost) proc createSpiral(int \$stairAttributesPassed[]) { int \$numberOfSteps = \$stairAttributesPassed[0]; int \$widthOfSteps = \$stairAttributesPassed[1]; int \$heightOfSteps = \$stairAttributesPassed[2]; int \$depthOfSteps = \$stairAttributesPassed[3]; int \$rotations = \$stairAttributesPassed[5];//index 4 is now 5 string \$name; int \$zero = 2; for (\$i=0; \$i<\$numberOfSteps; \$i++) { polyCube -width \$widthOfSteps -height \$heightOfSteps -depth 1; string \$step[] = `ls -sl`; rename \$step[0] ("step"+(\$i+1)); string \$stepName = ("step"+(\$i+1)); float \$targetVert0[] = `pointPosition -w (\$stepName+".vtx[0]")`; float \$targetVert2[] = `pointPosition -w (\$stepName+".vtx[2]")`; float \$targetVert5[] = `pointPosition -w (\$stepName+".vtx[5]")`; move -r \$targetVert5[0] 0 \$targetVert5[2] (\$stepName + ".rotatePivot"); print ("\npivot point moved to : " + \$targetVert5[0] + " " + 0 + " " + \$targetVert5[2]+"\n"); move -a -ws \$targetVert0[0] \$targetVert0[1] (\$targetVert0[2]+\$depthOfSteps) (\$stepName + ".vtx[0]"); move -a -ws \$targetVert2[0] \$targetVert2[1] (\$targetVert2[2]+\$depthOfSteps) (\$stepName + ".vtx[2]"); print ("vert 0 moved to: " + \$targetVert0[0] + " " + \$targetVert0[1] + " " + (\$targetVert0[2]+\$depthOfSteps)+"\n"); print ("vert 2 moved to: " + \$targetVert2[0] + " " + \$targetVert2[1] + " " + (\$targetVert2[2]+\$depthOfSteps)+"\n"); move -a -ws 0 (\$heightOfSteps*\$i) 0 \$stepName; rotate -a -ws 0 (((\$rotations/\$numberOfSteps)*\$i)+\$widthOfSteps+(\$depthOfSteps*2 )) 0 \$stepName; DeleteHistory; print (\$stepName + " finished \n"); select \$stepName; } float \$polePos[] = `pointPosition -w ("step1.vtx[5]")`; polyCylinder -h (\$numberOfSteps*\$heightOfSteps)-r 1; move \$polePos[0] (((\$numberOfSteps*\$heightOfSteps)*.5)-(\$heightOfSteps*.5)) \$polePos[2]; } proc createStandard(int \$stairAttributesPassed[]) { int \$numberOfSteps = \$stairAttributesPassed[0]; int \$widthOfSteps = \$stairAttributesPassed[1]; int \$heightOfSteps = \$stairAttributesPassed[2]; int \$depthOfSteps = \$stairAttributesPassed[3]; int \$numberOfLandings = \$stairAttributesPassed[4]; int \$stepsPerLanding; if (\$numberOfLandings != 0) //only needed if there're some landings and avoids division by zero \$stepsPerLanding = \$numberOfSteps / \$numberOfLandings; int \$landingDepth = \$depthOfSteps *5; float \$half = \$landingDepth /2; //must be a float (3/2 == 1.5 and not 1) float \$stepHalf = \$depthOfSteps/2; //we need to offset the landings because the first step is created at the center of the world int \$landingCount = \$stepsPerLanding ; int \$actualLandingCount = 1; //for naming purpose int \$actualStepCount = 1;//for naming purpose float \$depth = 0.0; //needed to calculate the position of the next step in Z float \$heightCount = 0.0; //needed to calculate the position of the next step in Y //Creates a group to make things easier once the stairs are created. string \$stairsName = `textFieldGrp -q -text nameStdTFG`; string \$grp = `group -em -n \$stairsName`; for (\$i=0; \$i < (\$numberOfSteps + \$numberOfLandings); \$i++) { string \$stepName = ("step" + \$actualStepCount); string \$landingName = ("landing" + \$actualLandingCount); if (\$i == \$landingCount && \$numberOfLandings != 0) //must add this second condition as we can make no landing { polyCube -w \$widthOfSteps -h \$heightOfSteps -depth \$landingDepth -n \$landingName; xform -ws -t 0 \$heightCount (\$depth + \$half - \$stepHalf);//offsets the landing whith all the added steps' depth, minus half a step makeIdentity -a 1 -t 1 \$landingName;//resets translation delete -ch \$landingName;//deletes construction history parent \$landingName \$grp;//moves the step into the group \$depth += \$landingDepth; \$heightCount += \$heightOfSteps;//adds the step's height at each iteration \$landingCount += (\$stepsPerLanding+1); \$actualLandingCount ++; } else { polyCube -w \$widthOfSteps -h \$heightOfSteps -depth \$depthOfSteps -n \$stepName; xform -ws -t 0 \$heightCount \$depth; makeIdentity -a 1 -t 1 \$stepName;//resets translation delete -ch \$stepName;//deletes construction history parent \$stepName \$grp;//moves the step into the group \$depth += \$depthOfSteps; \$heightCount += \$heightOfSteps;//adds the step's height at each iteration \$actualStepCount ++; } } } //be careful with global declarations labels. To avoid conflicts with other scripts, don't be afraid to //have long names global proc getSliderValue(int \$stairChoice) { //don't write several times the same thing int \$numStep = `intSliderGrp -q -v numberStepStdSlider`; int \$widthStep = `intSliderGrp -q -v widthStepStdSlider`; int \$heightStep = `intSliderGrp -q -v heightStepStdSlider`; int \$depthStep = `intSliderGrp -q -v depthStepStdSlider`; int \$landingsStep = `intSliderGrp -q -v landingsStdSlider`; int \$rotationsStep = `intSliderGrp -q -v roationsStepSprlSlider`; int \$stairAttributes[] = {\$numStep, \$widthStep, \$heightStep, \$depthStep, \$landingsStep, \$rotationsStep}; if (1 == \$stairChoice) //better to write it his way, to avoid this very common mistake: if (\$stairChoice = 1) //maya will return an error if you write: if(1 = \$stairChoise), //but will assign the value to the variable if you write: if (\$stairChoise = 1) //so you will have unattended results, and it can be very hard to find out where the mistake comes from createStandard(\$stairAttributes); if (2 == \$stairChoice) createSpiral(\$stairAttributes); if (3 == \$stairChoice) createGrand(\$stairAttributes); } global proc dragWidthCommandProcedure() { int \$widthValue = `intSliderGrp -q -v widthStepSprlSlider`; int \$depthValue = `intSliderGrp -q -v depthStepSprlSlider`; if (\$widthValue < (\$depthValue *2)) intSliderGrp -e -v (\$depthValue-1) depthStepSprlSlider; } global proc dragDepthCommandProcedure() { int \$widthValue = `intSliderGrp -q -v widthStepSprlSlider`; int \$depthValue = `intSliderGrp -q -v depthStepSprlSlider`; if (\$depthValue >= (\$widthValue / 2)) intSliderGrp -e -v (\$depthValue * 2) widthStepSprlSlider; } global proc Stairs_O_Matic () { string \$winName = "stairMaster"; string \$winTitle = "Stair Master"; if (`window -exists \$winName`) deleteUI \$winName; window -rtf on -title \$winTitle \$winName; columnLayout; text -label "\n Standard Stair Case \n"; intSliderGrp -label "Number of Steps" -field true -value 10 -minValue 1 -maxValue 100 numberStepStdSlider; intSliderGrp -label "Width of Steps" -field true -value 5 -minValue 1 widthStepStdSlider; intSliderGrp -label "Height of Steps" -field true -value 1 -minValue 1 heightStepStdSlider; intSliderGrp -label "Depth of Steps" -field true -value 1 -minValue 1 depthStepStdSlider; intSliderGrp -label "Number of landings" -field true -value 2 -minValue 0 landingsStdSlider; //We may not want any landing textFieldGrp -label "Name" -text "MyStairs" nameStdTFG;//adds a field to name the group that will contain the stairs button -label "Create it" -command "getSliderValue(1)" standardBtn; // -------------------------------------------------------------- separator -width 400 -style "double" - horizontal 1; // -------------------------------------------------------------- text -label "\n Spiral Stair Case \n"; intSliderGrp -label "Number of Steps" -field true -value 10 -minValue 1 -maxValue 100 numberStepSprlSlider; intSliderGrp -label "Width of Steps" -field true -value 5 -minValue 2 -dc "dragWidthCommandProcedure()" widthStepSprlSlider; intSliderGrp -label "Height of Steps" -field true -value 1 -minValue 1 heightStepSprlSlider; intSliderGrp -label "Depth of Steps" -field true -value 1 -minValue 1 -maxValue 50 -dc "dragDepthCommandProcedure()" depthStepSprlSlider; intSliderGrp -label "Degrees of Rotations" -field true -value 90 -minValue 1 -maxValue 720 roationsStepSprlSlider; button -label "Create it" -command "getSliderValue(2)" sprialBtn; // -------------------------------------------------------------- separator -width 400 -style "double" - horizontal 1; // -------------------------------------------------------------- text -label "\n Grand Stair Case \n"; intSliderGrp -label "Number of Steps" -field true -value 1 -minValue 1 -maxValue 100 numberStepGrndSlider; intSliderGrp -label "Width of Steps" -field true -value 5 -minValue 1 widthStepGrndSlider; intSliderGrp -label "Height of Steps" -field true -value 1 -minValue 1 heightStepGrndSlider; intSliderGrp -label "Depth of Steps" -field true -value 1 -minValue 1 depthStepGrndSlider; button -label "Create it" -command "getSliderValue(3)" grandBtn; showWindow \$winName; window -e -sizeable false -rtf on \$winName; }`````` Hope it helps. share quote
 02 February 2013 #6 Kobes Veteran portfolio Jacob Santamaria Melbourne, Australia   Join Date: Aug 2010 Posts: 70 The fixes that zeroeffect posted fixes the landings being out of whack Dave. There is also a couple of other suggestions I would make alongside what depakeen has said. First is your UI, I understand it's your first attempt at an original script and it's a great start but creating a more user friendly and intuitive UI for your scripts is going to go along way when other people start to use them. I have edited the UI area of your script, adjust the getSliderProc() and added a toggleUIMode() proc. Check it out and figure out how they work together. `````` // This procedure gets the values of the sliders then passes those values to the respective create procedure proc getSliderValue() { // Queary current values of sliders int \$numStep = `intSliderGrp -q -v numberStepSlider`; int \$widthStep = `intSliderGrp -q -v widthStepSlider`; int \$heightStep = `intSliderGrp -q -v heightStepSlider`; int \$depthStep = `intSliderGrp -q -v depthStepSlider`; int \$landingsStep = `intSliderGrp -q -v landingsSlider`; int \$rotationsStep = `intSliderGrp -q -v roationsStepSlider`; int \$stairAttributes[] = {\$numStep, \$widthStep, \$heightStep, \$depthStep, \$landingsStep, \$rotationsStep}; // Query current mode of UI int \$mode = `radioButtonGrp -q -select modeRadioBtnGrp`; // select is a 1 based int, not 0 if (\$mode == 1) createStandard(\$stairAttributes); if (\$mode == 2) createSpiral(\$stairAttributes); if (\$mode == 3) createGrand(\$stairAttributes); } // ------------------- // Procedure used to toggle certain sliders relative to the mode selected // ------------------- proc toggleUIMode(){ int \$mode = `radioButtonGrp -q -select modeRadioBtnGrp`; // select is a 1 based int, not 0 print (\$mode); // If standard disable the degrees slider if (\$mode == 1){ intSliderGrp -edit -enable true landingsSlider; intSliderGrp -edit -enable false roationsStepSlider; } // If spiral disable landing and enable degrees else if (\$mode == 2){ intSliderGrp -edit -enable false landingsSlider; intSliderGrp -edit -enable true roationsStepSlider; } // If grand disable both landing and enable degrees else if (\$mode == 3){ intSliderGrp -edit -enable false landingsSlider; intSliderGrp -edit -enable false roationsStepSlider; } } // Set the name and title of the window string \$winName = "stairMaster"; string \$winTitle = "Stair Master"; // Check is Window exists and delete if necessary if (`window -exists \$winName`) deleteUI \$winName; //create the window window -rtf on -title \$winTitle -widthHeight 400 200 \$winName ; columnLayout ; //text -label "\n Standard Stair Case \n"; separator -height 4 -style "none"; radioButtonGrp -numberOfRadioButtons 3 -select 1 -label "Stair Case Layout: " -labelArray3 "Standard" "Spiral" "Grand" -columnWidth4 140 80 80 80 -columnAttach4 "left" "left" "left" "left" -columnAlign4 "left" "left" "left" "left" -changeCommand "toggleUIMode()" modeRadioBtnGrp; separator -width 400 -style "in"; separator -height 4 -style "none"; intSliderGrp -label "Number of Steps" -field true -value 10 -minValue 1 -maxValue 100 numberStepSlider; intSliderGrp -label "Width of Steps" -field true -value 5 -minValue 1 widthStepSlider; intSliderGrp -label "Height of Steps" -field true -value 1 -minValue 1 heightStepSlider; intSliderGrp -label "Depth of Steps" -field true -value 1 -minValue 1 depthStepSlider; intSliderGrp -label "Number of landings" -field true -value 2 -minValue 1 landingsSlider; intSliderGrp -label "Degrees of Rotations" -field true -value 90 -minValue 1 -maxValue 720 roationsStepSlider; separator -height 4 -style "none"; button -label "Create it" -width 400 -command "getSliderValue()" standardBtn; showWindow \$winName; //lock the window size window -e -sizeable false -widthHeight 400 200 -rtf on \$winName; toggleUIMode();`````` The second thing is that when I create a standard staircase and then create a spiral in the same scene the steps from the standard are used for the spiral and it all gets messy. The reason for this is because when you are moving and rotating the steps your referring to them by name rather than by object. To fix this when you create each step you should store it in a variable and refer to that variable when manipulating it rather than its name. Third thing is small but you might want to put in a small Reset button to reset all the values on the sliders to default. Hope this all helps Cheers Jake share quote
 02 February 2013 #7 CGTalk Moderation Expert   Join Date: Sep 2003 Posts: 1,066,473 Thread automatically closed This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum. share quote

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts vB code is On Smilies are On [IMG] code is On HTML code is Off CGSociety Society of Digital Artists www.cgsociety.org Powered by vBulletinCopyright ©2000 - 2006, Jelsoft Enterprises Ltd.