Hi,
i’ve read the very first post of this thread, and i found that to have a cubic helper was quite useful. Unfortunatly, the cube is not at the center of the world and have fixed values. So I’ve changed the script a little bit. Tell me if it helps ! (sorry, i’m really a newbie)
four scripts :
- CreateSplineCube.mel
- CreateSplineCubePrompt.mel
and two others for the shelf buttons.
first part, the cube itself (“CreateSplineCube.mel”):
global proc JPL_CubeSpline (int $sizeSide)
{
if ($sizeSide > 0) //useful if the user did not type an integer
{
curve -d 1
-p $sizeSide $sizeSide $sizeSide -p $sizeSide $sizeSide (-$sizeSide)
-p (-$sizeSide) $sizeSide (-$sizeSide) -p (-$sizeSide) $sizeSide $sizeSide
-p $sizeSide $sizeSide $sizeSide -p $sizeSide (-$sizeSide) $sizeSide
-p (-$sizeSide) (-$sizeSide) $sizeSide -p (-$sizeSide) $sizeSide $sizeSide
-p (-$sizeSide) $sizeSide (-$sizeSide) -p (-$sizeSide) (-$sizeSide) (-$sizeSide)
-p (-$sizeSide) (-$sizeSide) $sizeSide -p $sizeSide (-$sizeSide) $sizeSide
-p $sizeSide (-$sizeSide) (-$sizeSide) -p (-$sizeSide) (-$sizeSide) (-$sizeSide)
-p (-$sizeSide) $sizeSide (-$sizeSide) -p $sizeSide $sizeSide (-$sizeSide)
-p $sizeSide (-$sizeSide) (-$sizeSide)
-k 0 -k 1 -k 2 -k 3 -k 4 -k 5 -k 6 -k 7 -k 8 -k 9 -k 10 -k 11 -k 12 -k 13 -k 14 -k 15 -k 16;
xform -cp;
rename ControlCube1; //Maya will automatically increment if you create other cubes
}
else
error "not a valid value. Try again !";
}
second part, the code that creates a prompt window to set the size of the cube (“CreateSplineCubePrompt.mel”):
global proc JPL_PromptCubeDialog ()
{
int $sizeSide;
string $result = `promptDialog
-t "Create a cubic helper"
-m ("Please type the size of the cube:")
-b "OK" -b "Cancel"
-db "OK" -cb "Cancel"
-ds "Cancel"`;
if ($result == "OK")
{
$sizeSide = `promptDialog -q -tx`;
source "CreateSplineCube.mel";
JPL_CubeSpline ($sizeSide);
}
}
The script to launch from the shelf with the prompt window :
source "CreateSplineCubePrompt.mel";
JPL_PromptCubeDialog ();
The last one to create the cube with a fixed value (change “5” by whatever you want) :
source "CreateSplineCube.mel";
JPL_CubeSpline (5);