Grayth
10-25-2005, 12:23 PM
Thanks to everyone for all their help on my first script. I finished it. While it works I'm sure there are better ways to code it, but this is how i figured it out so far for my first script.
your comments are welcome.
global proc Procam()
{
//variable creation here
string $grp1 = "XYZ_Trans";
string $grp2 = "YRot_Pan";
string $grp3 = "XRot_Tilt";
string $grp4 = "ZRot_Roll";
string $winName = "ProCam";
string $camnode = "1NodeCam";
string $camnode2 = "2NodeCam";
string $camnode3 = "3NodeCam";
//window check
if(`window -exists $winName`)
deleteUI -window $winName;
windowPref -remove $winName;
//window creation Layout here
string $myWindow= `window -title "Pro Camera Setup"
-w 260 -h 185 -s 0 -mnb 0 -mxb 0
$winName`;
//Main window Controls
string $form = `formLayout -nd 260 myform`;
string $labl= `text -label "Camera Name"`;
string $cameraName = `textField -w 150 Newname`;
string $sep =`separator -st "single" -w 225 divider`;
string $checka = `checkBox -l $camnode onenode`;
string $checkb = `checkBox -l $camnode2 twonode`;
string $checkc = `checkBox -l $camnode3 threenode`;
string $butn = `button -label "Create Camera" -c "Values" mybutton`;
//embedded form layout here
string $newform =`frameLayout -l "Select Editable Nodes" -w 225 -h 65 -p myform
-la "top" -bs "etchedIn"
-cll 0 -cl 0 embedform`;
//child of embededform Controls
string $form1 =`formLayout -nd 225 -p embedform nodeform`;
string $check1 = `checkBox -l $grp1 xyztrans`;
string $check2 = `checkBox -l $grp2 yrot`;
string $check3 = `checkBox -l $grp3 xrot`;
string $check4 = `checkBox -l $grp4 zrot`;
//Layout for embeded form Controls here
formLayout -e -af $check1 "top" 8 nodeform;
formLayout -e -af $check1 "left" 15 nodeform;
formLayout -e -af $check2 "top" 24 nodeform;
formLayout -e -af $check2 "left" 15 nodeform;
formLayout -e -af $check3 "top" 8 nodeform;
formLayout -e -af $check3 "left" 135 nodeform;
formLayout -e -af $check4 "top" 24 nodeform;
formLayout -e -af $check4 "left" 135 nodeform;
//layout for main window Controls here
formLayout -e -af $labl "top" 10 myform;
formLayout -e -af $labl "left" 10 myform;
formLayout -e -af $cameraName "top" 7 myform;
formLayout -e -af $cameraName "left" 85 myform;
formLayout -e -af $checka "top" 35 myform;
formLayout -e -af $checka "left" 10 myform;
formLayout -e -af $checkb "top" 35 myform;
formLayout -e -af $checkb "left" 90 myform;
formLayout -e -af $checkc "top" 35 myform;
formLayout -e -af $checkc "left" 170 myform;
formLayout -e -af $sep "top" 55 myform;
formLayout -e -af $sep "left" 11 myform;
formLayout -e -af $newform "top" 60 myform;
formLayout -e -af $newform "left" 11 myform;
formLayout -e -af $butn "top" 130 myform;
formLayout -e -af $butn "left" 75 myform;
showWindow $winName;
}
//procedure to query all the values from the window
//and run tests for error messages
global proc Values()
{
//variable creation here
string $grp1 = "XYZ_Trans";
string $grp2 = "YRot_Pan";
string $grp3 = "XRot_Tilt";
string $grp4 = "ZRot_Roll";
//query the values of the controls from main form
string $CamName = `textField -q -tx Newname`;
string $xyz = `checkBox -q -v xyztrans`;
string $yrotate = `checkBox -q -v yrot`;
string $xrotate = `checkBox -q -v xrot`;
string $zrotate = `checkBox -q -v zrot`;
string $node1 = `checkBox -q -v onenode`;
string $node2 = `checkBox -q -v twonode`;
string $node3 = `checkBox -q -v threenode`;
//check for error messages
if($CamName == "")
error "You forgot to give the Camera a name";
string $totalnode = $node1 + $node2 + $node3;
if($totalnode =="000")
error "You didn't select a Camera Type";
if($totalnode =="111")
error "You selected more than one Camera Type";
if($totalnode =="110")
error "You selected more than one Camera Type";
if($totalnode =="101")
error "You selected more than one Camera Type";
if($totalnode =="011")
error "You selected more than one Camera Type";
string $editnode = $xyz + $yrotate + $xrotate + $zrotate;
if($editnode =="0000")
error "You didn't select any Editable Nodes";
//camera creation statements
if ($node1 =="1")
camnode1($CamName);
if ($node2 =="1")
camnode2($CamName);
if ($node3 =="1")
camnode3($CamName);
//selecting the top node in hypergraph
select -r $CamName;
pickWalk -d up;
//setting attrib of the zrot node
if ($zrotate =="1")
zgroup($grp4);
//setting the attrib of the xrot node
if ($xrotate =="1")
xgroup($grp3);
//setting the attrib of the yrot node
if ($yrotate =="1")
ygroup($grp2);
//setting the attrib of the xyz trans
if ($xyz =="1")
xyzgroup($grp1);
}
//procedure for camera creation for 1 node camera
global proc camnode1(string $CamName)
{
camera -centerOfInterest 5 -focalLength 35 -lensSqueezeRatio 1 -cameraScale 1 -horizontalFilmAperture 1.41732 -horizontalFilmOffset 0 -verticalFilmAperture 0.94488 -verticalFilmOffset 0 -filmFit Fill -overscan 1 -motionBlur 0 -shutterAngle 144 -nearClipPlane 0.01 -farClipPlane 1000 -orthographic 0 -orthographicWidth 30;
cameraMakeNode 1 "";
rename $CamName;
setAttr -lock true ($CamName +".tx");
setAttr -lock true ($CamName +".ty");
setAttr -lock true ($CamName +".tz");
setAttr -lock true ($CamName +".rx");
setAttr -lock true ($CamName +".ry");
setAttr -lock true ($CamName +".rz");
setAttr -lock true ($CamName +".sx");
setAttr -lock true ($CamName +".sy");
setAttr -lock true ($CamName +".sz");
}
//procedure for camera creation for 2 node camera
global proc camnode2(string $CamName)
{
camera -centerOfInterest 5 -focalLength 35 -lensSqueezeRatio 1 -cameraScale 1 -horizontalFilmAperture 1.41732 -horizontalFilmOffset 0 -verticalFilmAperture 0.94488 -verticalFilmOffset 0 -filmFit Fill -overscan 1 -motionBlur 0 -shutterAngle 144 -nearClipPlane 0.01 -farClipPlane 1000 -orthographic 0 -orthographicWidth 30;
cameraMakeNode 2 "";
rename $CamName;
setAttr -lock true ($CamName +".tx");
setAttr -lock true ($CamName +".ty");
setAttr -lock true ($CamName +".tz");
setAttr -lock true ($CamName +".rx");
setAttr -lock true ($CamName +".ry");
setAttr -lock true ($CamName +".rz");
setAttr -lock true ($CamName +".sx");
setAttr -lock true ($CamName +".sy");
setAttr -lock true ($CamName +".sz");
}
//procedure for camera creation for 3 node camera
global proc camnode3(string $CamName)
{
camera -centerOfInterest 5 -focalLength 35 -lensSqueezeRatio 1 -cameraScale 1 -horizontalFilmAperture 1.41732 -horizontalFilmOffset 0 -verticalFilmAperture 0.94488 -verticalFilmOffset 0 -filmFit Fill -overscan 1 -motionBlur 0 -shutterAngle 144 -nearClipPlane 0.01 -farClipPlane 1000 -orthographic 0 -orthographicWidth 30;
cameraMakeNode 3 "";
rename $CamName;
setAttr -lock true ($CamName +".tx");
setAttr -lock true ($CamName +".ty");
setAttr -lock true ($CamName +".tz");
setAttr -lock true ($CamName +".rx");
setAttr -lock true ($CamName +".ry");
setAttr -lock true ($CamName +".rz");
setAttr -lock true ($CamName +".sx");
setAttr -lock true ($CamName +".sy");
setAttr -lock true ($CamName +".sz");
}
//procedure for making zrotate node
global proc zgroup(string $grp4)
{
group -name $grp4; xform -os -piv 0 0 0;
setAttr -lock true ($grp4 +".tx");
setAttr -lock true ($grp4 +".ty");
setAttr -lock true ($grp4 +".tz");
setAttr -lock true ($grp4 +".rx");
setAttr -lock true ($grp4 +".ry");
setAttr -lock true ($grp4 +".sx");
setAttr -lock true ($grp4 +".sy");
setAttr -lock true ($grp4 +".sz");
}
//procedure for making xrotate node
global proc xgroup(string $grp3)
{
group -name $grp3; xform -os -piv 0 0 0;
setAttr -lock true ($grp3 +".tx");
setAttr -lock true ($grp3 +".ty");
setAttr -lock true ($grp3 +".tz");
setAttr -lock true ($grp3 +".ry");
setAttr -lock true ($grp3 +".rz");
setAttr -lock true ($grp3 +".sx");
setAttr -lock true ($grp3 +".sy");
setAttr -lock true ($grp3 +".sz");
}
//procedure for making yrot node
global proc ygroup(string $grp2)
{
group -name $grp2; xform -os -piv 0 0 0;
setAttr -lock true ($grp2 +".tx");
setAttr -lock true ($grp2 +".ty");
setAttr -lock true ($grp2 +".tz");
setAttr -lock true ($grp2 +".rx");
setAttr -lock true ($grp2 +".rz");
setAttr -lock true ($grp2 +".sx");
setAttr -lock true ($grp2 +".sy");
setAttr -lock true ($grp2 +".sz");
setAttr -lock true ($grp2 +".v");
}
//procedure for making xyztrans node
global proc xyzgroup(string $grp1)
{
group -name $grp1; xform -os -piv 0 0 0;
setAttr -lock true ($grp1 +".rx");
setAttr -lock true ($grp1 +".ry");
setAttr -lock true ($grp1 +".rz");
setAttr -lock true ($grp1 +".sx");
setAttr -lock true ($grp1 +".sy");
setAttr -lock true ($grp1 +".sz");
setAttr -lock true ($grp1 +".v");
}
Thanks,
Troy
your comments are welcome.
global proc Procam()
{
//variable creation here
string $grp1 = "XYZ_Trans";
string $grp2 = "YRot_Pan";
string $grp3 = "XRot_Tilt";
string $grp4 = "ZRot_Roll";
string $winName = "ProCam";
string $camnode = "1NodeCam";
string $camnode2 = "2NodeCam";
string $camnode3 = "3NodeCam";
//window check
if(`window -exists $winName`)
deleteUI -window $winName;
windowPref -remove $winName;
//window creation Layout here
string $myWindow= `window -title "Pro Camera Setup"
-w 260 -h 185 -s 0 -mnb 0 -mxb 0
$winName`;
//Main window Controls
string $form = `formLayout -nd 260 myform`;
string $labl= `text -label "Camera Name"`;
string $cameraName = `textField -w 150 Newname`;
string $sep =`separator -st "single" -w 225 divider`;
string $checka = `checkBox -l $camnode onenode`;
string $checkb = `checkBox -l $camnode2 twonode`;
string $checkc = `checkBox -l $camnode3 threenode`;
string $butn = `button -label "Create Camera" -c "Values" mybutton`;
//embedded form layout here
string $newform =`frameLayout -l "Select Editable Nodes" -w 225 -h 65 -p myform
-la "top" -bs "etchedIn"
-cll 0 -cl 0 embedform`;
//child of embededform Controls
string $form1 =`formLayout -nd 225 -p embedform nodeform`;
string $check1 = `checkBox -l $grp1 xyztrans`;
string $check2 = `checkBox -l $grp2 yrot`;
string $check3 = `checkBox -l $grp3 xrot`;
string $check4 = `checkBox -l $grp4 zrot`;
//Layout for embeded form Controls here
formLayout -e -af $check1 "top" 8 nodeform;
formLayout -e -af $check1 "left" 15 nodeform;
formLayout -e -af $check2 "top" 24 nodeform;
formLayout -e -af $check2 "left" 15 nodeform;
formLayout -e -af $check3 "top" 8 nodeform;
formLayout -e -af $check3 "left" 135 nodeform;
formLayout -e -af $check4 "top" 24 nodeform;
formLayout -e -af $check4 "left" 135 nodeform;
//layout for main window Controls here
formLayout -e -af $labl "top" 10 myform;
formLayout -e -af $labl "left" 10 myform;
formLayout -e -af $cameraName "top" 7 myform;
formLayout -e -af $cameraName "left" 85 myform;
formLayout -e -af $checka "top" 35 myform;
formLayout -e -af $checka "left" 10 myform;
formLayout -e -af $checkb "top" 35 myform;
formLayout -e -af $checkb "left" 90 myform;
formLayout -e -af $checkc "top" 35 myform;
formLayout -e -af $checkc "left" 170 myform;
formLayout -e -af $sep "top" 55 myform;
formLayout -e -af $sep "left" 11 myform;
formLayout -e -af $newform "top" 60 myform;
formLayout -e -af $newform "left" 11 myform;
formLayout -e -af $butn "top" 130 myform;
formLayout -e -af $butn "left" 75 myform;
showWindow $winName;
}
//procedure to query all the values from the window
//and run tests for error messages
global proc Values()
{
//variable creation here
string $grp1 = "XYZ_Trans";
string $grp2 = "YRot_Pan";
string $grp3 = "XRot_Tilt";
string $grp4 = "ZRot_Roll";
//query the values of the controls from main form
string $CamName = `textField -q -tx Newname`;
string $xyz = `checkBox -q -v xyztrans`;
string $yrotate = `checkBox -q -v yrot`;
string $xrotate = `checkBox -q -v xrot`;
string $zrotate = `checkBox -q -v zrot`;
string $node1 = `checkBox -q -v onenode`;
string $node2 = `checkBox -q -v twonode`;
string $node3 = `checkBox -q -v threenode`;
//check for error messages
if($CamName == "")
error "You forgot to give the Camera a name";
string $totalnode = $node1 + $node2 + $node3;
if($totalnode =="000")
error "You didn't select a Camera Type";
if($totalnode =="111")
error "You selected more than one Camera Type";
if($totalnode =="110")
error "You selected more than one Camera Type";
if($totalnode =="101")
error "You selected more than one Camera Type";
if($totalnode =="011")
error "You selected more than one Camera Type";
string $editnode = $xyz + $yrotate + $xrotate + $zrotate;
if($editnode =="0000")
error "You didn't select any Editable Nodes";
//camera creation statements
if ($node1 =="1")
camnode1($CamName);
if ($node2 =="1")
camnode2($CamName);
if ($node3 =="1")
camnode3($CamName);
//selecting the top node in hypergraph
select -r $CamName;
pickWalk -d up;
//setting attrib of the zrot node
if ($zrotate =="1")
zgroup($grp4);
//setting the attrib of the xrot node
if ($xrotate =="1")
xgroup($grp3);
//setting the attrib of the yrot node
if ($yrotate =="1")
ygroup($grp2);
//setting the attrib of the xyz trans
if ($xyz =="1")
xyzgroup($grp1);
}
//procedure for camera creation for 1 node camera
global proc camnode1(string $CamName)
{
camera -centerOfInterest 5 -focalLength 35 -lensSqueezeRatio 1 -cameraScale 1 -horizontalFilmAperture 1.41732 -horizontalFilmOffset 0 -verticalFilmAperture 0.94488 -verticalFilmOffset 0 -filmFit Fill -overscan 1 -motionBlur 0 -shutterAngle 144 -nearClipPlane 0.01 -farClipPlane 1000 -orthographic 0 -orthographicWidth 30;
cameraMakeNode 1 "";
rename $CamName;
setAttr -lock true ($CamName +".tx");
setAttr -lock true ($CamName +".ty");
setAttr -lock true ($CamName +".tz");
setAttr -lock true ($CamName +".rx");
setAttr -lock true ($CamName +".ry");
setAttr -lock true ($CamName +".rz");
setAttr -lock true ($CamName +".sx");
setAttr -lock true ($CamName +".sy");
setAttr -lock true ($CamName +".sz");
}
//procedure for camera creation for 2 node camera
global proc camnode2(string $CamName)
{
camera -centerOfInterest 5 -focalLength 35 -lensSqueezeRatio 1 -cameraScale 1 -horizontalFilmAperture 1.41732 -horizontalFilmOffset 0 -verticalFilmAperture 0.94488 -verticalFilmOffset 0 -filmFit Fill -overscan 1 -motionBlur 0 -shutterAngle 144 -nearClipPlane 0.01 -farClipPlane 1000 -orthographic 0 -orthographicWidth 30;
cameraMakeNode 2 "";
rename $CamName;
setAttr -lock true ($CamName +".tx");
setAttr -lock true ($CamName +".ty");
setAttr -lock true ($CamName +".tz");
setAttr -lock true ($CamName +".rx");
setAttr -lock true ($CamName +".ry");
setAttr -lock true ($CamName +".rz");
setAttr -lock true ($CamName +".sx");
setAttr -lock true ($CamName +".sy");
setAttr -lock true ($CamName +".sz");
}
//procedure for camera creation for 3 node camera
global proc camnode3(string $CamName)
{
camera -centerOfInterest 5 -focalLength 35 -lensSqueezeRatio 1 -cameraScale 1 -horizontalFilmAperture 1.41732 -horizontalFilmOffset 0 -verticalFilmAperture 0.94488 -verticalFilmOffset 0 -filmFit Fill -overscan 1 -motionBlur 0 -shutterAngle 144 -nearClipPlane 0.01 -farClipPlane 1000 -orthographic 0 -orthographicWidth 30;
cameraMakeNode 3 "";
rename $CamName;
setAttr -lock true ($CamName +".tx");
setAttr -lock true ($CamName +".ty");
setAttr -lock true ($CamName +".tz");
setAttr -lock true ($CamName +".rx");
setAttr -lock true ($CamName +".ry");
setAttr -lock true ($CamName +".rz");
setAttr -lock true ($CamName +".sx");
setAttr -lock true ($CamName +".sy");
setAttr -lock true ($CamName +".sz");
}
//procedure for making zrotate node
global proc zgroup(string $grp4)
{
group -name $grp4; xform -os -piv 0 0 0;
setAttr -lock true ($grp4 +".tx");
setAttr -lock true ($grp4 +".ty");
setAttr -lock true ($grp4 +".tz");
setAttr -lock true ($grp4 +".rx");
setAttr -lock true ($grp4 +".ry");
setAttr -lock true ($grp4 +".sx");
setAttr -lock true ($grp4 +".sy");
setAttr -lock true ($grp4 +".sz");
}
//procedure for making xrotate node
global proc xgroup(string $grp3)
{
group -name $grp3; xform -os -piv 0 0 0;
setAttr -lock true ($grp3 +".tx");
setAttr -lock true ($grp3 +".ty");
setAttr -lock true ($grp3 +".tz");
setAttr -lock true ($grp3 +".ry");
setAttr -lock true ($grp3 +".rz");
setAttr -lock true ($grp3 +".sx");
setAttr -lock true ($grp3 +".sy");
setAttr -lock true ($grp3 +".sz");
}
//procedure for making yrot node
global proc ygroup(string $grp2)
{
group -name $grp2; xform -os -piv 0 0 0;
setAttr -lock true ($grp2 +".tx");
setAttr -lock true ($grp2 +".ty");
setAttr -lock true ($grp2 +".tz");
setAttr -lock true ($grp2 +".rx");
setAttr -lock true ($grp2 +".rz");
setAttr -lock true ($grp2 +".sx");
setAttr -lock true ($grp2 +".sy");
setAttr -lock true ($grp2 +".sz");
setAttr -lock true ($grp2 +".v");
}
//procedure for making xyztrans node
global proc xyzgroup(string $grp1)
{
group -name $grp1; xform -os -piv 0 0 0;
setAttr -lock true ($grp1 +".rx");
setAttr -lock true ($grp1 +".ry");
setAttr -lock true ($grp1 +".rz");
setAttr -lock true ($grp1 +".sx");
setAttr -lock true ($grp1 +".sy");
setAttr -lock true ($grp1 +".sz");
setAttr -lock true ($grp1 +".v");
}
Thanks,
Troy
