These are some MEL scripts I've assigned to hotkeys. They are written or pieced together by me based on stuff I found in maya documentation, stackoverflow, forums, etc., or my own guesswork or trial and error. I'm sure there are plenty of weird edge cases where some scripts don't work or break somehow, I fix them as I discover them. The list looks longer than it really is, because many scripts have copies for each axis, some for +/- on each axis as well. Also some scripts depend on the presence of others, it should be mentioned in the description of each script if so.
My current hotkey sheet can be seen here (source is here) and you can make your own using my templates which are explained in this video.
I recommend AutoHotkey for custom per-software key/button remapping, macros, etc. The script I use for it is here. I set up just one static profile for the mouse mappings in the shitty Razer software so I can put it in the mouse onboard memory and not rely on the Razer software at all and close it. (Now I use the more reliable Logitech G600t and set it up in Logitech Gaming Software but the idea is the same.)
The changelog is at the bottom.
- SelectionHighlighting
- WireframeOnShaded
- FlatLight
- FaceCentersAndNormals
- HiddenTriangles
- ResetPolygonDisplay
- GridAndUVGridToggle
- IsolateSelectedAllViews
- UnhideAll
- CustomFrame
- ViewportSingle
- ViewportDual
- ViewportQuad
- OutlinerToggle
- SetBackgroundColor
- ObjectModeForce
- CustomSelectPress
- CustomSelectRelease
- LockObject
- SelectFacingPosX
- SelectFacingPosY
- SelectFacingPosZ
- SelectFacingNegX
- SelectFacingNegY
- SelectFacingNegZ
- SelectFacingCam
- SelectPercentageRandom
- SelectEdgesSmooth
- SelectEdgesHard
- SelectEdgesInside
- SelectEdgesBorder
- SelectSameAngle
- SelectSameAngleCont
- SelectStrayVerts
- Ring2
- Ring3
- Ring4
- Loop2
- Loop3
- Loop4
- BreakComponentsOrShells
- TargetWeld
- MergeAllVerts
- ConnectFirstVert
- EdgeDivide
- CollapseOrSewEdges
- BridgeEdgesOrFaces
- BevelEdge
- FillHoleQuads
- Corner45A
- Corner45B
- TriangulateFaces
- QuadrangulateFaces
- SetBoundingBox
- PushVertices
- SetNormalPosX
- SetNormalPosY
- SetNormalPosZ
- SetNormalNegX
- SetNormalNegY
- SetNormalNegZ
- BendNormalPosX
- BendNormalPosY
- BendNormalPosZ
- BendNormalNegX
- BendNormalNegY
- BendNormalNegZ
- FlattenNormalX
- FlattenNormalY
- FlattenNormalZ
- NormalsSizeUp
- NormalsSizeDown
- FirstNormalToAll
- FirstNormalBend
- TransferNormals
- AutoSmooth
- HardUVBorders
- PivotForceComponent
- PivotForceWorld
- PivotWorldReset
- PivotReset
- FreezeResetClear
- PivotCenterBottom
- FreezeCenterBottomClear
- ClearHistory
- AlignMidX
- AlignMidY
- AlignMidZ
- AlignMinX
- AlignMinY
- AlignMinZ
- AlignMaxX
- AlignMaxY
- AlignMaxZ
- DistributeX
- DistributeY
- DistributeZ
- StackX
- StackY
- StackZ
- UV_EditorToggle
- UV_UnfoldU
- UV_UnfoldV
- UV_UnfoldUV
- UV_ScaleVup
- UV_ScaleVdown
- UV_ScaleUup
- UV_ScaleUdown
- UV_FlipU
- UV_FlipV
- UV_RotateCW
- UV_RotateCCW
- UV_AlignAvgU
- UV_AlignAvgV
- UV_AlignMaxU
- UV_AlignMaxV
- UV_AlignMinU
- UV_AlignMinV
- UV_MoveUp
- UV_MoveRight
- UV_MoveDown
- UV_MoveLeft
- UV_TexelDensityGet
- UV_TexelDensitySet
- UV_PlanarProjectX
- UV_PlanarProjectY
- UV_PlanarProjectZ
- UV_Automatic
- UV_Cycle
- UV_Stack
- UV_StackOrient
- UV_Straighten
- UV_StitchTogetherAB
- UV_StitchTogetherBA
Toggles highlighting of selected objects.
string $mp = `getPanel -wf`; modelEditor -e -sel (!`modelEditor -q -sel $mp`) $mp;Enters shaded mode and toggles wireframe on shaded.
modelEditor -e -dl "default" `getPanel -wf`;
string $selectedPanel = `getPanel -wf`;
int $shadedWireState = `modelEditor -q -wos $selectedPanel`;
if(`modelEditor -ex $selectedPanel`) setWireframeOnShadedOption (!$shadedWireState) $selectedPanel;Enters unlit mode. (has no effect on some custom shaders)
modelEditor -e -dl flat `getPanel -wf`;
string $selectedPanel = `getPanel -wf`;
int $shadedWireState = `modelEditor -q -wos $selectedPanel`;
if(`modelEditor -ex $selectedPanel`) setWireframeOnShadedOption (!$shadedWireState) $selectedPanel;Toggles display of face centers and normals.
polyOptions -gl -r -f -dn on;
polyOptions -gl -r -dc 1;
inViewMessage -msg "Face Centers & Normals" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;HiddenTriangles
Toggles display of hidden triangles.
polyOptions -r -dt 1;
inViewMessage -msg "Hidden Triangles" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;Resets polygon display for all objects.
polyOptions -gl -ae -sb 3 -db 0 -dmb 0 -dv 0 -dn 0 -facet -dc 0 -dt 0 -dw 0 -din 0 0 0 0 -sn 0.4 -bc -duv 0 -uvt 0 -cs 0 -cm diffuse -bcv 1;
inViewMessage -msg "Reset Polygon Display" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;Toggles grid in the viewport or uv editor based on which the mouse is hovering.
if(`getPanel -wf` == "polyTexturePlacementPanel1") textureWindowToggleGrid ("polyTexturePlacementPanel1","textureWindow" );
else optionVar -intValue showGrid (!`optionVar -query showGrid`); grid -toggle (`optionVar -query showGrid`);Toggles isolation mode of selected objects in all viewports. Hides sets in the outliner.
{
string $panels[] = `getPanel -type modelPanel`;
for ($currentPanel in $panels) {
isolateSelect -loadSelected $currentPanel;
string $state = `isolateSelect -q -state $currentPanel`;
if($state) {
enableIsolateSelect $currentPanel false;
isolateSelect -state 0 $currentPanel;
}
else {
enableIsolateSelect $currentPanel true;
isolateSelect -state 1 $currentPanel;
}
if($state) inViewMessage -msg "Exit Isolate" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
else inViewMessage -msg "Isolate" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
}
string $all[] = `ls`;
for($obj in $all) if(`objectType $obj` == "objectSet") setAttr ($obj + ".hiddenInOutliner") true;
AEobjectSetCommonRefreshOutliners();
}Unhides all objects but hides cameras.
showHidden -all;
HideCameras;
inViewMessage -msg "Unhide All" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;Repositions and zooms cameras to frame the selection. Similar to default frame selected but takes into account the bounding box of the selection, so it avoids bad framing when you have complex scenes with nested objects and weird pivots.
{
if(`getPanel -wf` == "polyTexturePlacementPanel1") FrameSelected;
else {
string $objs[] = `ls -o -sl`;
string $prevsel = "o";
if(!`selectMode -q -object` && size($objs)==0) {
if(`selectType -q -v`) $prevsel = "v";
else if(`selectType -q -eg`) $prevsel = "e";
else if(`selectType -q -fc`) $prevsel = "f";
else if(`selectType -q -puv`) $prevsel = "u";
else if(`selectType -q -smu`||`selectType -q -msh`) $prevsel = "s";
dR_modeObject;
}
$objs = `ls -o -sl`;
float $bb[] = { 10000000000000001 };
if(size($objs)>0) $bb = `exactWorldBoundingBox`;
if(size($objs)>0 && $bb[0] < 10000000000000000) {
float $avg[] = { ($bb[3] + $bb[0]) / 2, ($bb[4] + $bb[1]) / 2, ($bb[5] + $bb[2]) / 2 };
float $len = `mag <<float($bb[0] - $bb[3]), float($bb[1] - $bb[4]), float($bb[2] - $bb[5])>>`;
string $cams[] = `listCameras`;
for($cam in $cams) if(`match "persp" $cam` != "" || `match "top" $cam` != "" || `match "front" $cam` != "" || `match "side" $cam` != "" || `match "back" $cam` != "" || `match "left" $cam` != "" || `match "right" $cam` != "" || `match "bottom" $cam` != "") {
float $camFoc[3] = `camera -q -worldCenterOfInterest $cam`;
float $camPos[3] = `camera -q -position $cam`;
vector $one = <<$camFoc[0], $camFoc[1], $camFoc[2]>>;
vector $two = <<$camPos[0], $camPos[1], $camPos[2]>>;
vector $final = ($two - $one);
$directionVector = unit($final);
move -ws -a ($avg[0]+$directionVector.x*$len) ($avg[1]+$directionVector.y*$len) ($avg[2]+$directionVector.z*$len) $cam;
$len += 0.1;
setAttr ($cam + "Shape" + ".centerOfInterest") $len;
if(`getAttr ($cam + "Shape" + ".orthographic")`) {
setAttr ($cam + "Shape" + ".orthographicWidth") ($len*2);
float $farc = `getAttr ($cam + "Shape" + ".farClipPlane")`/8;
move -ws -a ($avg[0]+$directionVector.x*$farc) ($avg[1]+$directionVector.y*$farc) ($avg[2]+$directionVector.z*$farc) $cam;
}
else move -ws -a ($avg[0]+$directionVector.x*$len) ($avg[1]+$directionVector.y*$len) ($avg[2]+$directionVector.z*$len) $cam;
}
}
else FrameAllInAllViews;
if($prevsel == "v") SelectVertexMask;
else if($prevsel == "e") SelectEdgeMask;
else if($prevsel == "f") SelectFacetMask;
else if($prevsel == "u") SelectUVMask;
else if($prevsel == "s") UVToolkitUVShellModeCB;
}
}Loads up single pane viewport layout preset.
setNamedPanelLayout "Single Perspective View"; updateToolbox();Loads up two pane viewport layout preset.
setNamedPanelLayout "Front/Persp"; updateToolbox();Loads up four pane viewport layout preset.
setNamedPanelLayout "Four View"; updateToolbox();Toggles the outliner.
ToggleOutliner;Sets the viewport background color to 0.18 gray.
displayRGBColor background 0.18 0.18 0.18;Forces object mode instead of toggling it.
changeSelectMode -object;
inViewMessage -smg "Object Selection" -fade -pos topCenter;Workaround for newer versions of maya not hiding the gizmo while tab selecting, I assign these to Q press and release - you need to assign the relase key first and then the press key, otherwise they will overwrite each other. Pressing it without selecting/deselecting anything will activate the regular select tool. Works for vertices, edges, faces, and uvs, but not uv shells. Also preserves custom pivot when used. A weird quirk - deselecting all selected components while using this will activate the select tool, since it gets registered the same as not selecting/deselecting everything. (This is unreliable garbage - I don't recommend using it.)
string $currentToolActive = `currentCtx`;
float $prepivpos[] = `manipPivot -q -p`;
float $prepivori[] = `manipPivot -q -o`;
SelectTool;
selectPref -paintSelect 1;
string $preverts[];
string $preedges[];
string $prefaces[];
string $preuvs[];
if(`selectType -q -v`) $preverts = `filterExpand -sm 31`;
else if(`selectType -q -eg`) $preedges = `filterExpand -sm 32`;
else if(`selectType -q -fc`) $prefaces = `filterExpand -sm 34`;
else if(`selectType -q -puv`) $preuvs = `filterExpand -sm 35`;global proc int stringArraysEqual(string $a[], string $b[]) {
if (size($a) != size($b)) return 0;
for ($i = 0; $i < size($a); $i++) if ($a[$i] != $b[$i]) return 0;
return 1;
}
selectPref -paintSelect 0;
string $presel[];
string $newsel[];
if(`selectType -q -v`) {
$presel = $preverts;
$newsel = `filterExpand -sm 31`;
}
else if(`selectType -q -eg`) {
$presel = $preedges;
$newsel = `filterExpand -sm 32`;
}
else if(`selectType -q -fc`) {
$presel = $prefaces;
$newsel = `filterExpand -sm 34`;
}
else if(`selectType -q -puv`) {
$presel = $preuvs;
$newsel = `filterExpand -sm 35`;
}
select $presel;
if(size($newsel)) {
string $addsel[];
string $remsel[];
for($f in $newsel) if(!stringArrayContains($f, $presel)) $addsel[size($addsel)] = $f;
for($f in $presel) if(stringArrayContains($f, $newsel)) $remsel[size($remsel)] = $f;
if(stringArraysEqual($presel, $newsel) && stringArraysEqual($newsel, $remsel)) selectTool;
else {
select -add $newsel;
if(size($remsel)) select -d $remsel;
setToolTo $currentToolActive;
manipPivot -p $prepivpos[0] $prepivpos[1] $prepivpos[2];
manipPivot -o $prepivori[0] $prepivori[1] $prepivori[2];
}
}Toggles reference mode for non-selected objects, "locking" you into only being able to select currently selected objects or their components.
proc toggleReference(){
string $isReferenced = `getenv "isReferenced"`;
if($isReferenced == "" || $isReferenced == "-1") {
string $selection[] = `ls -sl`;
changeSelectMode -object;
SelectToggleMode;
toggleSelMode;
InvertSelection;
string $array[] = `eval "listRelatives -pa -p `ls -typ mesh`"`;
for ($item in $array) {
$flag = -1;
for($i in $selection) {
if($i == $item) {
$flag = 1;
break;
}
}
if($flag == 1) continue;
string $shapes[] = `listRelatives -pa -shapes $item`;
setAttr ($shapes[0] + ".overrideEnabled") 1;
setAttr ($shapes[0] + ".overrideDisplayType") 2;
}
select -cl;
select $selection;
selectMode -co;
int $isReferenced = 1;
putenv "isReferenced" "1";
inViewMessage -msg "<span style='color:#ff0'>Objects Locked</span>" -pos midLeft -fts 30 -fof 0 -bkc 0x330000;
}
else {
string $selection[] = `ls -sl`;
SelectAll;
string $array[] = `eval "listRelatives -pa -p `ls -typ mesh`"`;
for ($item in $array) {
string $shapes[] = `listRelatives -pa -shapes $item`;
setAttr ($shapes[0] + ".overrideDisplayType") 0;
setAttr ($shapes[0] + ".overrideEnabled") 0;
}
select $selection;
selectMode -o;
putenv "isReferenced" "-1";
inViewMessage -msg "<span style='color:#0ff'>Objects Unlocked</span>" -fade -fit 00 -fst 200 -fot 800 -pos midLeft -fts 30 -fof 0 -bkc 0x000033;
}
}
toggleReference;Select all faces facing in a certain direction (+X in this case), input window popup for angle tolerance.
proc selectByAngle(float $x, float $y, float $z, float $a) {
SelectFacetMask;
resetPolySelectConstraint;
polySelectConstraint -m 3;
polySelectConstraint -t 8 -a 1 -o 1 -oa $x $y $z -ob 0 $a;
polySelectConstraint -m 0;
resetPolySelectConstraint;
}
proc dial() {
string $result = `promptDialog -title "Select +X" -text "25"
-button "OK" -button "Cancel"
-defaultButton "OK" -cancelButton "Cancel"
-dismissString "Cancel"`;
if($result == "OK") {
$angle = float(`promptDialog -query -text`);
selectByAngle(1, 0, 0, $angle);
string $message = "Select <span style='color:#ff0'>+</span><span style='color:#f00'>X</span>" + string($angle) + "°";
inViewMessage -msg $message -fade -fit 00 -fst 1000 -fot 1000 -pos midCenterTop -fts 30 -bkc 0x000000;
}
}
dial();Ditto +Y.
proc selectByAngle(float $x, float $y, float $z, float $a) {
SelectFacetMask;
resetPolySelectConstraint;
polySelectConstraint -m 3;
polySelectConstraint -t 8 -a 1 -o 1 -oa $x $y $z -ob 0 $a;
polySelectConstraint -m 0;
resetPolySelectConstraint;
}
proc dial() {
string $result = `promptDialog -title "Select +Y" -text "25"
-button "OK" -button "Cancel"
-defaultButton "OK" -cancelButton "Cancel"
-dismissString "Cancel"`;
if($result == "OK") {
$angle = float(`promptDialog -query -text`);
selectByAngle(0, 1, 0, $angle);
string $message = "Select <span style='color:#ff0'>+</span><span style='color:#0f0'>Y</span>" + string($angle) + "°";
inViewMessage -msg $message -fade -fit 00 -fst 1000 -fot 1000 -pos midCenterTop -fts 30 -bkc 0x000000;
}
}
dial();Ditto +Z.
proc selectByAngle(float $x, float $y, float $z, float $a) {
SelectFacetMask;
resetPolySelectConstraint;
polySelectConstraint -m 3;
polySelectConstraint -t 8 -a 1 -o 1 -oa $x $y $z -ob 0 $a;
polySelectConstraint -m 0;
resetPolySelectConstraint;
}
proc dial() {
string $result = `promptDialog -title "Select +Z" -text "25"
-button "OK" -button "Cancel"
-defaultButton "OK" -cancelButton "Cancel"
-dismissString "Cancel"`;
if($result == "OK") {
$angle = float(`promptDialog -query -text`);
selectByAngle(0, 0, 1, $angle);
string $message = "Select <span style='color:#ff0'>+</span><span style='color:#00f'>Z</span>" + string($angle) + "°";
inViewMessage -msg $message -fade -fit 00 -fst 1000 -fot 1000 -pos midCenterTop -fts 30 -bkc 0x000000;
}
}
dial();Ditto -X.
proc selectByAngle(float $x, float $y, float $z, float $a) {
SelectFacetMask;
resetPolySelectConstraint;
polySelectConstraint -m 3;
polySelectConstraint -t 8 -a 1 -o 1 -oa $x $y $z -ob 0 $a;
polySelectConstraint -m 0;
resetPolySelectConstraint;
}
proc dial() {
string $result = `promptDialog -title "Select -X" -text "25"
-button "OK" -button "Cancel"
-defaultButton "OK" -cancelButton "Cancel"
-dismissString "Cancel"`;
if($result == "OK") {
$angle = float(`promptDialog -query -text`);
selectByAngle(-1, 0, 0, $angle);
string $message = "Select <span style='color:#0ff'>-</span><span style='color:#f00'>X</span>" + string($angle) + "°";
inViewMessage -msg $message -fade -fit 00 -fst 1000 -fot 1000 -pos midCenterTop -fts 30 -bkc 0x000000;
}
}
dial();Ditto -Y.
proc selectByAngle(float $x, float $y, float $z, float $a) {
SelectFacetMask;
resetPolySelectConstraint;
polySelectConstraint -m 3;
polySelectConstraint -t 8 -a 1 -o 1 -oa $x $y $z -ob 0 $a;
polySelectConstraint -m 0;
resetPolySelectConstraint;
}
proc dial() {
string $result = `promptDialog -title "Select -Y" -text "25"
-button "OK" -button "Cancel"
-defaultButton "OK" -cancelButton "Cancel"
-dismissString "Cancel"`;
if($result == "OK") {
$angle = float(`promptDialog -query -text`);
selectByAngle(0, -1, 0, $angle);
string $message = "Select <span style='color:#0ff'>-</span><span style='color:#0f0'>Y</span>" + string($angle) + "°";
inViewMessage -msg $message -fade -fit 00 -fst 1000 -fot 1000 -pos midCenterTop -fts 30 -bkc 0x000000;
}
}
dial();Ditto -Z.
proc selectByAngle(float $x, float $y, float $z, float $a) {
SelectFacetMask;
resetPolySelectConstraint;
polySelectConstraint -m 3;
polySelectConstraint -t 8 -a 1 -o 1 -oa $x $y $z -ob 0 $a;
polySelectConstraint -m 0;
resetPolySelectConstraint;
}
proc dial() {
string $result = `promptDialog -title "Select -Z" -text "25"
-button "OK" -button "Cancel"
-defaultButton "OK" -cancelButton "Cancel"
-dismissString "Cancel"`;
if($result == "OK") {
$angle = float(`promptDialog -query -text`);
selectByAngle(0, 0, -1, $angle);
string $message = "Select <span style='color:#0ff'>-</span><span style='color:#00f'>Z</span>" + string($angle) + "°";
inViewMessage -msg $message -fade -fit 00 -fst 1000 -fot 1000 -pos midCenterTop -fts 30 -bkc 0x000000;
}
}
dial();Ditto for facing the perspective camera.
proc selectByAngle(float $x, float $y, float $z, float $a) {
SelectFacetMask;
resetPolySelectConstraint;
polySelectConstraint -m 3;
polySelectConstraint -t 8 -a 1 -o 1 -oa $x $y $z -ob 0 $a;
polySelectConstraint -m 0;
resetPolySelectConstraint;
}
proc dial() {
string $result = `promptDialog -title "Select -X" -text "25"
-button "OK" -button "Cancel"
-defaultButton "OK" -cancelButton "Cancel"
-dismissString "Cancel"`;
if($result == "OK") {
$angle = float(`promptDialog -query -text`);
float $mat[] = `xform -q -ws -m persp`;
vector $v = <<$mat[8], $mat[9], $mat[10]>>;
selectByAngle($v.x, $v.y, $v.z, $angle);
string $message = "Select Facing Camera " + string($angle) + "°";
inViewMessage -msg $message -fade -fit 00 -fst 1000 -fot 1000 -pos midCenterTop -fts 30 -bkc 0x000000;
}
}
dial();From the currently selected components, select only a certain % randomly, input window popup for %.
proc selectRandom(int $percentage) {
if(`selectMode -q -object`) inViewMessage -msg "Must be in component selection" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
else {
string $sel[];
if(`selectType -q -fc`) $sel = getFaces();
if(`selectType -q -v`) $sel = getVerts();
if(`selectType -q -eg`) $sel = getEdges();
string $newSel[];
for ($i=1; $i < 20; $i++) {
for($item in $sel) {
int $num = rand(0, 100);
if($num < $percentage && size($newSel) < size($sel)*$percentage/100) $newSel[size($newSel)] = $item;
}
}
select $newSel;
string $message = "Select " + string($percentage) + "%";
inViewMessage -msg $message -fade -fit 00 -fst 1000 -fot 1000 -pos midCenterTop -fts 30 -bkc 0x000000;
}
}
proc dialp() {
string $result = `promptDialog -title "Select Percentage" -text "50"
-button "OK" -button "Cancel"
-defaultButton "OK" -cancelButton "Cancel"
-dismissString "Cancel"`;
if($result == "OK") {
$percentage = int(`promptDialog -query -text`);
if($percentage > 0 && $percentage < 100) selectRandom($percentage);
}
}
dialp();Select smooth edges.
SelectEdgeMask;
resetPolySelectConstraint;
polySelectConstraint -m 3;
polySelectConstraint -t 32768 -sm 2 -w 2;
polySelectConstraint -m 0;
resetPolySelectConstraint;
inViewMessage -msg "Select Smooth Edges" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;Select hard edges.
SelectEdgeMask;
resetPolySelectConstraint;
polySelectConstraint -m 3;
polySelectConstraint -t 32768 -sm 1 -w 2;
polySelectConstraint -m 0;
resetPolySelectConstraint;
inViewMessage -msg "Select Hard Edges" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;Select inside(non-border) edges.
SelectEdgeMask;
resetPolySelectConstraint;
polySelectConstraint -m 3;
polySelectConstraint -t 32768 -w 2;
polySelectConstraint -m 0;
resetPolySelectConstraint;
inViewMessage -msg "Select Inside Edges" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;Select border edges.
SelectEdgeMask;
resetPolySelectConstraint;
polySelectConstraint -m 3;
polySelectConstraint -t 32768 -w 1;
polySelectConstraint -m 0;
resetPolySelectConstraint;
inViewMessage -msg "Select Border Edges" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;Select all faces facing the same direction, input window popup for angle tolerance.
proc selectSameAngle(float $difAng) {
$difAngDeg = $difAng;
$difAng = 3.14*($difAng/180);
string $obj[] = `ls -hl`;
string $faces[] = `ls -sl -flatten`;
string $normal[] = `polyInfo -fn $faces[0]`;
string $selNormal = `substitute "[A-Z]*_[A-Z]* *[0-9]*: " $normal[0] ""`;
string $buff[];
tokenize $selNormal " " $buff;
float $xG = $buff[0]; float $yG = $buff[1]; float $zG = $buff[2];
vector $G = <<$xG, $yG, $zG>>;
string $curSelection[] = `ls -hl`;
float $selXform[] = `xform -q -m -ws $curSelection[0]`;
float $axis[] = {(float)$xG, (float)$yG, (float)$zG };
float $worldAxis[] = pointMatrixMult($axis, $selXform);
$xG = $worldAxis[0];
$yG = $worldAxis[1];
$zG = $worldAxis[2];
select $obj[0];
ConvertSelectionToFaces;
polySelectConstraint -t 0x0008 -m 3 -o 1 -oa $xG $yG $zG -ob 0 $difAngDeg;
$faces = `ls -sl`;
resetPolySelectConstraint;
print($G);
hilite $obj[0];
select $faces;
}
proc dial() {
string $result = `promptDialog -title "Select Same Angle" -m "Angle" -text "3"
-button "OK" -button "Cancel"
-defaultButton "OK" -cancelButton "Cancel"
-dismissString "Cancel"`;
if($result == "OK") {
$angle = float(`promptDialog -query -text`);
selectSameAngle($angle);
string $message = "Select Same Angle " + string($angle) + "°";
inViewMessage -msg $message -fade -fit 00 -fst 1000 -fot 1000 -pos midCenterTop -fts 30 -bkc 0x000000;
}
}
resetPolySelectConstraint;
dial();Ditto but continuous - meaning only the faces connected to the current one.
proc selectSameAngleCont(float $difAng) {
$difAngDeg = $difAng;
$difAng = 3.14*($difAng/180);
string $obj[] = `ls -hl`;
string $faces[] = `ls -sl -flatten`;
string $normal[] = `polyInfo -fn $faces[0]`;
string $selNormal = `substitute "[A-Z]*_[A-Z]* *[0-9]*: " $normal[0] ""`;
string $buff[];
tokenize $selNormal " " $buff;
float $xG = $buff[0]; float $yG = $buff[1]; float $zG = $buff[2];
vector $G = <<$xG, $yG, $zG>>;
int $ex=0;
int $safeVal=0;
int $cykl=0;
while($ex==0 && $safeVal<= 200 && $cykl==0){
$safeVal++;
$ex=1;
select $faces;
polySelectConstraint -pp 1;
string $gS[] = `ls -sl -flatten`;
select -d $faces;
string $facesB[] = `ls -sl -flatten`;
string $difference[] = $facesB;
for($newFace in $difference){
string $normalTemp[] = `polyInfo -fn $newFace`;
string $selNormalTemp = `substitute "[A-Z]*_[A-Z]* *[0-9]*: " $normalTemp[0] ""`;
tokenize $selNormalTemp " " $buff;
float $xN = $buff[0]; float $yN = $buff[1]; float $zN = $buff[2];
vector $N = <<$xN, $yN, $zN>>;
if(angle($N, $G) <= $difAng) {
$faces[size($faces)] = $newFace;
$ex=0;
}
}
}
hilite $obj[0];
select $faces;
}
proc dial() {
string $result = `promptDialog -title "Select Same Angle" -m "Angle" -text "3"
-button "OK" -button "Cancel"
-defaultButton "OK" -cancelButton "Cancel"
-dismissString "Cancel"`;
if($result == "OK") {
$angle = float(`promptDialog -query -text`);
selectSameAngleCont($angle);
string $message = "Select Same Angle Continuous " + string($angle) + "°";
inViewMessage -msg $message -fade -fit 00 -fst 1000 -fot 1000 -pos midCenterTop -fts 30 -bkc 0x000000;
}
}
resetPolySelectConstraint;
dial();Attempts to select non-geometry-contributing(stray) vertices.
SelectVertexMask;
resetPolySelectConstraint;
polySelectConstraint -m 3;
polySelectConstraint -t 1 -a 1 -ab 178 182;
polySelectConstraint -m 0;
resetPolySelectConstraint;
inViewMessage -msg "Select Stray Verts" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;Selects every 2nd edge in a ring.
polySelectEdgesEveryN "edgeRing" 2;
inViewMessage -msg "Ring 2" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;Ditto but every 3rd.
polySelectEdgesEveryN "edgeRing" 3;
inViewMessage -msg "Ring 3" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;Ditto but every 4th.
polySelectEdgesEveryN "edgeRing" 4;
inViewMessage -msg "Ring 4" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;Selects every 2nd edge in a loop.
polySelectEdgesEveryN "edgeLoop" 2;
inViewMessage -msg "Loop 2" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;Ditto but every 3rd.
polySelectEdgesEveryN "edgeLoop" 3;
inViewMessage -msg "Loop 3" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;Ditto but every 4th.
polySelectEdgesEveryN "edgeLoop" 4;
inViewMessage -msg "Loop 4" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;Create a cube, input window popup for size.
proc quickCube() {
string $result = `promptDialog -title "Create Cube" -text "10" -button "OK" -button "Cancel" -defaultButton "OK" -cancelButton "Cancel" -dismissString "Cancel"`;
if($result == "OK") {
$size = float(`promptDialog -query -text`);
string $message = "Cube " + string($size);
inViewMessage -msg $message -fade -fit 00 -fst 1000 -fot 1000 -pos midCenterTop -fts 30 -bkc 0x000000;
string $newCube = (`polyCube -ch on -o on -w $size -h $size -d $size -cuv 4`);
select $newCube;
}
}
quickCube();Create a cylinder, input window popups for radius, height, subdivisions.
proc quickCylinder() {
float $radius = 0.0;
float $height = 0.0;
int $subdivs = 0;
string $result1 = `promptDialog -title "Create Cylinder" -m "Radius" -text "5" -button "OK" -button "Cancel" -defaultButton "OK" -cancelButton "Cancel" -dismissString "Cancel"`;
if($result1 == "OK") $radius = float(`promptDialog -query -text`);
string $result2 = `promptDialog -title "Create Cylinder" -m "Height" -text "10" -button "OK" -button "Cancel" -defaultButton "OK" -cancelButton "Cancel" -dismissString "Cancel"`;
if($result2 == "OK") $height = float(`promptDialog -query -text`);
string $result3 = `promptDialog -title "Create Cylinder" -m "Subdivs" -text "16" -button "OK" -button "Cancel" -defaultButton "OK" -cancelButton "Cancel" -dismissString "Cancel"`;
if($result3 == "OK") $subdivs = float(`promptDialog -query -text`);
if($radius != 0) if($height != 0) if($subdivs != 0) {
string $message2 = "Cylinder R" + string($radius) + " H" + string($height) + " S" + string($subdivs);
inViewMessage -msg $message2 -fade -fit 00 -fst 1000 -fot 1000 -pos midCenterTop -fts 30 -bkc 0x000000;
string $newCyl = (`polyCylinder -ch on -o on -r $radius -h $height -sx $subdivs -sc 1 -cuv 3`);
select $newCyl;
}
}
quickCylinder();Create a plane, input window popups for width and length.
proc quickPlane() {
float $width = 0.0;
float $length = 0.0;
string $result1 = `promptDialog -title "Create Plane" -m "Width" -text "10" -button "OK" -button "Cancel" -defaultButton "OK" -cancelButton "Cancel" -dismissString "Cancel"`;
if($result1 == "OK") $width = float(`promptDialog -query -text`);
string $result2 = `promptDialog -title "Create Plane" -m "Length" -text "10" -button "OK" -button "Cancel" -defaultButton "OK" -cancelButton "Cancel" -dismissString "Cancel"`;
if($result2 == "OK") $length = float(`promptDialog -query -text`);
if($width != 0) if($length != 0) {
string $message2 = "Plane W" + string($width) + " L" + string($length);
inViewMessage -msg $message2 -fade -fit 00 -fst 1000 -fot 1000 -pos midCenterTop -fts 30 -bkc 0x000000;
string $newPlane = (`polyPlane -ch on -o on -w $width -h $length -sw 1 -sh 1 -cuv 2`);
select $newPlane;
}
}
quickPlane();Create a sphere, input window popups for radius and subdivisions.
proc quickSphere() {
float $radius = 0.0;
int $sx = 0;
int $sy = 0;
string $result1 = `promptDialog -title "Create Sphere" -m "Radius" -text "10" -button "OK" -button "Cancel" -defaultButton "OK" -cancelButton "Cancel" -dismissString "Cancel"`;
if($result1 == "OK") $radius = float(`promptDialog -query -text`);
string $result2 = `promptDialog -title "Create Sphere" -m "Subdivs Axis" -text "16" -button "OK" -button "Cancel" -defaultButton "OK" -cancelButton "Cancel" -dismissString "Cancel"`;
if($result2 == "OK") $sx = int(`promptDialog -query -text`);
string $result3 = `promptDialog -title "Create Sphere" -m "Subdivs Height" -text "16" -button "OK" -button "Cancel" -defaultButton "OK" -cancelButton "Cancel" -dismissString "Cancel"`;
if($result3 == "OK") $sy = int(`promptDialog -query -text`);
if($radius != 0) if($sx != 0) if($sy != 0) {
string $message2 = "Sphere R" + string($radius) + " X" + string($sx) + " Y" + string($sy);
inViewMessage -msg $message2 -fade -fit 00 -fst 1000 -fot 1000 -pos midCenterTop -fts 30 -bkc 0x000000;
string $newSphere = (`polySphere -ch on -o on -r $radius -sx $sx -sy $sy`);
select $newSphere;
}
}
quickSphere();Move selected components a specific amount in the custom pivot X direction, input window popup for amount.
proc customMoveX() {
float $amount = 0.0;
string $result1 = `promptDialog -title "Relative Custom Move X" -m "Amount" -text "0" -button "OK" -button "Cancel" -defaultButton "OK" -cancelButton "Cancel" -dismissString "Cancel"`;
if($result1 == "OK") $amount = float(`promptDialog -query -text`);
if($amount != 0) {
string $message2 = "Relative Custom Move <span style='color:#f00'>X</span> " + string($amount);
inViewMessage -msg $message2 -fade -fit 00 -fst 1000 -fot 1000 -pos midCenterTop -fts 30 -bkc 0x000000;
vector $tra = `dR_getTransformValues`;
$tra = <<$tra.x+($amount*100), $tra.y, $tra.z>>;
dR_setTransformValue 0 ($tra.x);
}
}
customMoveX();Ditto but Y.
proc customMoveY() {
float $amount = 0.0;
string $result1 = `promptDialog -title "Relative Custom Move Y" -m "Amount" -text "0" -button "OK" -button "Cancel" -defaultButton "OK" -cancelButton "Cancel" -dismissString "Cancel"`;
if($result1 == "OK") $amount = float(`promptDialog -query -text`);
if($amount != 0) {
string $message2 = "Relative Custom Move <span style='color:#0f0'>Y</span> " + string($amount);
inViewMessage -msg $message2 -fade -fit 00 -fst 1000 -fot 1000 -pos midCenterTop -fts 30 -bkc 0x000000;
vector $tra = `dR_getTransformValues`;
$tra = <<$tra.x, $tra.y+($amount*100), $tra.z>>;
dR_setTransformValue 1 ($tra.y);
}
}
customMoveY();Ditto but Z.
proc customMoveZ() {
float $amount = 0.0;
string $result1 = `promptDialog -title "Relative Custom Move Z" -m "Amount" -text "0" -button "OK" -button "Cancel" -defaultButton "OK" -cancelButton "Cancel" -dismissString "Cancel"`;
if($result1 == "OK") $amount = float(`promptDialog -query -text`);
if($amount != 0) {
string $message2 = "Relative Custom Move <span style='color:#00f'>Z</span> " + string($amount);
inViewMessage -msg $message2 -fade -fit 00 -fst 1000 -fot 1000 -pos midCenterTop -fts 30 -bkc 0x000000;
vector $tra = `dR_getTransformValues`;
$tra = <<$tra.x, $tra.y, $tra.z+($amount*100)>>;
dR_setTransformValue 2 ($tra.z);
}
}
customMoveZ();Ditto but all directions.
proc customMoveAll() {
float $amountX = 0.0;
string $result1 = `promptDialog -title "Relative Custom Move X" -m "Amount X" -text "0" -button "OK" -button "Cancel" -defaultButton "OK" -cancelButton "Cancel" -dismissString "Cancel"`;
if($result1 == "OK") $amountX = float(`promptDialog -query -text`);
float $amountY = 0.0;
string $result2 = `promptDialog -title "Relative Custom Move Y" -m "Amount Y" -text "0" -button "OK" -button "Cancel" -defaultButton "OK" -cancelButton "Cancel" -dismissString "Cancel"`;
if($result2 == "OK") $amountY = float(`promptDialog -query -text`);
float $amountZ = 0.0;
string $result3 = `promptDialog -title "Relative Custom Move Z" -m "Amount Z" -text "0" -button "OK" -button "Cancel" -defaultButton "OK" -cancelButton "Cancel" -dismissString "Cancel"`;
if($result3 == "OK") $amountZ = float(`promptDialog -query -text`);
if($amountX != 0 || $amountY != 0 || $amountZ != 0) {
string $message2 = "Relative Custom Move <span style='color:#f00'>X</span> " + string($amountX) + " / <span style='color:#0f0'>Y</span> " + string($amountY) + " / <span style='color:#00f'>Z</span> " + string($amountZ);
inViewMessage -msg $message2 -fade -fit 00 -fst 1000 -fot 1000 -pos midCenterTop -fts 30 -bkc 0x000000;
vector $tra = `dR_getTransformValues`;
$tra = <<$tra.x+($amountX*100), $tra.y+($amountY*100), $tra.z+($amountZ*100)>>;
dR_setTransformValue 0 ($tra.x);
dR_setTransformValue 1 ($tra.y);
dR_setTransformValue 2 ($tra.z);
}
}
customMoveAll();Scale selected components to 0 on X axis, takes into account custom pivot.
if(!`selectMode -q -object`) {
string $currentToolActive = `currentCtx`;
ScaleTool;
dR_setTransformValue 0 0;
setToolTo $currentToolActive;
inViewMessage -msg "Flatten <span style='color:#f00'>X</span>" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
}Ditto but Y.
if(!`selectMode -q -object`) {
string $currentToolActive = `currentCtx`;
ScaleTool;
dR_setTransformValue 1 0;
setToolTo $currentToolActive;
inViewMessage -msg "Flatten <span style='color:#0f0'>Y</span>" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
}Ditto but Z.
if(!`selectMode -q -object`) {
string $currentToolActive = `currentCtx`;
ScaleTool;
dR_setTransformValue 2 0;
setToolTo $currentToolActive;
inViewMessage -msg "Flatten <span style='color:#00f'>Z</span>" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
}Ditto but Y and Z.
if(!`selectMode -q -object`) {
string $currentToolActive = `currentCtx`;
ScaleTool;
dR_setTransformValue 1 0;
dR_setTransformValue 2 0;
setToolTo $currentToolActive;
inViewMessage -msg "Flatten <span style='color:#0f0'>Y</span><span style='color:#00f'>Z</span>" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
}Ditto but Z and X.
if(!`selectMode -q -object`) {
string $currentToolActive = `currentCtx`;
ScaleTool;
dR_setTransformValue 0 0;
dR_setTransformValue 2 0;
setToolTo $currentToolActive;
inViewMessage -msg "Flatten <span style='color:#00f'>Z</span><span style='color:#f00'>X</span>" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
}Ditto but X and Y.
if(!`selectMode -q -object`) {
string $currentToolActive = `currentCtx`;
ScaleTool;
dR_setTransformValue 0 0;
dR_setTransformValue 1 0;
setToolTo $currentToolActive;
inViewMessage -msg "Flatten <span style='color:#f00'>X</span><span style='color:#0f0'>Y</span>" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
}Rotate selected components 90° on X axis, takes into account custom pivot.
string $currentToolActive = `currentCtx`;
RotateTool;
dR_setTransformValue 0 90;
setToolTo $currentToolActive;
inViewMessage -msg "Rotate 90 <span style='color:#f00'>X</span>" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;Ditto but Y.
string $currentToolActive = `currentCtx`;
RotateTool;
dR_setTransformValue 1 90;
setToolTo $currentToolActive;
inViewMessage -msg "Rotate 90 <span style='color:#0f0'>Y</span>" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;Ditto but Z.
string $currentToolActive = `currentCtx`;
RotateTool;
dR_setTransformValue 2 90;
setToolTo $currentToolActive;
inViewMessage -msg "Rotate 90 <span style='color:#00f'>Z</span>" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;Rotates the current component selection so that the custom pivot is aligned with the world ground plane.
proc StraightenToGround2() {
string $currentToolActive = `currentCtx`;
$p = `manipPivot -q -o`;
RotateTool;
dR_setTransformValue 2 (270-$p[2]);
dR_setTransformValue 1 (-$p[1]);
dR_setTransformValue 0 (-$p[0]);
setToolTo $currentToolActive;
inViewMessage -msg "Straighten" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
}
if(`selectMode -q -object`) inViewMessage -msg "must be in component selection" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
else if(`selectType -q -v` || `selectType -q -eg` || `selectType -q -fc`) StraightenToGround2();Flip selected components on X axis, takes into account custom pivot.
if(!`selectMode -q -object`) {
string $currentToolActive = `currentCtx`;
ScaleTool;
dR_setTransformValue 0 -1;
ReversePolygonNormals;
setToolTo $currentToolActive;
inViewMessage -msg "Flip <span style='color:#f00'>X</span>" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
}Ditto but Y.
if(!`selectMode -q -object`) {
string $currentToolActive = `currentCtx`;
ScaleTool;
dR_setTransformValue 1 -1;
ReversePolygonNormals;
setToolTo $currentToolActive;
inViewMessage -msg "Flip <span style='color:#0f0'>Y</span>" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
}Ditto but Z.
if(!`selectMode -q -object`) {
string $currentToolActive = `currentCtx`;
ScaleTool;
dR_setTransformValue 2 -1;
ReversePolygonNormals;
setToolTo $currentToolActive;
inViewMessage -msg "Flip <span style='color:#00f'>Z</span>" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
}Break or detach components (but not into a separate object) based on context. If mouse is hovering UV editor - it either splits selected UVs or creates a UV shell from selected faces. Requires ClearHistory.
if(`getPanel -wf` == "polyTexturePlacementPanel1") {
if(`selectType -q -puv` || `selectType -q -eg`) {
polySplitTextureUV;
inViewMessage -msg "Break UVs" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
}
else if(`selectType -q -fc`||`selectType -q -smu`||`selectType -q -msh`) {
createUVShellAlongBorder;
inViewMessage -msg "Split UV Shell" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
}
}
else if(!`selectMode -q -object`) {
ClearHistory;
string $objs[] = `ls -o -sl`;
if(size($objs)==1) performDetachComponents;
else {
changeSelectMode -object;
string $objs2[] = `ls -o -sl`;
string $prevsel;
if(`selectType -q -v`) {
$prevsel = "v";
select(`filterExpand -sm 31`);
}
else if(`selectType -q -eg`) {
$prevsel = "eg";
select(`filterExpand -sm 32`);
}
else if(`selectType -q -fc`) {
$prevsel = "fc";
select(`filterExpand -sm 34`);
}
for($item in $objs) {
changeSelectMode -object;
select $item;
if($prevsel == "v") SelectVertexMask;
else if($prevsel == "eg") SelectEdgeMask;
else if($prevsel == "fc") SelectFacetMask;
performDetachComponents;
}
select $objs2;
if($prevsel == "v") SelectVertexMask;
else if($prevsel == "eg") SelectEdgeMask;
else if($prevsel == "fc") SelectFacetMask;
}
ClearHistory;
inViewMessage -msg "Break" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
}Activates target weld tool but deselects all vertices first - so you don't weld all of them to the target.
SelectVertexMask;
select -cl;
setToolTo polyMergeVertexContext;
inViewMessage -msg "Target Weld" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;Merges all vertices of selected objects.
{
string $currentToolActive = `currentCtx`;
string $prevsel = "";
if(`selectType -q -v`) $prevsel = "v";
else if(`selectType -q -eg`) $prevsel = "eg";
else if(`selectType -q -fc`) $prevsel = "fc";
else if(`selectType -q -puv`) $prevsel = "puv";
else if(`selectType -q -smu`||`selectType -q -msh`) $prevsel = "smu";
SelectVertexMask;
dR_selectAll;
PolyMergeVertices;
changeSelectMode -object;
DeleteHistory;
if($prevsel == "v") SelectVertexMask;
else if($prevsel == "eg") SelectEdgeMask;
else if($prevsel == "fc") SelectFacetMask;
else if($prevsel == "puv") SelectUVMask;
else if($prevsel == "smu") UVToolkitUVShellModeCB;
select -cl;
setToolTo $currentToolActive;
inViewMessage -msg "Merge All Verts" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
}Connects vertices by connecting the rest to the first selected one. Track selection order must be enabled in maya settings.
string $vertsSplit[] = `ls -os`;
int $count = `size($vertsSplit)`;
for ($i=1; $i < $count; $i++) {
select $vertsSplit[0];
select -tgl $vertsSplit[$i];
polyConnectComponents;
}
select $vertsSplit[0];
Inserts a vertex into the middle of the currently selected edge.
performPolySubdivide "" 0;
MoveTool;
ConvertSelectionToVertices;
inViewMessage -msg "Divide Edges" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;Collapse or UV sew edges, works across multiple objects. Requires ClearHistory.
if(`selectMode -q -object`) inViewMessage -msg "must be in edge selection" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
else if(`selectType -q -eg`) {
ClearHistory;
string $objs[] = `ls -o -sl`;
changeSelectMode -object;
string $objs2[] = `ls -o -sl`;
SelectEdgeMask;
int $count = `size($objs)`;
if(`getPanel -wf` == "polyTexturePlacementPanel1") {
for($item in $objs) {
changeSelectMode -object;
select $item;
dR_DoCmd("modeEdge");
SewUVs;
}
select $objs2;
ClearHistory;
select $objs2;
SelectEdgeMask;
inViewMessage -msg "Sew Edges" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
}
else {
for($item in $objs) {
changeSelectMode -object;
select $item;
dR_DoCmd("modeEdge");
polyCollapseEdge;
}
select $objs2;
ClearHistory;
select $objs2;
SelectEdgeMask;
select -cl;
inViewMessage -msg "Collapse Edges" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
}
}
else inViewMessage -msg "must be in edge selection" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;Bridge edges or faces, but works with multiple objects selected (but doesn't bridge between different objects). Note that it can only bridge 2 sets of faces per object. Requires ClearHistory.
{
if(`selectMode -q -object`) inViewMessage -msg "must be in edge selection" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
else if(`selectType -q -eg`) {
ClearHistory;
string $sele[] = `ls -sl`;
select -cl;
changeSelectMode -object;
SelectEdgeMask;
select $sele;
string $objs[] = `ls -o -sl`;
changeSelectMode -object;
string $objs2[] = `ls -o -sl`;
SelectEdgeMask;
int $count = `size($objs)`;
for ($item in $objs) {
changeSelectMode -object;
select $item;
dR_DoCmd("modeEdge");
BridgeEdge;
}
select $objs2;
SelectEdgeMask;
select -cl;
inViewMessage -msg "Bridge Edges" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
}
else if(`selectType -q -fc`) {
string $sele[] = `filterExpand -sm 34`;
print(" AAAAAAAAAAAAAAAAAAAAAA \n");
print($sele);
print(" AAAAAAAAAAAAAAAAAAAAAA \n");
select -cl;
changeSelectMode -object;
SelectFacetMask;
select $sele;
string $objs[] = `ls -o -sl`;
changeSelectMode -object;
string $objs2[] = `ls -o -sl`;
SelectFacetMask;
select $sele;
int $count = `size($objs)`;
for ($item in $objs) {
changeSelectMode -object;
select $item;
SelectFacetMask;
polyBridgeFaces;
}
select $objs2;
SelectFacetMask;
select -cl;
inViewMessage -msg "Bridge Faces" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
}
else inViewMessage -msg "must be in edge selection" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
}Bevels currently selected edges.
performBevelOrChamfer;
inViewMessage -msg "Bevel" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;Fills a hole within selected edges, triangulates, then quadrangulates it.
FillHole;
ConvertSelectionToContainedFaces;
polyPerformAction polyTriangulate f 0;
polyPerformAction "polyQuad -a 30 -kgb 1 -ktb 1 -khe 1 -ws 1" f 0;Rotates and scales selected vertices/edges/faces to create 45° corners, but the custom pivot must be set to the corner edge around which this rotation should happen.
proc corner() {
string $ifv2 = `selectType -q -v`;
if(`selectMode -q -object`) print("");
else if(`selectType -q -v` || `selectType -q -eg` || `selectType -q -fc`) {
string $currentToolActive = `currentCtx`;
ScaleTool;
dR_setTransformValue 0 1.414213562373095;
RotateTool;
dR_setTransformValue 1 45;
setToolTo $currentToolActive;
if($ifv2) SelectVertexMask;
else SelectEdgeMask;
inViewMessage -msg "Corner <span style='color:#ff0'>45</span>" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
}
}
corner();Ditto but rotates in the opposite direction.
proc corner() {
string $ifv2 = `selectType -q -v`;
if(`selectMode -q -object`) print("");
else if(`selectType -q -v` || `selectType -q -eg` || `selectType -q -fc`) {
string $currentToolActive = `currentCtx`;
ScaleTool;
dR_setTransformValue 0 1.414213562373095;
RotateTool;
dR_setTransformValue 1 -45;
setToolTo $currentToolActive;
if($ifv2) SelectVertexMask;
else SelectEdgeMask;
inViewMessage -msg "Corner <span style='color:#0ff'>-45</span>" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
}
}
corner();Ditto but displays input box for a custom angle.
proc anyCorner() {
string $ifv2 = `selectType -q -v`;
if(`selectMode -q -object`) print("");
else if(`selectType -q -v` || `selectType -q -eg` || `selectType -q -fc`) {
float $angle = 0.0;
string $result1 = `promptDialog -title "Corner Angle" -m "Angle" -text "0" -button "OK" -button "Cancel" -defaultButton "OK" -cancelButton "Cancel" -dismissString "Cancel"`;
if($result1 == "OK") $angle = float(`promptDialog -query -text`);
if($angle != 0 && $angle < 90) {
string $currentToolActive = `currentCtx`;
ScaleTool;
float $tf = 1/cos(deg_to_rad($angle));
dR_setTransformValue 0 $tf;
RotateTool;
dR_setTransformValue 1 $angle;
setToolTo $currentToolActive;
if($ifv2) SelectVertexMask;
else SelectEdgeMask;
string $message = "Corner Angle <span style='color:#ff0'>" + string($angle) + "</span>";
inViewMessage -msg $message -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
}
}
}
anyCorner();Same as regular triangulate but should work across multiple objects. Requires ClearHistory.
if(`selectMode -q -object`) inViewMessage -msg "must be in face selection" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
else if(`selectType -q -fc`) {
ClearHistory;
string $objs[] = `ls -o -sl`;
changeSelectMode -object;
string $objs2[] = `ls -o -sl`;
SelectFacetMask;
int $count = `size($objs)`;
for($item in $objs) {
changeSelectMode -object;
select $item;
SelectFacetMask;
Triangulate;
}
select $objs2;
ClearHistory;
select $objs2;
SelectFacetMask;
select -cl;
inViewMessage -msg "Triangulate" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
}
else inViewMessage -msg "must be in face selection" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;Same as regular quadrangulate but should work across multiple objects. Requires ClearHistory.
if(`selectMode -q -object`) inViewMessage -msg "must be in face selection" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
else if(`selectType -q -fc`) {
ClearHistory;
string $objs[] = `ls -o -sl`;
changeSelectMode -object;
string $objs2[] = `ls -o -sl`;
SelectFacetMask;
int $count = `size($objs)`;
for($item in $objs) {
changeSelectMode -object;
select $item;
SelectFacetMask;
Quadrangulate;
}
select $objs2;
ClearHistory;
select $objs2;
SelectFacetMask;
select -cl;
inViewMessage -msg "Quadrangulate" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
}
else inViewMessage -msg "must be in face selection" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;Scales the current component selection so the bounding box matches the input values. Inputting 0 or measuring 0 skips scaling an axis. Forces world pivot (since bounding boxes are world oriented) and scales centered on current pivot position.
proc SetExactBoundingBox(float $x, float $y, float $z) {
string $currentToolActive = `currentCtx`;
manipMoveContext -e -mode 2 Move;
manipRotateContext -e -mode 1 Rotate;
manipScaleContext -e -mode 2 Scale;
ScaleTool;
$bb = `exactWorldBoundingBox`;
float $ox = abs(float($bb[0]-$bb[3]));
float $p[] = { float(($bb[0]+$bb[3])/2), float(($bb[1]+$bb[4])/2), float(($bb[2]+$bb[5])/2) };
$p = `manipMoveContext -q -p Move`;
if($x != 0 && $ox != 0) dR_setTransformValue 0 ($x/$ox);
else $x = $ox;
float $oy = abs(float($bb[1]-$bb[4]));
if($y != 0 && $oy != 0) dR_setTransformValue 1 ($y/$oy);
else $y = $oy;
float $oz = abs(float($bb[2]-$bb[5]));
if($z != 0 && $oz != 0) dR_setTransformValue 2 ($z/$oz);
else $z = $oz;
string $message2 = "Set Bounding Box <span style='color:#f00'>X</span> " + string($x) + " / <span style='color:#0f0'>Y</span> " + string($y) + " / <span style='color:#00f'>Z</span> " + string($z);
inViewMessage -msg $message2 -fade -fit 00 -fst 1000 -fot 1000 -pos midCenterTop -fts 30 -bkc 0x000000;
setToolTo $currentToolActive;
}
if(!`selectMode -q -object`) {
float $amountX = 0.0;
string $result1 = `promptDialog -title "Set Bounding Box X" -m "Size X" -text "0" -button "OK" -button "Cancel" -defaultButton "OK" -cancelButton "Cancel" -dismissString "Cancel"`;
if($result1 == "OK") $amountX = float(`promptDialog -query -text`);
float $amountY = 0.0;
string $result2 = `promptDialog -title "Set Bounding Boxe Y" -m "Size Y" -text "0" -button "OK" -button "Cancel" -defaultButton "OK" -cancelButton "Cancel" -dismissString "Cancel"`;
if($result2 == "OK") $amountY = float(`promptDialog -query -text`);
float $amountZ = 0.0;
string $result3 = `promptDialog -title "Set Bounding Box Z" -m "Size Z" -text "0" -button "OK" -button "Cancel" -defaultButton "OK" -cancelButton "Cancel" -dismissString "Cancel"`;
if($result3 == "OK") $amountZ = float(`promptDialog -query -text`);
SetExactBoundingBox($amountX, $amountY, $amountZ);
}
else inViewMessage -msg "must be in component selection" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;Transforms currently selected vertices in their normal direction (local translate z) by the input amount. Works across multiple objects. Requires ClearHistory.
proc TransformLocalZ(float $amount) {
ClearHistory;
string $objs[] = `ls -o -sl`;
changeSelectMode -object;
string $objs2[] = `ls -o -sl`;
SelectVertexMask;
for($item in $objs) {
changeSelectMode -object;
select $item;
SelectVertexMask;
polyMoveVertex -ltz $amount -ch true;
}
changeSelectMode -object;
select $objs2;
ClearHistory;
SelectVertexMask;
string $message = "Transform Local <span style='color:#00f'>Z</span> " + string($amount);
inViewMessage -msg $message -fade -fit 00 -fst 1000 -fot 1000 -pos midCenterTop -fts 30 -bkc 0x000000;
}
proc dial() {
string $result = `promptDialog -title "Push Vertices" -text "-0.04" -button "OK" -button "Cancel" -defaultButton "OK" -cancelButton "Cancel" -dismissString "Cancel"`;
if($result == "OK") {
$amount = float(`promptDialog -query -text`);
TransformLocalZ($amount);
}
}
if(!`selectMode -q -object` && `selectType -q -v`) dial();
else inViewMessage -msg "must be in vertex selection" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;Disables transform constraints.
dR_DoCmd("slideOff");
inViewMessage -msg "Constraint None" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;Enables edge transform constraint.
dR_DoCmd("slideEdge");
inViewMessage -msg "Constraint Edge" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;Enables surface transform constraint.
dR_DoCmd("slideSurface");
inViewMessage -msg "Constraint Surface" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;Toggles preserve uv, permanent inview message stays on screen until toggled off.
setTRSPreserveUVs(!`optionVar -q trsManipsPreserveUvs`);
if(`optionVar -q trsManipsPreserveUvs`)
inViewMessage -msg "<span style='color:#ff0'>Preserve UV ON</span>" -pos midRight -fts 30 -fof 0 -bkc 0x330000;
else
inViewMessage -msg "<span style='color:#0ff'>Preserve UV OFF</span>" -fade -fit 00 -fst 200 -fot 800 -pos midRight -fts 30 -fof 0 -bkc 0x000033;Do multi-cut YZ plane slice.
if(`selectMode -q -object`) SelectVertexMask;
dR_multiCutTool;
dr_polyCut(0);
inViewMessage -msg "Slice <span style='color:#0f0'>Y</span><span style='color:#00f'>Z</span>" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;Ditto but ZX.
if(`selectMode -q -object`) SelectVertexMask;
dR_multiCutTool;
dr_polyCut(1);
inViewMessage -msg "Slice <span style='color:#00f'>Z</span><span style='color:#f00'>X</span>" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;Ditto but XY.
if(`selectMode -q -object`) SelectVertexMask;
dR_multiCutTool;
dr_polyCut(2);
inViewMessage -msg "Slice <span style='color:#f00'>X</span><span style='color:#0f0'>Y</span>" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;Instantly XY plane slice selected objects based on the currently selected vertex. Works across multiple objects.
proc qSlice(string $axis) {
if(`selectMode -q -object`) inViewMessage -msg "must select 1 vertex" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
else if(`selectType -q -v`) {
string $selected[] = `ls -sl`;
if(size($selected)!=1) inViewMessage -msg "must select 1 vertex" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
else {
float $aaa[] = `xform -q -ws -t`;
changeSelectMode -object;
string $objs[] = `ls -o -sl`;
int $count = `size($objs)`;
for($item in $objs) {
changeSelectMode -object;
select $item;
dR_DoCmd("modeVert");
dR_selectAll;
string $cutp[] = `polyCut -ws 1 -cd $axis -ch 1 -df 0 -oo false -ps 10000 10000`;
setAttr ($cutp[0]+".cutPlaneCenter") -type double3 $aaa[0] $aaa[1] $aaa[2];
}
select $objs;
SelectVertexMask;
select $selected[0];
string $msgg = "Quick Slice ";
if($axis=="x") $msgg+="<span style='color:#0f0'>Y</span><span style='color:#00f'>Z</span>";
else if($axis=="y") $msgg+="<span style='color:#00f'>Z</span><span style='color:#f00'>X</span>";
else if($axis=="z") $msgg+="<span style='color:#f00'>X</span><span style='color:#0f0'>Y</span>";
inViewMessage -msg $msgg -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
}
}
}
qSlice("z");Ditto but ZX.
proc qSlice(string $axis) {
if(`selectMode -q -object`) inViewMessage -msg "must select 1 vertex" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
else if(`selectType -q -v`) {
string $selected[] = `ls -sl`;
if(size($selected)!=1) inViewMessage -msg "must select 1 vertex" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
else {
float $aaa[] = `xform -q -ws -t`;
changeSelectMode -object;
string $objs[] = `ls -o -sl`;
int $count = `size($objs)`;
for($item in $objs) {
changeSelectMode -object;
select $item;
dR_DoCmd("modeVert");
dR_selectAll;
string $cutp[] = `polyCut -ws 1 -cd $axis -ch 1 -df 0 -oo false -ps 10000 10000`;
setAttr ($cutp[0]+".cutPlaneCenter") -type double3 $aaa[0] $aaa[1] $aaa[2];
}
select $objs;
SelectVertexMask;
select $selected[0];
string $msgg = "Quick Slice ";
if($axis=="x") $msgg+="<span style='color:#0f0'>Y</span><span style='color:#00f'>Z</span>";
else if($axis=="y") $msgg+="<span style='color:#00f'>Z</span><span style='color:#f00'>X</span>";
else if($axis=="z") $msgg+="<span style='color:#f00'>X</span><span style='color:#0f0'>Y</span>";
inViewMessage -msg $msgg -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
}
}
}
qSlice("y");Ditto but YZ.
proc qSlice(string $axis) {
if(`selectMode -q -object`) inViewMessage -msg "must select 1 vertex" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
else if(`selectType -q -v`) {
string $selected[] = `ls -sl`;
if(size($selected)!=1) inViewMessage -msg "must select 1 vertex" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
else {
float $aaa[] = `xform -q -ws -t`;
changeSelectMode -object;
string $objs[] = `ls -o -sl`;
int $count = `size($objs)`;
for($item in $objs) {
changeSelectMode -object;
select $item;
dR_DoCmd("modeVert");
dR_selectAll;
string $cutp[] = `polyCut -ws 1 -cd $axis -ch 1 -df 0 -oo false -ps 10000 10000`;
setAttr ($cutp[0]+".cutPlaneCenter") -type double3 $aaa[0] $aaa[1] $aaa[2];
}
select $objs;
SelectVertexMask;
select $selected[0];
string $msgg = "Quick Slice ";
if($axis=="x") $msgg+="<span style='color:#0f0'>Y</span><span style='color:#00f'>Z</span>";
else if($axis=="y") $msgg+="<span style='color:#00f'>Z</span><span style='color:#f00'>X</span>";
else if($axis=="z") $msgg+="<span style='color:#f00'>X</span><span style='color:#0f0'>Y</span>";
inViewMessage -msg $msgg -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
}
}
}
qSlice("x");Instantly plane slice selected objects based on the currently selected face. Works across multiple objects.
proc customSlice() {
if(`selectMode -q -object`) inViewMessage -msg "must select 1 face" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
else if(`selectType -q -fc`) {
string $selected[] = `ls -sl`;
if(size($selected)!=1) inViewMessage -msg "must select 1 face" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
else {
float $aaa[] = `xform -q -ws -t`;
string $norm[] = `polyInfo -fn $selected`;
string $buffer[];
int $numTokens = `tokenize $norm[0] $buffer`;
vector $normvec = <<float($buffer[2]), float($buffer[3]), float($buffer[4])>>;
vector $angleb = `angleBetween -euler -v1 0.0 0.0 1.0 -v2 $buffer[2] $buffer[3] $buffer[4]`;
float $var1[6] = `polyEvaluate -bc`;
vector $center = <<(($var1[0]+$var1[1])/2), (($var1[2]+$var1[3])/2), (($var1[4]+$var1[5])/2)>>;
changeSelectMode -object;
string $objs[] = `ls -o -sl`;
int $count = `size($objs)`;
for($item in $objs) {
changeSelectMode -object;
select $item;
dR_DoCmd("modePoly");
dR_selectAll;
select -d $selected[0];
string $cutp[] = `polyCut -ws 1 -ro ($angleb.x) ($angleb.y) ($angleb.z) -ch 1 -df 0 -oo false -ps 10000 10000`;
setAttr ($cutp[0]+".cutPlaneCenter") -type double3 (($var1[0]+$var1[1])/2) (($var1[2]+$var1[3])/2) (($var1[4]+$var1[5])/2);
}
select $objs;
SelectFacetMask;
select $selected[0];
inViewMessage -msg "Custom Slice" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
}
}
}
customSlice();Set the normals of currently selected vertices to face +X.
polyNormalPerVertex -xyz 1 0 0;
inViewMessage -msg "Set Normal <span style='color:#ff0'>+</span><span style='color:#f00'>X</span>" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;Ditto but +Y.
polyNormalPerVertex -xyz 0 1 0;
inViewMessage -msg "Set Normal <span style='color:#ff0'>+</span><span style='color:#0f0'>Y</span>" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;Ditto but +Z.
polyNormalPerVertex -xyz 0 0 1;
inViewMessage -msg "Set Normal <span style='color:#ff0'>+</span><span style='color:#00f'>Z</span>" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;Ditto but -X.
polyNormalPerVertex -xyz -1 0 0;
inViewMessage -msg "Set Normal <span style='color:#0ff'>-</span><span style='color:#f00'>X</span>" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;Ditto but -Y.
polyNormalPerVertex -xyz 0 -1 0;
inViewMessage -msg "Set Normal <span style='color:#0ff'>-</span><span style='color:#0f0'>Y</span>" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;Ditto but -Z.
polyNormalPerVertex -xyz 0 0 -1;
inViewMessage -msg "Set Normal <span style='color:#0ff'>-</span><span style='color:#00f'>Z</span>" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;Bend the normals of currently selected vertices towards +X.
proc nBendAxis(float $x, float $y, float $z, float $bias) {
string $selected[] = `ls -os -long -fl`;
float $vertFaceNormal[] = { $x, $y, $z };
for ($i = 0; $i < size($selected); $i++) {
float $arrayX[] = `polyNormalPerVertex -q -x $selected[$i]`;
float $summedX = 0.0; for($value in $arrayX) { $summedX += $value; }
float $averageX = $summedX/size($arrayX);
float $newX = (($vertFaceNormal[0] * $bias) + ($averageX * (1.0 - $bias))) / 2;
float $arrayY[] = `polyNormalPerVertex -q -y $selected[$i]`;
float $summedY = 0.0; for($value in $arrayY) { $summedY += $value; }
float $averageY = $summedY/size($arrayY);
float $newY = (($vertFaceNormal[1] * $bias) + ($averageY * (1.0 - $bias))) / 2;
float $arrayZ[] = `polyNormalPerVertex -q -z $selected[$i]`;
float $summedZ = 0.0; for($value in $arrayZ) { $summedZ += $value; }
float $averageZ = $summedZ/size($arrayZ);
float $newZ = (($vertFaceNormal[2] * $bias) + ($averageZ * (1.0 - $bias))) / 2;
polyNormalPerVertex -x $newX -y $newY -z $newZ $selected[$i];
}
}
nBendAxis(1, 0, 0, 0.1);
inViewMessage -msg "Normal Bend <span style='color:#ff0'>+</span><span style='color:#f00'>X</span>" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;Ditto but +Y.
proc nBendAxis(float $x, float $y, float $z, float $bias) {
string $selected[] = `ls -os -long -fl`;
float $vertFaceNormal[] = { $x, $y, $z };
for ($i = 0; $i < size($selected); $i++) {
float $arrayX[] = `polyNormalPerVertex -q -x $selected[$i]`;
float $summedX = 0.0; for($value in $arrayX) { $summedX += $value; }
float $averageX = $summedX/size($arrayX);
float $newX = (($vertFaceNormal[0] * $bias) + ($averageX * (1.0 - $bias))) / 2;
float $arrayY[] = `polyNormalPerVertex -q -y $selected[$i]`;
float $summedY = 0.0; for($value in $arrayY) { $summedY += $value; }
float $averageY = $summedY/size($arrayY);
float $newY = (($vertFaceNormal[1] * $bias) + ($averageY * (1.0 - $bias))) / 2;
float $arrayZ[] = `polyNormalPerVertex -q -z $selected[$i]`;
float $summedZ = 0.0; for($value in $arrayZ) { $summedZ += $value; }
float $averageZ = $summedZ/size($arrayZ);
float $newZ = (($vertFaceNormal[2] * $bias) + ($averageZ * (1.0 - $bias))) / 2;
polyNormalPerVertex -x $newX -y $newY -z $newZ $selected[$i];
}
}
nBendAxis(0, 1, 0, 0.1);
inViewMessage -msg "Normal Bend <span style='color:#ff0'>+</span><span style='color:#0f0'>Y</span>" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;Ditto but +Z.
proc nBendAxis(float $x, float $y, float $z, float $bias) {
string $selected[] = `ls -os -long -fl`;
float $vertFaceNormal[] = { $x, $y, $z };
for ($i = 0; $i < size($selected); $i++) {
float $arrayX[] = `polyNormalPerVertex -q -x $selected[$i]`;
float $summedX = 0.0; for($value in $arrayX) { $summedX += $value; }
float $averageX = $summedX/size($arrayX);
float $newX = (($vertFaceNormal[0] * $bias) + ($averageX * (1.0 - $bias))) / 2;
float $arrayY[] = `polyNormalPerVertex -q -y $selected[$i]`;
float $summedY = 0.0; for($value in $arrayY) { $summedY += $value; }
float $averageY = $summedY/size($arrayY);
float $newY = (($vertFaceNormal[1] * $bias) + ($averageY * (1.0 - $bias))) / 2;
float $arrayZ[] = `polyNormalPerVertex -q -z $selected[$i]`;
float $summedZ = 0.0; for($value in $arrayZ) { $summedZ += $value; }
float $averageZ = $summedZ/size($arrayZ);
float $newZ = (($vertFaceNormal[2] * $bias) + ($averageZ * (1.0 - $bias))) / 2;
polyNormalPerVertex -x $newX -y $newY -z $newZ $selected[$i];
}
}
nBendAxis(0, 0, 1, 0.1);
inViewMessage -msg "Normal Bend <span style='color:#ff0'>+</span><span style='color:#00f'>Z</span>" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;Ditto but -X.
proc nBendAxis(float $x, float $y, float $z, float $bias) {
string $selected[] = `ls -os -long -fl`;
float $vertFaceNormal[] = { $x, $y, $z };
for ($i = 0; $i < size($selected); $i++) {
float $arrayX[] = `polyNormalPerVertex -q -x $selected[$i]`;
float $summedX = 0.0; for($value in $arrayX) { $summedX += $value; }
float $averageX = $summedX/size($arrayX);
float $newX = (($vertFaceNormal[0] * $bias) + ($averageX * (1.0 - $bias))) / 2;
float $arrayY[] = `polyNormalPerVertex -q -y $selected[$i]`;
float $summedY = 0.0; for($value in $arrayY) { $summedY += $value; }
float $averageY = $summedY/size($arrayY);
float $newY = (($vertFaceNormal[1] * $bias) + ($averageY * (1.0 - $bias))) / 2;
float $arrayZ[] = `polyNormalPerVertex -q -z $selected[$i]`;
float $summedZ = 0.0; for($value in $arrayZ) { $summedZ += $value; }
float $averageZ = $summedZ/size($arrayZ);
float $newZ = (($vertFaceNormal[2] * $bias) + ($averageZ * (1.0 - $bias))) / 2;
polyNormalPerVertex -x $newX -y $newY -z $newZ $selected[$i];
}
}
nBendAxis(-1, 0, 0, 0.1);
inViewMessage -msg "Normal Bend <span style='color:#0ff'>-</span><span style='color:#f00'>X</span>" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;Ditto but -Y.
proc nBendAxis(float $x, float $y, float $z, float $bias) {
string $selected[] = `ls -os -long -fl`;
float $vertFaceNormal[] = { $x, $y, $z };
for ($i = 0; $i < size($selected); $i++) {
float $arrayX[] = `polyNormalPerVertex -q -x $selected[$i]`;
float $summedX = 0.0; for($value in $arrayX) { $summedX += $value; }
float $averageX = $summedX/size($arrayX);
float $newX = (($vertFaceNormal[0] * $bias) + ($averageX * (1.0 - $bias))) / 2;
float $arrayY[] = `polyNormalPerVertex -q -y $selected[$i]`;
float $summedY = 0.0; for($value in $arrayY) { $summedY += $value; }
float $averageY = $summedY/size($arrayY);
float $newY = (($vertFaceNormal[1] * $bias) + ($averageY * (1.0 - $bias))) / 2;
float $arrayZ[] = `polyNormalPerVertex -q -z $selected[$i]`;
float $summedZ = 0.0; for($value in $arrayZ) { $summedZ += $value; }
float $averageZ = $summedZ/size($arrayZ);
float $newZ = (($vertFaceNormal[2] * $bias) + ($averageZ * (1.0 - $bias))) / 2;
polyNormalPerVertex -x $newX -y $newY -z $newZ $selected[$i];
}
}
nBendAxis(0, -1, 0, 0.1);
inViewMessage -msg "Normal Bend <span style='color:#0ff'>-</span><span style='color:#0f0'>Y</span>" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;Ditto but -Z.
proc nBendAxis(float $x, float $y, float $z, float $bias) {
string $selected[] = `ls -os -long -fl`;
float $vertFaceNormal[] = { $x, $y, $z };
for ($i = 0; $i < size($selected); $i++) {
float $arrayX[] = `polyNormalPerVertex -q -x $selected[$i]`;
float $summedX = 0.0; for($value in $arrayX) { $summedX += $value; }
float $averageX = $summedX/size($arrayX);
float $newX = (($vertFaceNormal[0] * $bias) + ($averageX * (1.0 - $bias))) / 2;
float $arrayY[] = `polyNormalPerVertex -q -y $selected[$i]`;
float $summedY = 0.0; for($value in $arrayY) { $summedY += $value; }
float $averageY = $summedY/size($arrayY);
float $newY = (($vertFaceNormal[1] * $bias) + ($averageY * (1.0 - $bias))) / 2;
float $arrayZ[] = `polyNormalPerVertex -q -z $selected[$i]`;
float $summedZ = 0.0; for($value in $arrayZ) { $summedZ += $value; }
float $averageZ = $summedZ/size($arrayZ);
float $newZ = (($vertFaceNormal[2] * $bias) + ($averageZ * (1.0 - $bias))) / 2;
polyNormalPerVertex -x $newX -y $newY -z $newZ $selected[$i];
}
}
nBendAxis(0, 0, -1, 0.1);
inViewMessage -msg "Normal Bend <span style='color:#0ff'>-</span><span style='color:#00f'>Z</span>" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;Averages and flattens normals on X axis. Split hard edges beforehand to preserve them.
proc nFlattenAxis(float $x, float $y, float $z) {
string $selected[] = `ls -os -long -fl`;
for ($i = 0; $i < size($selected); $i++) {
float $arrayX[] = `polyNormalPerVertex -q -x $selected[$i]`;
float $summedX = 0.0; for($value in $arrayX) { $summedX += $value; }
float $averageX = $summedX/size($arrayX);
float $newX = $averageX * $x;
float $arrayY[] = `polyNormalPerVertex -q -y $selected[$i]`;
float $summedY = 0.0; for($value in $arrayY) { $summedY += $value; }
float $averageY = $summedY/size($arrayY);
float $newY = $averageY * $y;
float $arrayZ[] = `polyNormalPerVertex -q -z $selected[$i]`;
float $summedZ = 0.0; for($value in $arrayZ) { $summedZ += $value; }
float $averageZ = $summedZ/size($arrayZ);
float $newZ = $averageZ * $z;
polyNormalPerVertex -x $newX -y $newY -z $newZ $selected[$i];
}
}
nFlattenAxis(0, 1, 1);
inViewMessage -msg "Normal Flatten <span style='color:#f00'>X</span>" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;Ditto but Y.
proc nFlattenAxis(float $x, float $y, float $z) {
string $selected[] = `ls -os -long -fl`;
for ($i = 0; $i < size($selected); $i++) {
float $arrayX[] = `polyNormalPerVertex -q -x $selected[$i]`;
float $summedX = 0.0; for($value in $arrayX) { $summedX += $value; }
float $averageX = $summedX/size($arrayX);
float $newX = $averageX * $x;
float $arrayY[] = `polyNormalPerVertex -q -y $selected[$i]`;
float $summedY = 0.0; for($value in $arrayY) { $summedY += $value; }
float $averageY = $summedY/size($arrayY);
float $newY = $averageY * $y;
float $arrayZ[] = `polyNormalPerVertex -q -z $selected[$i]`;
float $summedZ = 0.0; for($value in $arrayZ) { $summedZ += $value; }
float $averageZ = $summedZ/size($arrayZ);
float $newZ = $averageZ * $z;
polyNormalPerVertex -x $newX -y $newY -z $newZ $selected[$i];
}
}
nFlattenAxis(1, 0, 1);
inViewMessage -msg "Normal Flatten <span style='color:#0f0'>Y</span>" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;Ditto but Z.
proc nFlattenAxis(float $x, float $y, float $z) {
string $selected[] = `ls -os -long -fl`;
for ($i = 0; $i < size($selected); $i++) {
float $arrayX[] = `polyNormalPerVertex -q -x $selected[$i]`;
float $summedX = 0.0; for($value in $arrayX) { $summedX += $value; }
float $averageX = $summedX/size($arrayX);
float $newX = $averageX * $x;
float $arrayY[] = `polyNormalPerVertex -q -y $selected[$i]`;
float $summedY = 0.0; for($value in $arrayY) { $summedY += $value; }
float $averageY = $summedY/size($arrayY);
float $newY = $averageY * $y;
float $arrayZ[] = `polyNormalPerVertex -q -z $selected[$i]`;
float $summedZ = 0.0; for($value in $arrayZ) { $summedZ += $value; }
float $averageZ = $summedZ/size($arrayZ);
float $newZ = $averageZ * $z;
polyNormalPerVertex -x $newX -y $newY -z $newZ $selected[$i];
}
}
nFlattenAxis(1, 1, 0);
inViewMessage -msg "Normal Flatten <span style='color:#00f'>Z</span>" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;Increases size of displayed normals for selected objects.
proc nSizeUp() {
float $cn[] = `polyOptions -q -sn`;
polyOptions -sn ($cn[0]*1.4);
inViewMessage -msg ("Normals Size " + string($cn[0]*1.2)) -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
}
nSizeUp();Decreases size of displayed normals for selected objects.
proc nSizeDown() {
float $cn[] = `polyOptions -q -sn`;
polyOptions -sn ($cn[0]*0.7);
inViewMessage -msg ("Normals Size " + string($cn[0]*1.2)) -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
}
nSizeDown();Copies the normal of the first selected vertex to all others. Track selection order must be enabled in maya settings.
proc nBend(float $bias) {
string $selected[] = `ls -os -long -fl`;
if (size($selected) < 2) { error "Please select at least two vertices!"; }
float $vertFaceNormal[] = `polyNormalPerVertex -q -xyz $selected[0]`;
for ($i = 1; $i < size($selected); $i++) {
float $arrayX[] = `polyNormalPerVertex -q -x $selected[$i]`;
float $summedX = 0.0; for($value in $arrayX) { $summedX += $value; }
float $averageX = $summedX/size($arrayX);
float $newX = (($vertFaceNormal[0] * $bias) + ($averageX * (1.0 - $bias))) / 2;
float $arrayY[] = `polyNormalPerVertex -q -y $selected[$i]`;
float $summedY = 0.0; for($value in $arrayY) { $summedY += $value; }
float $averageY = $summedY/size($arrayY);
float $newY = (($vertFaceNormal[1] * $bias) + ($averageY * (1.0 - $bias))) / 2;
float $arrayZ[] = `polyNormalPerVertex -q -z $selected[$i]`;
float $summedZ = 0.0; for($value in $arrayZ) { $summedZ += $value; }
float $averageZ = $summedZ/size($arrayZ);
float $newZ = (($vertFaceNormal[2] * $bias) + ($averageZ * (1.0 - $bias))) / 2;
polyNormalPerVertex -x $newX -y $newY -z $newZ $selected[$i];
}
inViewMessage -msg "1st Normal To All" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
}
nBend(1.0);Bends the vertex normals to approach the normal of the first selected vertex. Unfortunately neighboring vertex normals are set to the same normal so split normals are not preserved. Track selection order must be enabled in maya settings.
proc nBend(float $bias) {
string $selected[] = `ls -os -long -fl`;
if (size($selected) < 2) { error "Please select at least two vertices!"; }
float $vertFaceNormal[] = `polyNormalPerVertex -q -xyz $selected[0]`;
for ($i = 1; $i < size($selected); $i++) {
float $arrayX[] = `polyNormalPerVertex -q -x $selected[$i]`;
float $summedX = 0.0; for($value in $arrayX) { $summedX += $value; }
float $averageX = $summedX/size($arrayX);
float $newX = (($vertFaceNormal[0] * $bias) + ($averageX * (1.0 - $bias))) / 2;
float $arrayY[] = `polyNormalPerVertex -q -y $selected[$i]`;
float $summedY = 0.0; for($value in $arrayY) { $summedY += $value; }
float $averageY = $summedY/size($arrayY);
float $newY = (($vertFaceNormal[1] * $bias) + ($averageY * (1.0 - $bias))) / 2;
float $arrayZ[] = `polyNormalPerVertex -q -z $selected[$i]`;
float $summedZ = 0.0; for($value in $arrayZ) { $summedZ += $value; }
float $averageZ = $summedZ/size($arrayZ);
float $newZ = (($vertFaceNormal[2] * $bias) + ($averageZ * (1.0 - $bias))) / 2;
polyNormalPerVertex -x $newX -y $newY -z $newZ $selected[$i];
}
inViewMessage -msg "Normal Bend" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
}
nBend(0.1);Transfers normals from one mesh to another.
transferAttributes -transferPositions 0 -transferNormals 1 -transferUVs 0 -transferColors 0 -sampleSpace 0 -searchMethod 3 -flipUVs 0 -colorBorders 1;Softens and hardens edges based on the angle in input window popup.
proc autoSmooth() {
float $angle = 0.0;
string $result1 = `promptDialog -title "Auto Smooth" -m "Angle" -text "30" -button "OK" -button "Cancel" -defaultButton "OK" -cancelButton "Cancel" -dismissString "Cancel"`;
if($result1 == "OK") $angle = float(`promptDialog -query -text`);
if($angle != 0) {
string $message2 = "Auto Smooth " + string($angle) + "°";
inViewMessage -msg $message2 -fade -fit 00 -fst 1000 -fot 1000 -pos midCenterTop -fts 30 -bkc 0x000000;
polySoftEdge -a $angle;
}
}
autoSmooth();Hardens UV shell border edges and softens the rest.
UVToolkitEdgeModeCB;
SelectEdgeMask;
dR_selectAll;
UnlockNormals;
PolygonSoftenEdge;
SelectUVBorderComponents;
PolygonHardenEdge;Creates a lattice based on the context - in object mode creates lattice for the entire object, in component mode for selected components, in uv editor for selected uvs. Also should go into lattice point selection mode, but it doesn't work the first time you run it for some reason. Requires ClearHistory.
if(`selectMode -q -object`) {
ClearHistory;
CreateLattice;
isolateSelectAutoAddCallback;
doMenuLatticeComponentSelection("ffd1Lattice", "latticePoint");
}
else if(`getPanel -wf` == "polyTexturePlacementPanel1") LatticeUVTool;
else {
ClearHistory;
CreateLattice;
isolateSelectAutoAddCallback;
doMenuLatticeComponentSelection("ffd1Lattice", "latticePoint");
}
inViewMessage -msg "Lattice" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;Ditto but opens the lattice options window. Requires ClearHistory.
if(`getPanel -wf` == "polyTexturePlacementPanel1") LatticeUVToolOptions;
else {
ClearHistory;
CreateLatticeOptions;
}
inViewMessage -msg "Lattice" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;Detaches faces into a new object, selects the new object, and remains in face selection mode. Works across multiple objects.
proc string detachFaces() {
string $nameSplitSkip[];
string $faceNum[];
string $temp[];
string $newObj[];
string $newFaceSel[];
string $origFaceSel[] = `filterExpand -ex 1 -sm 34`;
string $origObjShape[] = `listRelatives -p -f $origFaceSel`;
string $origObj[] = `listRelatives -p -f $origObjShape`;
for($step = 0, $skip = 0; $step < size($origFaceSel); $step++, $skip++) {
tokenize $origFaceSel[$step] "." $temp;
$nameSplitSkip[$skip] = $temp[0];
$skip++;
$nameSplitSkip[$skip] = $temp[1];
clear $temp;
}
for($step2 = 0, $skip2 = 1; $step2 < (size($nameSplitSkip)/2); $step2++, $skip2 = $skip2 + 2) $faceNum[$step2] = $nameSplitSkip[$skip2];
$newObj = `duplicate -un $origObj[0]`;
delete -ch $newObj[0];
string $newAllFaces[] = `ls ($newObj[0] + ".f[*]")`;
for($step3 = 0; $step3 < size($faceNum); $step3++) $newFaceSel[$step3] = ($newObj[0] + "." + $faceNum[$step3]);
delete $origFaceSel;
select -r $newAllFaces;
select -d $newFaceSel;
string $finalFaceSel[] = `filterExpand -ex 1 -sm 34`;
delete;
if(size($finalFaceSel)==0) delete $origObj;
return $newObj[0];
}
proc iterateObjs() {
string $objs[] = `ls -o -sl`;
if(size($objs)==0) {
inViewMessage -msg "No selected faces" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
return;
}
string $selobjs[];
if(size($objs)==1) {
$selobjs[0] = detachFaces();
}
else {
for($obj in $objs) {
changeSelectMode -object;
select $obj;
SelectFacetMask;
$selobjs[size($selobjs)] = detachFaces();
}
}
select $selobjs;
SelectFacetMask;
dR_selectAll;
inViewMessage -msg "Detach Faces" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
}
if(`selectMode -q -object`) inViewMessage -msg "Must be in face selection" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
else if(`selectType -q -fc` || `selectType -q -msh` || `selectType -q -smu`) {
select `filterExpand -ex 1 -sm 34`;
iterateObjs();
}
else inViewMessage -msg "Must be in face selection" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;Separates current object into elements(or shells) and deletes history.
performPolyShellSeparate;
DeleteHistory;Combines objects, while retaining name, place in hierarchy(but not order), pivot of the first selected object. Deletes history. Track selection order must be enabled in maya settings. Also reattaches resulting shape to any instances of the first object, preserving all instances.
proc CombineObjectsRedux() {
string $objs[] = `ls -o -sl`;
if(`selectMode -q -object` && size($objs)>1) {
select -d $objs[0];
ConvertInstanceToObject;
select $objs[0];
string $name[];
$numTokens = tokenize($objs[0], "|", $name);
int $cn = 0;
select -cl;
for($item in $objs) {
select -add $item;
rename $item ("tempprecombobj"+$cn);
$cn += 1;
}
$objs = `ls -o -sl`;
select $objs[0];
string $firstparent[] = `listRelatives -p -f`;
string $rels[] = `listRelatives -s $objs[0]`;
select -cl;
string $objs3[] = `ls -o -sl`;
string $relofs[] = `listRelatives -allParents $rels[0]`;
select $relofs;
select -d $objs[0];
$objs3 = `ls -o -sl`;
if(size($relofs)>1) for($item in $objs) {
select $item;
ConvertInstanceToObject;
}
float $tX = `getAttr ($objs[0]+".translateX")`; float $tY = `getAttr ($objs[0]+".translateY")`; float $tZ = `getAttr ($objs[0]+".translateZ")`;
string $combobjtemp[] = `polyCube -n ("combobjtemp"+$objs[0])`;
setAttr ($combobjtemp[0]+".translateX") $tX; setAttr ($combobjtemp[0]+".translateY") $tY; setAttr ($combobjtemp[0]+".translateZ") $tZ;
select -add $objs[0];
optionVar -iv matchRotPivot 1; optionVar -iv matchScalePivot 1; optionVar -iv matchPivotOrient 1;
performMatchPivots 0;
DeleteHistory;
select $objs;
CombinePolygons;
rename ("combinedobjtemp"+$objs[0]);
string $objfinal[] = `ls -o -sl`;
if(size($firstparent[0])!=0) parent $objfinal[0] $firstparent[0];
move -r -ws -moveXYZ (-$tX) (-$tY) (-$tZ);
performFreezeTransformations(0);
performResetTransformations(0);
DeleteHistory;
setAttr ($objfinal[0]+".translateX") $tX; setAttr ($objfinal[0]+".translateY") $tY; setAttr ($objfinal[0]+".translateZ") $tZ;
select -add $combobjtemp[0];
performMatchPivots 0;
if(size($relofs)>1) {
string $relsnew[] = `listRelatives -s`;
for($item in $objs3) {
select $item;
string $oldrels[] = `listRelatives -s`;
delete $oldrels;
parent -add -shape $relsnew[0];
}
}
delete $combobjtemp[0];
if(`objExists $objs[0]`) delete $objs[0];
rename $objfinal[0] $name[size($name)-1];
for($item in $objs) if(`objExists $item`) if($item != $name[size($name)-1]) delete $item;
select $name[size($name)-1];
inViewMessage -msg "Combine Objects" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
}
else inViewMessage -msg "Must be in object mode with multiple objects selected." -fade -fit 00 -fst 400 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
}
CombineObjectsRedux();Duplicates objects or faces depending on object or face selection mode. Requires ClearHistory. Separate duplicated faces must be disabled in duplicate face options.
if(`selectMode -q -object`) {
string $objs[] = `ls -o -sl`;
if(size($objs)>0) {
Duplicate;
inViewMessage -msg "Duplicate Objects" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
}
else inViewMessage -msg "No objects selected." -fade -fit 00 -fst 400 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
}
else if(`selectType -q -fc`||`selectType -q -smu`||`selectType -q -msh`) {
if(`selectType -q -smu`||`selectType -q -msh`) {
select(`filterExpand -sm 34`);
SelectFacetMask;
}
string $currentToolActive = `currentCtx`;
ClearHistory;
constructionHistory -toggle false;
DuplicateFace;
ClearHistory;
constructionHistory -toggle true;
setToolTo $currentToolActive;
inViewMessage -msg "Duplicate Faces" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
}
else inViewMessage -msg "must be in object or face mode" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;Duplicates objects as instances.
if(`selectMode -q -object`) {
instance;
inViewMessage -msg "Duplicate Objects as Instance" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
}
else inViewMessage -msg "must be in object mode" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;Forces the pivot into component mode.
manipMoveContext -e -mode 10 Move;
manipRotateContext -e -mode 10 Rotate;
manipScaleContext -e -mode 10 Scale;Ditto but world.
manipMoveContext -e -mode 2 Move;
manipRotateContext -e -mode 1 Rotate;
manipScaleContext -e -mode 2 Scale;Ditto but world and resets the pivot as well.
manipMoveContext -e -mode 2 Move;
manipRotateContext -e -mode 1 Rotate;
manipScaleContext -e -mode 2 Scale;
manipPivot -rp -ro;Centers pivot and puts it at the bottom of each selected object.
if(`selectMode -q -object`) {
ClearHistory;
string $objs[] = `ls -o -sl`;
changeSelectMode -object;
string $objs2[] = `ls -o -sl`;
int $count = `size($objs)`;
for($item in $objs) {
select $item;
float $bb[];
float $pivots[];
CenterPivot;
$bb = `xform -q -ws -a -bb`;
$pivots = `xform -q -ws -a -piv`;
xform -ws -a -piv $pivots[0] $bb[1] $pivots[2];
}
select $objs2;
ClearHistory;
select $objs2;
inViewMessage -msg "Pivot Center Bottom" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
}
else inViewMessage -msg "must be in object selection" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;Resets pivot for the object, as in going into the move tool settings and resetting pivot there. Not to be confused with resetting custom pivot.
{ string $objs[] = `ls -sl -type transform -type geometryShape`;if (size($objs) > 0) { xform -cp; } manipPivot -rp -ro; };Freezes and resets transforms, and deletes history.
changeSelectMode -object;
manipMoveContext -e -mode 2 Move;
manipRotateContext -e -mode 1 Rotate;
manipScaleContext -e -mode 2 Scale;
manipPivot -rp -ro;
performFreezeTransformations(0);
performResetTransformations(0);
delete -ch;
inViewMessage -msg "Freeze / Reset / Clear History" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;Freezes and resets transforms, put the pivot at the bottom of the object and deletes history. Requires clear history.
{
changeSelectMode -object;
manipMoveContext -e -mode 2 Move;
manipRotateContext -e -mode 1 Rotate;
manipScaleContext -e -mode 2 Scale;
manipPivot -rp -ro;
performFreezeTransformations(0);
CenterPivot;
if(`selectMode -q -object`) {
ClearHistory;
string $objs[] = `ls -o -sl`;
changeSelectMode -object;
string $objs2[] = `ls -o -sl`;
int $count = `size($objs)`;
for($item in $objs) {
select $item;
float $bb[];
float $pivots[];
CenterPivot;
$bb = `xform -q -ws -a -bb`;
$pivots = `xform -q -ws -a -piv`;
xform -ws -a -piv $pivots[0] $bb[1] $pivots[2];
}
select $objs2;
ClearHistory;
select $objs2;
inViewMessage -msg "Pivot Center Bottom" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
}
inViewMessage -msg "Freeze / Center Bottom / Clear History" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
}Deletes history but works even in component mode. Required for some other scripts here.
proc ClearHistoryImproved() {
if(`selectMode -q -object`) DeleteHistory;
else {
string $prevsel = "";
if(`selectType -q -v`) {
$prevsel = "v";
select(`filterExpand -sm 31`);
}
else if(`selectType -q -eg`) {
$prevsel = "eg";
select(`filterExpand -sm 32`);
}
else if(`selectType -q -fc`) {
$prevsel = "fc";
select(`filterExpand -sm 34`);
}
else if(`selectType -q -puv`) {
$prevsel = "puv";
select(`filterExpand -sm 35`);
}
else if(`selectType -q -smu`||`selectType -q -msh`) $prevsel = "smu";
string $sele[] = `ls -sl`;
changeSelectMode -object;
DeleteHistory;
if($prevsel == "v") SelectVertexMask;
else if($prevsel == "eg") SelectEdgeMask;
else if($prevsel == "fc") SelectFacetMask;
else if($prevsel == "puv") SelectUVMask;
else if($prevsel == "smu") UVToolkitUVShellModeCB;
select $sele;
}
}
ClearHistoryImproved();
inViewMessage -msg "Clear History" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;Align objects or elements within 1 object to the average X position.
proc AlignMidImproved(string $axis) {
string $objs[] = `ls -o -sl`;
if(`selectMode -q -object`) {
if(size($objs)>1) {
if($axis=="x") align -x Mid;
else if($axis=="y") align -y Mid;
else if($axis=="z") align -z Mid;
string $msgg = "Align Objects ";
if($axis=="x") $msgg += "<span style='color:#f00'>X</span>";
else if($axis=="y") $msgg += "<span style='color:#0f0'>Y</span>";
else if($axis=="z") $msgg += "<span style='color:#00f'>Z</span>";
inViewMessage -msg $msgg -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
}
if(size($objs)==1) {
performFreezeTransformations(0);
float $tX = `getAttr ($objs[0]+".translateX")`; float $tY = `getAttr ($objs[0]+".translateY")`; float $tZ = `getAttr ($objs[0]+".translateZ")`;
string $combobjtemp[] = `polyCube -n ("combobjtmp"+$objs[0])`;
setAttr ($combobjtemp[0]+".translateX") $tX; setAttr ($combobjtemp[0]+".translateY") $tY; setAttr ($combobjtemp[0]+".translateZ") $tZ;
select -add $objs[0];
optionVar -iv matchRotPivot 1; optionVar -iv matchScalePivot 1; optionVar -iv matchPivotOrient 1;
performMatchPivots 0;
DeleteHistory;
select $objs;
performPolyShellSeparate;
DeleteHistory;
if($axis=="x") align -x Mid;
else if($axis=="y") align -y Mid;
else if($axis=="z") align -z Mid;
select $objs[0];
string $name[];
$numTokens = tokenize($objs[0], "|", $name);
string $firstparent[] = `listRelatives -p -f`;
select $objs;
CombinePolygons;
string $objfinal[] = `ls -o -sl`;
if(size($firstparent[0])!=0) parent $objfinal[0] $firstparent[0];
$objfinal = `ls -o -sl`;
DeleteHistory;
move -r -ws -moveXYZ (-$tX) (-$tY) (-$tZ);
setAttr ($objfinal[0]+".translateX") $tX; setAttr ($objfinal[0]+".translateY") $tY; setAttr ($objfinal[0]+".translateZ") $tZ;
select -add $combobjtemp[0];
performMatchPivots 0;
delete $combobjtemp[0];
rename $objfinal[0] $name[size($name)-1];
string $msgg = "Align Elements within Object ";
if($axis=="x") $msgg += "<span style='color:#f00'>X</span>";
else if($axis=="y") $msgg += "<span style='color:#0f0'>Y</span>";
else if($axis=="z") $msgg += "<span style='color:#00f'>Z</span>";
inViewMessage -msg $msgg -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
}
}
}
AlignMidImproved("x");Ditto but Y.
proc AlignMidImproved(string $axis) {
string $objs[] = `ls -o -sl`;
if(`selectMode -q -object`) {
if(size($objs)>1) {
if($axis=="x") align -x Mid;
else if($axis=="y") align -y Mid;
else if($axis=="z") align -z Mid;
string $msgg = "Align Objects ";
if($axis=="x") $msgg += "<span style='color:#f00'>X</span>";
else if($axis=="y") $msgg += "<span style='color:#0f0'>Y</span>";
else if($axis=="z") $msgg += "<span style='color:#00f'>Z</span>";
inViewMessage -msg $msgg -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
}
if(size($objs)==1) {
performFreezeTransformations(0);
float $tX = `getAttr ($objs[0]+".translateX")`; float $tY = `getAttr ($objs[0]+".translateY")`; float $tZ = `getAttr ($objs[0]+".translateZ")`;
string $combobjtemp[] = `polyCube -n ("combobjtmp"+$objs[0])`;
setAttr ($combobjtemp[0]+".translateX") $tX; setAttr ($combobjtemp[0]+".translateY") $tY; setAttr ($combobjtemp[0]+".translateZ") $tZ;
select -add $objs[0];
optionVar -iv matchRotPivot 1; optionVar -iv matchScalePivot 1; optionVar -iv matchPivotOrient 1;
performMatchPivots 0;
DeleteHistory;
select $objs;
performPolyShellSeparate;
DeleteHistory;
if($axis=="x") align -x Mid;
else if($axis=="y") align -y Mid;
else if($axis=="z") align -z Mid;
select $objs[0];
string $name[];
$numTokens = tokenize($objs[0], "|", $name);
string $firstparent[] = `listRelatives -p -f`;
select $objs;
CombinePolygons;
string $objfinal[] = `ls -o -sl`;
if(size($firstparent[0])!=0) parent $objfinal[0] $firstparent[0];
$objfinal = `ls -o -sl`;
DeleteHistory;
move -r -ws -moveXYZ (-$tX) (-$tY) (-$tZ);
setAttr ($objfinal[0]+".translateX") $tX; setAttr ($objfinal[0]+".translateY") $tY; setAttr ($objfinal[0]+".translateZ") $tZ;
select -add $combobjtemp[0];
performMatchPivots 0;
delete $combobjtemp[0];
rename $objfinal[0] $name[size($name)-1];
string $msgg = "Align Elements within Object ";
if($axis=="x") $msgg += "<span style='color:#f00'>X</span>";
else if($axis=="y") $msgg += "<span style='color:#0f0'>Y</span>";
else if($axis=="z") $msgg += "<span style='color:#00f'>Z</span>";
inViewMessage -msg $msgg -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
}
}
}
AlignMidImproved("y");Ditto but Z.
proc AlignMidImproved(string $axis) {
string $objs[] = `ls -o -sl`;
if(`selectMode -q -object`) {
if(size($objs)>1) {
if($axis=="x") align -x Mid;
else if($axis=="y") align -y Mid;
else if($axis=="z") align -z Mid;
string $msgg = "Align Objects ";
if($axis=="x") $msgg += "<span style='color:#f00'>X</span>";
else if($axis=="y") $msgg += "<span style='color:#0f0'>Y</span>";
else if($axis=="z") $msgg += "<span style='color:#00f'>Z</span>";
inViewMessage -msg $msgg -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
}
if(size($objs)==1) {
performFreezeTransformations(0);
float $tX = `getAttr ($objs[0]+".translateX")`; float $tY = `getAttr ($objs[0]+".translateY")`; float $tZ = `getAttr ($objs[0]+".translateZ")`;
string $combobjtemp[] = `polyCube -n ("combobjtmp"+$objs[0])`;
setAttr ($combobjtemp[0]+".translateX") $tX; setAttr ($combobjtemp[0]+".translateY") $tY; setAttr ($combobjtemp[0]+".translateZ") $tZ;
select -add $objs[0];
optionVar -iv matchRotPivot 1; optionVar -iv matchScalePivot 1; optionVar -iv matchPivotOrient 1;
performMatchPivots 0;
DeleteHistory;
select $objs;
performPolyShellSeparate;
DeleteHistory;
if($axis=="x") align -x Mid;
else if($axis=="y") align -y Mid;
else if($axis=="z") align -z Mid;
select $objs[0];
string $name[];
$numTokens = tokenize($objs[0], "|", $name);
string $firstparent[] = `listRelatives -p -f`;
select $objs;
CombinePolygons;
string $objfinal[] = `ls -o -sl`;
if(size($firstparent[0])!=0) parent $objfinal[0] $firstparent[0];
$objfinal = `ls -o -sl`;
DeleteHistory;
move -r -ws -moveXYZ (-$tX) (-$tY) (-$tZ);
setAttr ($objfinal[0]+".translateX") $tX; setAttr ($objfinal[0]+".translateY") $tY; setAttr ($objfinal[0]+".translateZ") $tZ;
select -add $combobjtemp[0];
performMatchPivots 0;
delete $combobjtemp[0];
rename $objfinal[0] $name[size($name)-1];
string $msgg = "Align Elements within Object ";
if($axis=="x") $msgg += "<span style='color:#f00'>X</span>";
else if($axis=="y") $msgg += "<span style='color:#0f0'>Y</span>";
else if($axis=="z") $msgg += "<span style='color:#00f'>Z</span>";
inViewMessage -msg $msgg -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
}
}
}
AlignMidImproved("z");Align objects or elements within 1 object to the minimum X position.
proc AlignTo(string $axis) {
string $objs[] = `ls -o -sl`;
float $allBB[] = `exactWorldBoundingBox`;
for($item in $objs) {
select $item;
float $thisBB[] = `exactWorldBoundingBox`;
if($axis=="-x") move -r -ws -x ($allBB[0]-$thisBB[0]);
if($axis=="-y") move -r -ws -y ($allBB[1]-$thisBB[1]);
if($axis=="-z") move -r -ws -z ($allBB[2]-$thisBB[2]);
if($axis=="+x") move -r -ws -x ($allBB[3]-$thisBB[3]);
if($axis=="+y") move -r -ws -y ($allBB[4]-$thisBB[4]);
if($axis=="+z") move -r -ws -z ($allBB[5]-$thisBB[5]);
}
select $objs;
}
proc AlignImproved(string $axis) {
string $currentToolActive = `currentCtx`;
string $objs[] = `ls -o -sl`;
string $msgg;
if(`selectMode -q -object`) {
if(size($objs)>1) {
AlignTo($axis);
$msgg = "Align Objects ";
if($axis=="-x") $msgg = $msgg + "<span style='color:#0ff'>-</span><span style='color:#f00'>X</span>";
if($axis=="-y") $msgg = $msgg + "<span style='color:#0ff'>-</span><span style='color:#0f0'>Y</span>";
if($axis=="-z") $msgg = $msgg + "<span style='color:#0ff'>-</span><span style='color:#00f'>Z</span>";
if($axis=="+x") $msgg = $msgg + "<span style='color:#ff0'>+</span><span style='color:#f00'>X</span>";
if($axis=="+y") $msgg = $msgg + "<span style='color:#ff0'>+</span><span style='color:#0f0'>Y</span>";
if($axis=="+z") $msgg = $msgg + "<span style='color:#ff0'>+</span><span style='color:#00f'>Z</span>";
}
else if(size($objs)==1) {
$msgg = "Align Elements within Object ";
if($axis=="-x") $msgg = $msgg + "<span style='color:#0ff'>-</span><span style='color:#f00'>X</span>";
if($axis=="-y") $msgg = $msgg + "<span style='color:#0ff'>-</span><span style='color:#0f0'>Y</span>";
if($axis=="-z") $msgg = $msgg + "<span style='color:#0ff'>-</span><span style='color:#00f'>Z</span>";
if($axis=="+x") $msgg = $msgg + "<span style='color:#ff0'>+</span><span style='color:#f00'>X</span>";
if($axis=="+y") $msgg = $msgg + "<span style='color:#ff0'>+</span><span style='color:#0f0'>Y</span>";
if($axis=="+z") $msgg = $msgg + "<span style='color:#ff0'>+</span><span style='color:#00f'>Z</span>";
performFreezeTransformations(0);
float $tX = `getAttr ($objs[0]+".translateX")`; float $tY = `getAttr ($objs[0]+".translateY")`; float $tZ = `getAttr ($objs[0]+".translateZ")`;
string $combobjtemp[] = `polyCube -n ("combobjtmp"+$objs[0])`;
setAttr ($combobjtemp[0]+".translateX") $tX; setAttr ($combobjtemp[0]+".translateY") $tY; setAttr ($combobjtemp[0]+".translateZ") $tZ;
select -add $objs[0];
optionVar -iv matchRotPivot 1; optionVar -iv matchScalePivot 1; optionVar -iv matchPivotOrient 1;
performMatchPivots 0;
DeleteHistory;
select $objs;
string $origparent[] = `listRelatives -p -f`;
performPolyShellSeparate;
string $name[];
$numTokens = tokenize($objs[0], "|", $name);
parent -w;
AlignTo($axis);
CombinePolygons;
DeleteHistory;
string $objfinal[] = `ls -o -sl`;
move -r -ws -moveXYZ (-$tX) (-$tY) (-$tZ);
setAttr ($objfinal[0]+".translateX") $tX; setAttr ($objfinal[0]+".translateY") $tY; setAttr ($objfinal[0]+".translateZ") $tZ;
select -add $combobjtemp[0];
performMatchPivots 0;
delete $combobjtemp[0];
rename $objfinal[0] $name[size($name)-1];
$objfinal = `ls -o -sl`;
if(size($origparent[0])!=0) parent $objfinal[0] $origparent[0];
}
inViewMessage -msg $msgg -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
}
else inViewMessage -msg "must be in object mode" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
setToolTo $currentToolActive;
}
AlignImproved("-x");Ditto but Y.
proc AlignTo(string $axis) {
string $objs[] = `ls -o -sl`;
float $allBB[] = `exactWorldBoundingBox`;
for($item in $objs) {
select $item;
float $thisBB[] = `exactWorldBoundingBox`;
if($axis=="-x") move -r -ws -x ($allBB[0]-$thisBB[0]);
if($axis=="-y") move -r -ws -y ($allBB[1]-$thisBB[1]);
if($axis=="-z") move -r -ws -z ($allBB[2]-$thisBB[2]);
if($axis=="+x") move -r -ws -x ($allBB[3]-$thisBB[3]);
if($axis=="+y") move -r -ws -y ($allBB[4]-$thisBB[4]);
if($axis=="+z") move -r -ws -z ($allBB[5]-$thisBB[5]);
}
select $objs;
}
proc AlignImproved(string $axis) {
string $currentToolActive = `currentCtx`;
string $objs[] = `ls -o -sl`;
string $msgg;
if(`selectMode -q -object`) {
if(size($objs)>1) {
AlignTo($axis);
$msgg = "Align Objects ";
if($axis=="-x") $msgg = $msgg + "<span style='color:#0ff'>-</span><span style='color:#f00'>X</span>";
if($axis=="-y") $msgg = $msgg + "<span style='color:#0ff'>-</span><span style='color:#0f0'>Y</span>";
if($axis=="-z") $msgg = $msgg + "<span style='color:#0ff'>-</span><span style='color:#00f'>Z</span>";
if($axis=="+x") $msgg = $msgg + "<span style='color:#ff0'>+</span><span style='color:#f00'>X</span>";
if($axis=="+y") $msgg = $msgg + "<span style='color:#ff0'>+</span><span style='color:#0f0'>Y</span>";
if($axis=="+z") $msgg = $msgg + "<span style='color:#ff0'>+</span><span style='color:#00f'>Z</span>";
}
else if(size($objs)==1) {
$msgg = "Align Elements within Object ";
if($axis=="-x") $msgg = $msgg + "<span style='color:#0ff'>-</span><span style='color:#f00'>X</span>";
if($axis=="-y") $msgg = $msgg + "<span style='color:#0ff'>-</span><span style='color:#0f0'>Y</span>";
if($axis=="-z") $msgg = $msgg + "<span style='color:#0ff'>-</span><span style='color:#00f'>Z</span>";
if($axis=="+x") $msgg = $msgg + "<span style='color:#ff0'>+</span><span style='color:#f00'>X</span>";
if($axis=="+y") $msgg = $msgg + "<span style='color:#ff0'>+</span><span style='color:#0f0'>Y</span>";
if($axis=="+z") $msgg = $msgg + "<span style='color:#ff0'>+</span><span style='color:#00f'>Z</span>";
performFreezeTransformations(0);
float $tX = `getAttr ($objs[0]+".translateX")`; float $tY = `getAttr ($objs[0]+".translateY")`; float $tZ = `getAttr ($objs[0]+".translateZ")`;
string $combobjtemp[] = `polyCube -n ("combobjtmp"+$objs[0])`;
setAttr ($combobjtemp[0]+".translateX") $tX; setAttr ($combobjtemp[0]+".translateY") $tY; setAttr ($combobjtemp[0]+".translateZ") $tZ;
select -add $objs[0];
optionVar -iv matchRotPivot 1; optionVar -iv matchScalePivot 1; optionVar -iv matchPivotOrient 1;
performMatchPivots 0;
DeleteHistory;
select $objs;
string $origparent[] = `listRelatives -p -f`;
performPolyShellSeparate;
string $name[];
$numTokens = tokenize($objs[0], "|", $name);
parent -w;
AlignTo($axis);
CombinePolygons;
DeleteHistory;
string $objfinal[] = `ls -o -sl`;
move -r -ws -moveXYZ (-$tX) (-$tY) (-$tZ);
setAttr ($objfinal[0]+".translateX") $tX; setAttr ($objfinal[0]+".translateY") $tY; setAttr ($objfinal[0]+".translateZ") $tZ;
select -add $combobjtemp[0];
performMatchPivots 0;
delete $combobjtemp[0];
rename $objfinal[0] $name[size($name)-1];
$objfinal = `ls -o -sl`;
if(size($origparent[0])!=0) parent $objfinal[0] $origparent[0];
}
inViewMessage -msg $msgg -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
}
else inViewMessage -msg "must be in object mode" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
setToolTo $currentToolActive;
}
AlignImproved("-y");Ditto but Z.
proc AlignTo(string $axis) {
string $objs[] = `ls -o -sl`;
float $allBB[] = `exactWorldBoundingBox`;
for($item in $objs) {
select $item;
float $thisBB[] = `exactWorldBoundingBox`;
if($axis=="-x") move -r -ws -x ($allBB[0]-$thisBB[0]);
if($axis=="-y") move -r -ws -y ($allBB[1]-$thisBB[1]);
if($axis=="-z") move -r -ws -z ($allBB[2]-$thisBB[2]);
if($axis=="+x") move -r -ws -x ($allBB[3]-$thisBB[3]);
if($axis=="+y") move -r -ws -y ($allBB[4]-$thisBB[4]);
if($axis=="+z") move -r -ws -z ($allBB[5]-$thisBB[5]);
}
select $objs;
}
proc AlignImproved(string $axis) {
string $currentToolActive = `currentCtx`;
string $objs[] = `ls -o -sl`;
string $msgg;
if(`selectMode -q -object`) {
if(size($objs)>1) {
AlignTo($axis);
$msgg = "Align Objects ";
if($axis=="-x") $msgg = $msgg + "<span style='color:#0ff'>-</span><span style='color:#f00'>X</span>";
if($axis=="-y") $msgg = $msgg + "<span style='color:#0ff'>-</span><span style='color:#0f0'>Y</span>";
if($axis=="-z") $msgg = $msgg + "<span style='color:#0ff'>-</span><span style='color:#00f'>Z</span>";
if($axis=="+x") $msgg = $msgg + "<span style='color:#ff0'>+</span><span style='color:#f00'>X</span>";
if($axis=="+y") $msgg = $msgg + "<span style='color:#ff0'>+</span><span style='color:#0f0'>Y</span>";
if($axis=="+z") $msgg = $msgg + "<span style='color:#ff0'>+</span><span style='color:#00f'>Z</span>";
}
else if(size($objs)==1) {
$msgg = "Align Elements within Object ";
if($axis=="-x") $msgg = $msgg + "<span style='color:#0ff'>-</span><span style='color:#f00'>X</span>";
if($axis=="-y") $msgg = $msgg + "<span style='color:#0ff'>-</span><span style='color:#0f0'>Y</span>";
if($axis=="-z") $msgg = $msgg + "<span style='color:#0ff'>-</span><span style='color:#00f'>Z</span>";
if($axis=="+x") $msgg = $msgg + "<span style='color:#ff0'>+</span><span style='color:#f00'>X</span>";
if($axis=="+y") $msgg = $msgg + "<span style='color:#ff0'>+</span><span style='color:#0f0'>Y</span>";
if($axis=="+z") $msgg = $msgg + "<span style='color:#ff0'>+</span><span style='color:#00f'>Z</span>";
performFreezeTransformations(0);
float $tX = `getAttr ($objs[0]+".translateX")`; float $tY = `getAttr ($objs[0]+".translateY")`; float $tZ = `getAttr ($objs[0]+".translateZ")`;
string $combobjtemp[] = `polyCube -n ("combobjtmp"+$objs[0])`;
setAttr ($combobjtemp[0]+".translateX") $tX; setAttr ($combobjtemp[0]+".translateY") $tY; setAttr ($combobjtemp[0]+".translateZ") $tZ;
select -add $objs[0];
optionVar -iv matchRotPivot 1; optionVar -iv matchScalePivot 1; optionVar -iv matchPivotOrient 1;
performMatchPivots 0;
DeleteHistory;
select $objs;
string $origparent[] = `listRelatives -p -f`;
performPolyShellSeparate;
string $name[];
$numTokens = tokenize($objs[0], "|", $name);
parent -w;
AlignTo($axis);
CombinePolygons;
DeleteHistory;
string $objfinal[] = `ls -o -sl`;
move -r -ws -moveXYZ (-$tX) (-$tY) (-$tZ);
setAttr ($objfinal[0]+".translateX") $tX; setAttr ($objfinal[0]+".translateY") $tY; setAttr ($objfinal[0]+".translateZ") $tZ;
select -add $combobjtemp[0];
performMatchPivots 0;
delete $combobjtemp[0];
rename $objfinal[0] $name[size($name)-1];
$objfinal = `ls -o -sl`;
if(size($origparent[0])!=0) parent $objfinal[0] $origparent[0];
}
inViewMessage -msg $msgg -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
}
else inViewMessage -msg "must be in object mode" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
setToolTo $currentToolActive;
}
AlignImproved("-z");Align objects or elements within 1 object to the maximum X position.
proc AlignTo(string $axis) {
string $objs[] = `ls -o -sl`;
float $allBB[] = `exactWorldBoundingBox`;
for($item in $objs) {
select $item;
float $thisBB[] = `exactWorldBoundingBox`;
if($axis=="-x") move -r -ws -x ($allBB[0]-$thisBB[0]);
if($axis=="-y") move -r -ws -y ($allBB[1]-$thisBB[1]);
if($axis=="-z") move -r -ws -z ($allBB[2]-$thisBB[2]);
if($axis=="+x") move -r -ws -x ($allBB[3]-$thisBB[3]);
if($axis=="+y") move -r -ws -y ($allBB[4]-$thisBB[4]);
if($axis=="+z") move -r -ws -z ($allBB[5]-$thisBB[5]);
}
select $objs;
}
proc AlignImproved(string $axis) {
string $currentToolActive = `currentCtx`;
string $objs[] = `ls -o -sl`;
string $msgg;
if(`selectMode -q -object`) {
if(size($objs)>1) {
AlignTo($axis);
$msgg = "Align Objects ";
if($axis=="-x") $msgg = $msgg + "<span style='color:#0ff'>-</span><span style='color:#f00'>X</span>";
if($axis=="-y") $msgg = $msgg + "<span style='color:#0ff'>-</span><span style='color:#0f0'>Y</span>";
if($axis=="-z") $msgg = $msgg + "<span style='color:#0ff'>-</span><span style='color:#00f'>Z</span>";
if($axis=="+x") $msgg = $msgg + "<span style='color:#ff0'>+</span><span style='color:#f00'>X</span>";
if($axis=="+y") $msgg = $msgg + "<span style='color:#ff0'>+</span><span style='color:#0f0'>Y</span>";
if($axis=="+z") $msgg = $msgg + "<span style='color:#ff0'>+</span><span style='color:#00f'>Z</span>";
}
else if(size($objs)==1) {
$msgg = "Align Elements within Object ";
if($axis=="-x") $msgg = $msgg + "<span style='color:#0ff'>-</span><span style='color:#f00'>X</span>";
if($axis=="-y") $msgg = $msgg + "<span style='color:#0ff'>-</span><span style='color:#0f0'>Y</span>";
if($axis=="-z") $msgg = $msgg + "<span style='color:#0ff'>-</span><span style='color:#00f'>Z</span>";
if($axis=="+x") $msgg = $msgg + "<span style='color:#ff0'>+</span><span style='color:#f00'>X</span>";
if($axis=="+y") $msgg = $msgg + "<span style='color:#ff0'>+</span><span style='color:#0f0'>Y</span>";
if($axis=="+z") $msgg = $msgg + "<span style='color:#ff0'>+</span><span style='color:#00f'>Z</span>";
performFreezeTransformations(0);
float $tX = `getAttr ($objs[0]+".translateX")`; float $tY = `getAttr ($objs[0]+".translateY")`; float $tZ = `getAttr ($objs[0]+".translateZ")`;
string $combobjtemp[] = `polyCube -n ("combobjtmp"+$objs[0])`;
setAttr ($combobjtemp[0]+".translateX") $tX; setAttr ($combobjtemp[0]+".translateY") $tY; setAttr ($combobjtemp[0]+".translateZ") $tZ;
select -add $objs[0];
optionVar -iv matchRotPivot 1; optionVar -iv matchScalePivot 1; optionVar -iv matchPivotOrient 1;
performMatchPivots 0;
DeleteHistory;
select $objs;
string $origparent[] = `listRelatives -p -f`;
performPolyShellSeparate;
string $name[];
$numTokens = tokenize($objs[0], "|", $name);
parent -w;
AlignTo($axis);
CombinePolygons;
DeleteHistory;
string $objfinal[] = `ls -o -sl`;
move -r -ws -moveXYZ (-$tX) (-$tY) (-$tZ);
setAttr ($objfinal[0]+".translateX") $tX; setAttr ($objfinal[0]+".translateY") $tY; setAttr ($objfinal[0]+".translateZ") $tZ;
select -add $combobjtemp[0];
performMatchPivots 0;
delete $combobjtemp[0];
rename $objfinal[0] $name[size($name)-1];
$objfinal = `ls -o -sl`;
if(size($origparent[0])!=0) parent $objfinal[0] $origparent[0];
}
inViewMessage -msg $msgg -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
}
else inViewMessage -msg "must be in object mode" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
setToolTo $currentToolActive;
}
AlignImproved("+x");Ditto but Y.
proc AlignTo(string $axis) {
string $objs[] = `ls -o -sl`;
float $allBB[] = `exactWorldBoundingBox`;
for($item in $objs) {
select $item;
float $thisBB[] = `exactWorldBoundingBox`;
if($axis=="-x") move -r -ws -x ($allBB[0]-$thisBB[0]);
if($axis=="-y") move -r -ws -y ($allBB[1]-$thisBB[1]);
if($axis=="-z") move -r -ws -z ($allBB[2]-$thisBB[2]);
if($axis=="+x") move -r -ws -x ($allBB[3]-$thisBB[3]);
if($axis=="+y") move -r -ws -y ($allBB[4]-$thisBB[4]);
if($axis=="+z") move -r -ws -z ($allBB[5]-$thisBB[5]);
}
select $objs;
}
proc AlignImproved(string $axis) {
string $currentToolActive = `currentCtx`;
string $objs[] = `ls -o -sl`;
string $msgg;
if(`selectMode -q -object`) {
if(size($objs)>1) {
AlignTo($axis);
$msgg = "Align Objects ";
if($axis=="-x") $msgg = $msgg + "<span style='color:#0ff'>-</span><span style='color:#f00'>X</span>";
if($axis=="-y") $msgg = $msgg + "<span style='color:#0ff'>-</span><span style='color:#0f0'>Y</span>";
if($axis=="-z") $msgg = $msgg + "<span style='color:#0ff'>-</span><span style='color:#00f'>Z</span>";
if($axis=="+x") $msgg = $msgg + "<span style='color:#ff0'>+</span><span style='color:#f00'>X</span>";
if($axis=="+y") $msgg = $msgg + "<span style='color:#ff0'>+</span><span style='color:#0f0'>Y</span>";
if($axis=="+z") $msgg = $msgg + "<span style='color:#ff0'>+</span><span style='color:#00f'>Z</span>";
}
else if(size($objs)==1) {
$msgg = "Align Elements within Object ";
if($axis=="-x") $msgg = $msgg + "<span style='color:#0ff'>-</span><span style='color:#f00'>X</span>";
if($axis=="-y") $msgg = $msgg + "<span style='color:#0ff'>-</span><span style='color:#0f0'>Y</span>";
if($axis=="-z") $msgg = $msgg + "<span style='color:#0ff'>-</span><span style='color:#00f'>Z</span>";
if($axis=="+x") $msgg = $msgg + "<span style='color:#ff0'>+</span><span style='color:#f00'>X</span>";
if($axis=="+y") $msgg = $msgg + "<span style='color:#ff0'>+</span><span style='color:#0f0'>Y</span>";
if($axis=="+z") $msgg = $msgg + "<span style='color:#ff0'>+</span><span style='color:#00f'>Z</span>";
performFreezeTransformations(0);
float $tX = `getAttr ($objs[0]+".translateX")`; float $tY = `getAttr ($objs[0]+".translateY")`; float $tZ = `getAttr ($objs[0]+".translateZ")`;
string $combobjtemp[] = `polyCube -n ("combobjtmp"+$objs[0])`;
setAttr ($combobjtemp[0]+".translateX") $tX; setAttr ($combobjtemp[0]+".translateY") $tY; setAttr ($combobjtemp[0]+".translateZ") $tZ;
select -add $objs[0];
optionVar -iv matchRotPivot 1; optionVar -iv matchScalePivot 1; optionVar -iv matchPivotOrient 1;
performMatchPivots 0;
DeleteHistory;
select $objs;
string $origparent[] = `listRelatives -p -f`;
performPolyShellSeparate;
string $name[];
$numTokens = tokenize($objs[0], "|", $name);
parent -w;
AlignTo($axis);
CombinePolygons;
DeleteHistory;
string $objfinal[] = `ls -o -sl`;
move -r -ws -moveXYZ (-$tX) (-$tY) (-$tZ);
setAttr ($objfinal[0]+".translateX") $tX; setAttr ($objfinal[0]+".translateY") $tY; setAttr ($objfinal[0]+".translateZ") $tZ;
select -add $combobjtemp[0];
performMatchPivots 0;
delete $combobjtemp[0];
rename $objfinal[0] $name[size($name)-1];
$objfinal = `ls -o -sl`;
if(size($origparent[0])!=0) parent $objfinal[0] $origparent[0];
}
inViewMessage -msg $msgg -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
}
else inViewMessage -msg "must be in object mode" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
setToolTo $currentToolActive;
}
AlignImproved("+y");Ditto but Z.
proc AlignTo(string $axis) {
string $objs[] = `ls -o -sl`;
float $allBB[] = `exactWorldBoundingBox`;
for($item in $objs) {
select $item;
float $thisBB[] = `exactWorldBoundingBox`;
if($axis=="-x") move -r -ws -x ($allBB[0]-$thisBB[0]);
if($axis=="-y") move -r -ws -y ($allBB[1]-$thisBB[1]);
if($axis=="-z") move -r -ws -z ($allBB[2]-$thisBB[2]);
if($axis=="+x") move -r -ws -x ($allBB[3]-$thisBB[3]);
if($axis=="+y") move -r -ws -y ($allBB[4]-$thisBB[4]);
if($axis=="+z") move -r -ws -z ($allBB[5]-$thisBB[5]);
}
select $objs;
}
proc AlignImproved(string $axis) {
string $currentToolActive = `currentCtx`;
string $objs[] = `ls -o -sl`;
string $msgg;
if(`selectMode -q -object`) {
if(size($objs)>1) {
AlignTo($axis);
$msgg = "Align Objects ";
if($axis=="-x") $msgg = $msgg + "<span style='color:#0ff'>-</span><span style='color:#f00'>X</span>";
if($axis=="-y") $msgg = $msgg + "<span style='color:#0ff'>-</span><span style='color:#0f0'>Y</span>";
if($axis=="-z") $msgg = $msgg + "<span style='color:#0ff'>-</span><span style='color:#00f'>Z</span>";
if($axis=="+x") $msgg = $msgg + "<span style='color:#ff0'>+</span><span style='color:#f00'>X</span>";
if($axis=="+y") $msgg = $msgg + "<span style='color:#ff0'>+</span><span style='color:#0f0'>Y</span>";
if($axis=="+z") $msgg = $msgg + "<span style='color:#ff0'>+</span><span style='color:#00f'>Z</span>";
}
else if(size($objs)==1) {
$msgg = "Align Elements within Object ";
if($axis=="-x") $msgg = $msgg + "<span style='color:#0ff'>-</span><span style='color:#f00'>X</span>";
if($axis=="-y") $msgg = $msgg + "<span style='color:#0ff'>-</span><span style='color:#0f0'>Y</span>";
if($axis=="-z") $msgg = $msgg + "<span style='color:#0ff'>-</span><span style='color:#00f'>Z</span>";
if($axis=="+x") $msgg = $msgg + "<span style='color:#ff0'>+</span><span style='color:#f00'>X</span>";
if($axis=="+y") $msgg = $msgg + "<span style='color:#ff0'>+</span><span style='color:#0f0'>Y</span>";
if($axis=="+z") $msgg = $msgg + "<span style='color:#ff0'>+</span><span style='color:#00f'>Z</span>";
performFreezeTransformations(0);
float $tX = `getAttr ($objs[0]+".translateX")`; float $tY = `getAttr ($objs[0]+".translateY")`; float $tZ = `getAttr ($objs[0]+".translateZ")`;
string $combobjtemp[] = `polyCube -n ("combobjtmp"+$objs[0])`;
setAttr ($combobjtemp[0]+".translateX") $tX; setAttr ($combobjtemp[0]+".translateY") $tY; setAttr ($combobjtemp[0]+".translateZ") $tZ;
select -add $objs[0];
optionVar -iv matchRotPivot 1; optionVar -iv matchScalePivot 1; optionVar -iv matchPivotOrient 1;
performMatchPivots 0;
DeleteHistory;
select $objs;
string $origparent[] = `listRelatives -p -f`;
performPolyShellSeparate;
string $name[];
$numTokens = tokenize($objs[0], "|", $name);
parent -w;
AlignTo($axis);
CombinePolygons;
DeleteHistory;
string $objfinal[] = `ls -o -sl`;
move -r -ws -moveXYZ (-$tX) (-$tY) (-$tZ);
setAttr ($objfinal[0]+".translateX") $tX; setAttr ($objfinal[0]+".translateY") $tY; setAttr ($objfinal[0]+".translateZ") $tZ;
select -add $combobjtemp[0];
performMatchPivots 0;
delete $combobjtemp[0];
rename $objfinal[0] $name[size($name)-1];
$objfinal = `ls -o -sl`;
if(size($origparent[0])!=0) parent $objfinal[0] $origparent[0];
}
inViewMessage -msg $msgg -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
}
else inViewMessage -msg "must be in object mode" -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
setToolTo $currentToolActive;
}
AlignImproved("+z");Distribute objects or elements within 1 object along the X axis.
proc DistributeImproved(string $axis) {
string $objs[] = `ls -o -sl`;
if(`selectMode -q -object`) {
if(size($objs)>1) {
if($axis=="x") align -x Dist;
else if($axis=="y") align -y Dist;
else if($axis=="z") align -z Dist;
string $msgg = "Distribute Objects ";
if($axis=="x") $msgg += "<span style='color:#f00'>X</span>";
else if($axis=="y") $msgg += "<span style='color:#0f0'>Y</span>";
else if($axis=="z") $msgg += "<span style='color:#00f'>Z</span>";
inViewMessage -msg $msgg -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
}
if(size($objs)==1) {
performFreezeTransformations(0);
float $tX = `getAttr ($objs[0]+".translateX")`; float $tY = `getAttr ($objs[0]+".translateY")`; float $tZ = `getAttr ($objs[0]+".translateZ")`;
string $combobjtemp[] = `polyCube -n ("combobjtmp"+$objs[0])`;
setAttr ($combobjtemp[0]+".translateX") $tX; setAttr ($combobjtemp[0]+".translateY") $tY; setAttr ($combobjtemp[0]+".translateZ") $tZ;
select -add $objs[0];
optionVar -iv matchRotPivot 1; optionVar -iv matchScalePivot 1; optionVar -iv matchPivotOrient 1;
performMatchPivots 0;
DeleteHistory;
select $objs;
performPolyShellSeparate;
DeleteHistory;
if($axis=="x") align -x Dist;
else if($axis=="y") align -y Dist;
else if($axis=="z") align -z Dist;
select $objs[0];
string $name[];
$numTokens = tokenize($objs[0], "|", $name);
string $firstparent[] = `listRelatives -p -f`;
select $objs;
CombinePolygons;
string $objfinal[] = `ls -o -sl`;
if(size($firstparent[0])!=0) parent $objfinal[0] $firstparent[0];
$objfinal = `ls -o -sl`;
DeleteHistory;
move -r -ws -moveXYZ (-$tX) (-$tY) (-$tZ);
setAttr ($objfinal[0]+".translateX") $tX; setAttr ($objfinal[0]+".translateY") $tY; setAttr ($objfinal[0]+".translateZ") $tZ;
select -add $combobjtemp[0];
performMatchPivots 0;
delete $combobjtemp[0];
rename $objfinal[0] $name[size($name)-1];
string $msgg = "Distribute Elements within Object ";
if($axis=="x") $msgg += "<span style='color:#f00'>X</span>";
else if($axis=="y") $msgg += "<span style='color:#0f0'>Y</span>";
else if($axis=="z") $msgg += "<span style='color:#00f'>Z</span>";
inViewMessage -msg $msgg -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
}
}
}
DistributeImproved("x");Ditto but Y.
proc DistributeImproved(string $axis) {
string $objs[] = `ls -o -sl`;
if(`selectMode -q -object`) {
if(size($objs)>1) {
if($axis=="x") align -x Dist;
else if($axis=="y") align -y Dist;
else if($axis=="z") align -z Dist;
string $msgg = "Distribute Objects ";
if($axis=="x") $msgg += "<span style='color:#f00'>X</span>";
else if($axis=="y") $msgg += "<span style='color:#0f0'>Y</span>";
else if($axis=="z") $msgg += "<span style='color:#00f'>Z</span>";
inViewMessage -msg $msgg -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
}
if(size($objs)==1) {
performFreezeTransformations(0);
float $tX = `getAttr ($objs[0]+".translateX")`; float $tY = `getAttr ($objs[0]+".translateY")`; float $tZ = `getAttr ($objs[0]+".translateZ")`;
string $combobjtemp[] = `polyCube -n ("combobjtmp"+$objs[0])`;
setAttr ($combobjtemp[0]+".translateX") $tX; setAttr ($combobjtemp[0]+".translateY") $tY; setAttr ($combobjtemp[0]+".translateZ") $tZ;
select -add $objs[0];
optionVar -iv matchRotPivot 1; optionVar -iv matchScalePivot 1; optionVar -iv matchPivotOrient 1;
performMatchPivots 0;
DeleteHistory;
select $objs;
performPolyShellSeparate;
DeleteHistory;
if($axis=="x") align -x Dist;
else if($axis=="y") align -y Dist;
else if($axis=="z") align -z Dist;
select $objs[0];
string $name[];
$numTokens = tokenize($objs[0], "|", $name);
string $firstparent[] = `listRelatives -p -f`;
select $objs;
CombinePolygons;
string $objfinal[] = `ls -o -sl`;
if(size($firstparent[0])!=0) parent $objfinal[0] $firstparent[0];
$objfinal = `ls -o -sl`;
DeleteHistory;
move -r -ws -moveXYZ (-$tX) (-$tY) (-$tZ);
setAttr ($objfinal[0]+".translateX") $tX; setAttr ($objfinal[0]+".translateY") $tY; setAttr ($objfinal[0]+".translateZ") $tZ;
select -add $combobjtemp[0];
performMatchPivots 0;
delete $combobjtemp[0];
rename $objfinal[0] $name[size($name)-1];
string $msgg = "Distribute Elements within Object ";
if($axis=="x") $msgg += "<span style='color:#f00'>X</span>";
else if($axis=="y") $msgg += "<span style='color:#0f0'>Y</span>";
else if($axis=="z") $msgg += "<span style='color:#00f'>Z</span>";
inViewMessage -msg $msgg -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
}
}
}
DistributeImproved("y");Ditto but Z.
proc DistributeImproved(string $axis) {
string $objs[] = `ls -o -sl`;
if(`selectMode -q -object`) {
if(size($objs)>1) {
if($axis=="x") align -x Dist;
else if($axis=="y") align -y Dist;
else if($axis=="z") align -z Dist;
string $msgg = "Distribute Objects ";
if($axis=="x") $msgg += "<span style='color:#f00'>X</span>";
else if($axis=="y") $msgg += "<span style='color:#0f0'>Y</span>";
else if($axis=="z") $msgg += "<span style='color:#00f'>Z</span>";
inViewMessage -msg $msgg -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
}
if(size($objs)==1) {
performFreezeTransformations(0);
float $tX = `getAttr ($objs[0]+".translateX")`; float $tY = `getAttr ($objs[0]+".translateY")`; float $tZ = `getAttr ($objs[0]+".translateZ")`;
string $combobjtemp[] = `polyCube -n ("combobjtmp"+$objs[0])`;
setAttr ($combobjtemp[0]+".translateX") $tX; setAttr ($combobjtemp[0]+".translateY") $tY; setAttr ($combobjtemp[0]+".translateZ") $tZ;
select -add $objs[0];
optionVar -iv matchRotPivot 1; optionVar -iv matchScalePivot 1; optionVar -iv matchPivotOrient 1;
performMatchPivots 0;
DeleteHistory;
select $objs;
performPolyShellSeparate;
DeleteHistory;
if($axis=="x") align -x Dist;
else if($axis=="y") align -y Dist;
else if($axis=="z") align -z Dist;
select $objs[0];
string $name[];
$numTokens = tokenize($objs[0], "|", $name);
string $firstparent[] = `listRelatives -p -f`;
select $objs;
CombinePolygons;
string $objfinal[] = `ls -o -sl`;
if(size($firstparent[0])!=0) parent $objfinal[0] $firstparent[0];
$objfinal = `ls -o -sl`;
DeleteHistory;
move -r -ws -moveXYZ (-$tX) (-$tY) (-$tZ);
setAttr ($objfinal[0]+".translateX") $tX; setAttr ($objfinal[0]+".translateY") $tY; setAttr ($objfinal[0]+".translateZ") $tZ;
select -add $combobjtemp[0];
performMatchPivots 0;
delete $combobjtemp[0];
rename $objfinal[0] $name[size($name)-1];
string $msgg = "Distribute Elements within Object ";
if($axis=="x") $msgg += "<span style='color:#f00'>X</span>";
else if($axis=="y") $msgg += "<span style='color:#0f0'>Y</span>";
else if($axis=="z") $msgg += "<span style='color:#00f'>Z</span>";
inViewMessage -msg $msgg -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
}
}
}
DistributeImproved("z");Stack objects or elements within 1 object along the X axis.
proc StackImproved(string $axis) {
string $objs[] = `ls -o -sl`;
if(`selectMode -q -object`) {
if(size($objs)>1) {
if($axis=="x") align -x Stack;
else if($axis=="y") align -y Stack;
else if($axis=="z") align -z Stack;
string $msgg = "Stack Objects ";
if($axis=="x") $msgg += "<span style='color:#f00'>X</span>";
else if($axis=="y") $msgg += "<span style='color:#0f0'>Y</span>";
else if($axis=="z") $msgg += "<span style='color:#00f'>Z</span>";
inViewMessage -msg $msgg -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
}
if(size($objs)==1) {
performFreezeTransformations(0);
float $tX = `getAttr ($objs[0]+".translateX")`; float $tY = `getAttr ($objs[0]+".translateY")`; float $tZ = `getAttr ($objs[0]+".translateZ")`;
string $combobjtemp[] = `polyCube -n ("combobjtmp"+$objs[0])`;
setAttr ($combobjtemp[0]+".translateX") $tX; setAttr ($combobjtemp[0]+".translateY") $tY; setAttr ($combobjtemp[0]+".translateZ") $tZ;
select -add $objs[0];
optionVar -iv matchRotPivot 1; optionVar -iv matchScalePivot 1; optionVar -iv matchPivotOrient 1;
performMatchPivots 0;
DeleteHistory;
select $objs;
performPolyShellSeparate;
DeleteHistory;
if($axis=="x") align -x Stack;
else if($axis=="y") align -y Stack;
else if($axis=="z") align -z Stack;
select $objs[0];
string $name[];
$numTokens = tokenize($objs[0], "|", $name);
string $firstparent[] = `listRelatives -p -f`;
select $objs;
CombinePolygons;
string $objfinal[] = `ls -o -sl`;
if(size($firstparent[0])!=0) parent $objfinal[0] $firstparent[0];
$objfinal = `ls -o -sl`;
DeleteHistory;
move -r -ws -moveXYZ (-$tX) (-$tY) (-$tZ);
setAttr ($objfinal[0]+".translateX") $tX; setAttr ($objfinal[0]+".translateY") $tY; setAttr ($objfinal[0]+".translateZ") $tZ;
select -add $combobjtemp[0];
performMatchPivots 0;
delete $combobjtemp[0];
rename $objfinal[0] $name[size($name)-1];
string $msgg = "Stack Elements within Object ";
if($axis=="x") $msgg += "<span style='color:#f00'>X</span>";
else if($axis=="y") $msgg += "<span style='color:#0f0'>Y</span>";
else if($axis=="z") $msgg += "<span style='color:#00f'>Z</span>";
inViewMessage -msg $msgg -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
}
}
}
StackImproved("x");Ditto but Y.
proc StackImproved(string $axis) {
string $objs[] = `ls -o -sl`;
if(`selectMode -q -object`) {
if(size($objs)>1) {
if($axis=="x") align -x Stack;
else if($axis=="y") align -y Stack;
else if($axis=="z") align -z Stack;
string $msgg = "Stack Objects ";
if($axis=="x") $msgg += "<span style='color:#f00'>X</span>";
else if($axis=="y") $msgg += "<span style='color:#0f0'>Y</span>";
else if($axis=="z") $msgg += "<span style='color:#00f'>Z</span>";
inViewMessage -msg $msgg -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
}
if(size($objs)==1) {
performFreezeTransformations(0);
float $tX = `getAttr ($objs[0]+".translateX")`; float $tY = `getAttr ($objs[0]+".translateY")`; float $tZ = `getAttr ($objs[0]+".translateZ")`;
string $combobjtemp[] = `polyCube -n ("combobjtmp"+$objs[0])`;
setAttr ($combobjtemp[0]+".translateX") $tX; setAttr ($combobjtemp[0]+".translateY") $tY; setAttr ($combobjtemp[0]+".translateZ") $tZ;
select -add $objs[0];
optionVar -iv matchRotPivot 1; optionVar -iv matchScalePivot 1; optionVar -iv matchPivotOrient 1;
performMatchPivots 0;
DeleteHistory;
select $objs;
performPolyShellSeparate;
DeleteHistory;
if($axis=="x") align -x Stack;
else if($axis=="y") align -y Stack;
else if($axis=="z") align -z Stack;
select $objs[0];
string $name[];
$numTokens = tokenize($objs[0], "|", $name);
string $firstparent[] = `listRelatives -p -f`;
select $objs;
CombinePolygons;
string $objfinal[] = `ls -o -sl`;
if(size($firstparent[0])!=0) parent $objfinal[0] $firstparent[0];
$objfinal = `ls -o -sl`;
DeleteHistory;
move -r -ws -moveXYZ (-$tX) (-$tY) (-$tZ);
setAttr ($objfinal[0]+".translateX") $tX; setAttr ($objfinal[0]+".translateY") $tY; setAttr ($objfinal[0]+".translateZ") $tZ;
select -add $combobjtemp[0];
performMatchPivots 0;
delete $combobjtemp[0];
rename $objfinal[0] $name[size($name)-1];
string $msgg = "Stack Elements within Object ";
if($axis=="x") $msgg += "<span style='color:#f00'>X</span>";
else if($axis=="y") $msgg += "<span style='color:#0f0'>Y</span>";
else if($axis=="z") $msgg += "<span style='color:#00f'>Z</span>";
inViewMessage -msg $msgg -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
}
}
}
StackImproved("y");Ditto but Z.
proc StackImproved(string $axis) {
string $objs[] = `ls -o -sl`;
if(`selectMode -q -object`) {
if(size($objs)>1) {
if($axis=="x") align -x Stack;
else if($axis=="y") align -y Stack;
else if($axis=="z") align -z Stack;
string $msgg = "Stack Objects ";
if($axis=="x") $msgg += "<span style='color:#f00'>X</span>";
else if($axis=="y") $msgg += "<span style='color:#0f0'>Y</span>";
else if($axis=="z") $msgg += "<span style='color:#00f'>Z</span>";
inViewMessage -msg $msgg -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
}
if(size($objs)==1) {
performFreezeTransformations(0);
float $tX = `getAttr ($objs[0]+".translateX")`; float $tY = `getAttr ($objs[0]+".translateY")`; float $tZ = `getAttr ($objs[0]+".translateZ")`;
string $combobjtemp[] = `polyCube -n ("combobjtmp"+$objs[0])`;
setAttr ($combobjtemp[0]+".translateX") $tX; setAttr ($combobjtemp[0]+".translateY") $tY; setAttr ($combobjtemp[0]+".translateZ") $tZ;
select -add $objs[0];
optionVar -iv matchRotPivot 1; optionVar -iv matchScalePivot 1; optionVar -iv matchPivotOrient 1;
performMatchPivots 0;
DeleteHistory;
select $objs;
performPolyShellSeparate;
DeleteHistory;
if($axis=="x") align -x Stack;
else if($axis=="y") align -y Stack;
else if($axis=="z") align -z Stack;
select $objs[0];
string $name[];
$numTokens = tokenize($objs[0], "|", $name);
string $firstparent[] = `listRelatives -p -f`;
select $objs;
CombinePolygons;
string $objfinal[] = `ls -o -sl`;
if(size($firstparent[0])!=0) parent $objfinal[0] $firstparent[0];
$objfinal = `ls -o -sl`;
DeleteHistory;
move -r -ws -moveXYZ (-$tX) (-$tY) (-$tZ);
setAttr ($objfinal[0]+".translateX") $tX; setAttr ($objfinal[0]+".translateY") $tY; setAttr ($objfinal[0]+".translateZ") $tZ;
select -add $combobjtemp[0];
performMatchPivots 0;
delete $combobjtemp[0];
rename $objfinal[0] $name[size($name)-1];
string $msgg = "Stack Elements within Object ";
if($axis=="x") $msgg += "<span style='color:#f00'>X</span>";
else if($axis=="y") $msgg += "<span style='color:#0f0'>Y</span>";
else if($axis=="z") $msgg += "<span style='color:#00f'>Z</span>";
inViewMessage -msg $msgg -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
}
}
}
StackImproved("z");Toggle the UV Editor and UV Toolkit.
showModelingToolkit;
toggleUVToolkit;
if ((size(`textureWindow -query -parent polyTexturePlacementPanel1`)) == 0) {
TextureViewWindow;
toggleUVToolkit;
}
else {
deleteUI polyTexturePlacementPanel1Window;
showModelingToolkit;
}Unfold selection along U.
optionVar -intValue uvTkUnfoldDirection 2;
uvTkDoUnfoldAlong(0);
string $msguv = "UV Unfold <span style='color:#f00'>U</span>";
inViewMessage -msg $msguv -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
inViewMessage -uv -msg $msguv -fade -fit 00 -fst 200 -fot 800 -pos midLeft -fts 30 -bkc 0x000000;Unfold selection along V.
optionVar -intValue uvTkUnfoldDirection 1;
uvTkDoUnfoldAlong(0);
string $msguv = "UV Unfold <span style='color:#0f0'>V</span>";
inViewMessage -msg $msguv -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
inViewMessage -uv -msg $msguv -fade -fit 00 -fst 200 -fot 800 -pos midLeft -fts 30 -bkc 0x000000;Unfold selection in both axis.
proc UnfoldBoth() {
string $prevsel = "";
if(`selectType -q -v`) {
$prevsel = "v";
select(`filterExpand -sm 31`);
}
else if(`selectType -q -eg`) {
$prevsel = "eg";
select(`filterExpand -sm 32`);
}
else if(`selectType -q -fc`) {
$prevsel = "fc";
select(`filterExpand -sm 34`);
}
else if(`selectType -q -smu`||`selectType -q -msh`) $prevsel = "smu";
string $sele[] = `ls -sl`;
ConvertSelectionToUVs;
UnfoldUV;
if($prevsel == "v") SelectVertexMask;
else if($prevsel == "eg") SelectEdgeMask;
else if($prevsel == "fc") SelectFacetMask;
else if($prevsel == "puv") SelectUVMask;
else if($prevsel == "smu") UVToolkitUVShellModeCB;
select $sele;
string $msguv = "UV Unfold <span style='color:#f00'>U</span><span style='color:#0f0'>V</span>";
inViewMessage -msg $msguv -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
inViewMessage -uv -msg $msguv -fade -fit 00 -fst 200 -fot 800 -pos midLeft -fts 30 -bkc 0x000000;
}
UnfoldBoth();Scale selection up in the V direction, based on the scale value in the UV Toolkit UI(default 2).
uvTkToggleScaleDirection("V", 1);
uvTkToggleScaleDirection("U", 0);
uvTkDoScale 0;
string $msguv = "UV Scale <span style='color:#0f0'>V</span>+";
inViewMessage -msg $msguv -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
inViewMessage -uv -msg $msguv -fade -fit 00 -fst 200 -fot 800 -pos midLeft -fts 30 -bkc 0x000000;Ditto but V down.
uvTkToggleScaleDirection("V", 1);
uvTkToggleScaleDirection("U", 0);
uvTkDoScale 1;
string $msguv = "UV Scale <span style='color:#0f0'>V</span>-";
inViewMessage -msg $msguv -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
inViewMessage -uv -msg $msguv -fade -fit 00 -fst 200 -fot 800 -pos midLeft -fts 30 -bkc 0x000000;Ditto but U up.
uvTkToggleScaleDirection("U", 1);
uvTkToggleScaleDirection("V", 0);
uvTkDoScale 0;
string $msguv = "UV Scale <span style='color:#f00'>U</span>+";
inViewMessage -msg $msguv -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
inViewMessage -uv -msg $msguv -fade -fit 00 -fst 200 -fot 800 -pos midLeft -fts 30 -bkc 0x000000;Ditto but U down.
uvTkToggleScaleDirection("U", 1);
uvTkToggleScaleDirection("V", 0);
uvTkDoScale 1;
string $msguv = "UV Scale <span style='color:#f00'>U</span>-";
inViewMessage -msg $msguv -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
inViewMessage -uv -msg $msguv -fade -fit 00 -fst 200 -fot 800 -pos midLeft -fts 30 -bkc 0x000000;Flip selection on the U axis.
optionVar -intValue polyUVFlipDirection 1;
uvTkDoFlipUVs 1;
string $msguv = "UV Flip <span style='color:#f00'>U</span>";
inViewMessage -msg $msguv -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
inViewMessage -uv -msg $msguv -fade -fit 00 -fst 200 -fot 800 -pos midLeft -fts 30 -bkc 0x000000;Flip selection on the V axis.
optionVar -intValue polyUVFlipDirection 0;
uvTkDoFlipUVs 1;
string $msguv = "UV Flip <span style='color:#0f0'>V</span>";
inViewMessage -msg $msguv -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
inViewMessage -uv -msg $msguv -fade -fit 00 -fst 200 -fot 800 -pos midLeft -fts 30 -bkc 0x000000;Rotate selection clockwise.
uvTkDoRotate(1, 0);
string $msguv = "UV Rotate CW";
inViewMessage -msg $msguv -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
inViewMessage -uv -msg $msguv -fade -fit 00 -fst 200 -fot 800 -pos midLeft -fts 30 -bkc 0x000000;Rotate selection counterclockwise.
uvTkDoRotate(0, 0);
string $msguv = "UV Rotate CCW";
inViewMessage -msg $msguv -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
inViewMessage -uv -msg $msguv -fade -fit 00 -fst 200 -fot 800 -pos midLeft -fts 30 -bkc 0x000000;Align UVs or UV Shells to the average U position.
performAlignUV avgU;
string $msguv = "UV Align Average <span style='color:#f00'>U</span>";
inViewMessage -msg $msguv -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
inViewMessage -uv -msg $msguv -fade -fit 00 -fst 200 -fot 800 -pos midLeft -fts 30 -bkc 0x000000;Ditto but average V.
performAlignUV avgV;
string $msguv = "UV Align Average <span style='color:#0f0'>V</span>";
inViewMessage -msg $msguv -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
inViewMessage -uv -msg $msguv -fade -fit 00 -fst 200 -fot 800 -pos midLeft -fts 30 -bkc 0x000000;Ditto but maximum U.
performAlignUV maxU;
string $msguv = "UV Align Max <span style='color:#f00'>U</span>";
inViewMessage -msg $msguv -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
inViewMessage -uv -msg $msguv -fade -fit 00 -fst 200 -fot 800 -pos midLeft -fts 30 -bkc 0x000000;Ditto but maximum V.
performAlignUV maxV;
string $msguv = "UV Align Max <span style='color:#0f0'>V</span>";
inViewMessage -msg $msguv -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
inViewMessage -uv -msg $msguv -fade -fit 00 -fst 200 -fot 800 -pos midLeft -fts 30 -bkc 0x000000;Ditto but minimum U.
performAlignUV minU;
string $msguv = "UV Align Min <span style='color:#f00'>U</span>";
inViewMessage -msg $msguv -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
inViewMessage -uv -msg $msguv -fade -fit 00 -fst 200 -fot 800 -pos midLeft -fts 30 -bkc 0x000000;Ditto but minimum V.
performAlignUV minV;
string $msguv = "UV Align Min <span style='color:#0f0'>V</span>";
inViewMessage -msg $msguv -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
inViewMessage -uv -msg $msguv -fade -fit 00 -fst 200 -fot 800 -pos midLeft -fts 30 -bkc 0x000000;Move UVs up 0.125(1/8 tile).
polyEditUV -u 0 -v 0.125 -r 1;
string $msguv = "UV Move Up";
inViewMessage -msg $msguv -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
inViewMessage -uv -msg $msguv -fade -fit 00 -fst 200 -fot 800 -pos midLeft -fts 30 -bkc 0x000000;Ditto but right.
polyEditUV -u 0.125 -v 0 -r 1;
string $msguv = "UV Move Right";
inViewMessage -msg $msguv -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
inViewMessage -uv -msg $msguv -fade -fit 00 -fst 200 -fot 800 -pos midLeft -fts 30 -bkc 0x000000;Ditto but down.
polyEditUV -u 0 -v -0.125 -r 1;
string $msguv = "UV Move Down";
inViewMessage -msg $msguv -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
inViewMessage -uv -msg $msguv -fade -fit 00 -fst 200 -fot 800 -pos midLeft -fts 30 -bkc 0x000000;Ditto but left.
polyEditUV -u -0.125 -v 0 -r 1;
string $msguv = "UV Move Left";
inViewMessage -msg $msguv -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
inViewMessage -uv -msg $msguv -fade -fit 00 -fst 200 -fot 800 -pos midLeft -fts 30 -bkc 0x000000;Get texel density of selected uvs.
uvTkDoGetTexelDensity;
string $msguv = "UV Get Texel Density";
inViewMessage -msg $msguv -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
inViewMessage -uv -msg $msguv -fade -fit 00 -fst 200 -fot 800 -pos midLeft -fts 30 -bkc 0x000000;Set texel density of selected uvs.
uvTkDoSetTexelDensity;
string $msguv = "UV Set Texel Density";
inViewMessage -msg $msguv -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
inViewMessage -uv -msg $msguv -fade -fit 00 -fst 200 -fot 800 -pos midLeft -fts 30 -bkc 0x000000;Perform a planar projection for the currently selected UVs on the X axis.
polyProjection -ch 1 -type Planar -ibd on -md x;
string $msguv = "UV Planar Project <span style='color:#f00'>X</span>";
inViewMessage -msg $msguv -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
inViewMessage -uv -msg $msguv -fade -fit 00 -fst 200 -fot 800 -pos midLeft -fts 30 -bkc 0x000000;Ditto but Y.
polyProjection -ch 1 -type Planar -ibd on -md y;
string $msguv = "UV Planar Project <span style='color:#0f0'>Y</span>";
inViewMessage -msg $msguv -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
inViewMessage -uv -msg $msguv -fade -fit 00 -fst 200 -fot 800 -pos midLeft -fts 30 -bkc 0x000000;Ditto but Z.
polyProjection -ch 1 -type Planar -ibd on -md z;
string $msguv = "UV Planar Project <span style='color:#00f'>Z</span>";
inViewMessage -msg $msguv -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
inViewMessage -uv -msg $msguv -fade -fit 00 -fst 200 -fot 800 -pos midLeft -fts 30 -bkc 0x000000;Performs automatic UV projection, but disables transform constraint afterwards, because for some reason sometimes vanilla automatic projection leaves me with an unwanted enabled transform constraint.
performPolyAutoProj 0;
texTranConstSet "none";Cycle UVs for selected faces.
polyRotateUVsByVertex;
string $msguv = "UV Cycle";
inViewMessage -msg $msguv -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
inViewMessage -uv -msg $msguv -fade -fit 00 -fst 200 -fot 800 -pos midLeft -fts 30 -bkc 0x000000;Stack selected UVs.
uvTkDoStackShells;
string $msguv = "UV Stack";
inViewMessage -msg $msguv -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
inViewMessage -uv -msg $msguv -fade -fit 00 -fst 200 -fot 800 -pos midLeft -fts 30 -bkc 0x000000;Ditto but orient as well.
uvTkDoStackAndOrient;
string $msguv = "UV Stack & Orient";
inViewMessage -msg $msguv -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
inViewMessage -uv -msg $msguv -fade -fit 00 -fst 200 -fot 800 -pos midLeft -fts 30 -bkc 0x000000;Straighten selected UVs up to 5°.
string $msguv = "UV Straighten";
inViewMessage -msg $msguv -fade -fit 00 -fst 200 -fot 800 -pos midCenterTop -fts 30 -bkc 0x000000;
inViewMessage -uv -msg $msguv -fade -fit 00 -fst 200 -fot 800 -pos midLeft -fts 30 -bkc 0x000000;
uvTkDoStraightenUVs;Stitch together UV edges - smallest to largest.
texMultiStitch 0;Stitch together UV edges - largest to smallest.
texMultiStitch 1;Reset position, rotation, clip planes of default cameras and hide them, load up four pane viewport layout preset, and frame scene in all views. Input window popup for "multiplier" - for regularly sized objects the default of 1 should be fine, for small scenes try 0.1, for large scenes try 2 or 3. Working units should be in meters. Also disables texture resolution clamping.
proc resetCams(float $mult) {
setNamedPanelLayout "Four View"; updateToolbox();
select -r persp;
FreezeTransformations;
setAttr "perspShape.nearClipPlane" $mult;
setAttr "perspShape.farClipPlane" ($mult*1000);
select -r side;
FreezeTransformations;
setAttr "side.translateX" ($mult*200);
setAttr "side.translateY" 0;
setAttr "side.translateZ" 0;
setAttr "side.rotateX" 0;
setAttr "side.rotateY" 90;
setAttr "side.rotateZ" 0;
setAttr "sideShape.nearClipPlane" $mult;
setAttr "sideShape.farClipPlane" ($mult*1000);
select -r top;
FreezeTransformations;
setAttr "top.translateX" 0;
setAttr "top.translateY" ($mult*200);
setAttr "top.translateZ" 0;
setAttr "top.rotateX" -90;
setAttr "top.rotateY" 0;
setAttr "top.rotateZ" 0;
setAttr "topShape.nearClipPlane" $mult;
setAttr "topShape.farClipPlane" ($mult*1000);
select -r front;
FreezeTransformations;
setAttr "front.translateX" 0;
setAttr "front.translateY" 0;
setAttr "front.translateZ" ($mult*200);
setAttr "front.rotateX" 0;
setAttr "front.rotateY" 0;
setAttr "front.rotateZ" 0;
setAttr "frontShape.nearClipPlane" $mult;
setAttr "frontShape.farClipPlane" ($mult*1000);
select -cl;
FrameAllInAllViews;
HideCameras;
setAttr "hardwareRenderingGlobals.textureMaxResMode" 1;
setAttr "hardwareRenderingGlobals.textureMaxResolution" 8192;
setAttr "hardwareRenderingGlobals.enableTextureMaxRes" 0;
AEReloadAllTextures;
generateAllUvTilePreviews;
}
proc dial() {
string $result = `promptDialog -title "Reset Cams" -m "Multiplier" -text "1"
-button "OK" -button "Cancel"
-defaultButton "OK" -cancelButton "Cancel"
-dismissString "Cancel"`;
if($result == "OK") {
$mult = float(`promptDialog -query -text`);
resetCams($mult);
string $message = "Reset Cams x" + string($mult);
inViewMessage -msg $message -fade -fit 00 -fst 1000 -fot 1000 -pos midCenterTop -fts 30 -bkc 0x000000;
}
}
dial();Resets grid to (100 x multiplier) for size, grid lines every 10 units, 10 subdivisions. Input window popup for multiplier. Also sets scene working units to meters.
proc resetGrid(float $mult) {
currentUnit -linear "m";
grid -r;
grid -s ($mult*100) -sp 10 -d 10 -da true -dgl true -ddl true;
}
proc dial() {
string $result = `promptDialog -title "Reset Grid" -m "Size" -text "1"
-button "OK" -button "Cancel"
-defaultButton "OK" -cancelButton "Cancel"
-dismissString "Cancel"`;
if($result == "OK") {
$mult = float(`promptDialog -query -text`);
resetGrid($mult);
string $message = "Reset Grid " + string($mult);
inViewMessage -msg $message -fade -fit 00 -fst 1000 -fot 1000 -pos midCenterTop -fts 30 -bkc 0x000000;
}
}
dial();Save scene, ignoring any custom exporter overrides, must be reassigned every time after launching maya or sometimes after opening a new scene.
inViewMessage -smg "SAVE" -fade -pos topCenter;
SaveScene;Measures and shows bounding box dimensions of the current selection, but if exactly 1 edge is selected shows edge length. Updated to show run(on-ground distance), slope in percentage, ground relative angle in degrees, or distance for 2 vertices.
{
$bb = `exactWorldBoundingBox`;
if(`selectType -q -eg` && size(`filterExpand -sm 32`) == 1) {
$len = `mag <<float($bb[0] - $bb[3]), float($bb[1] - $bb[4]), float($bb[2] - $bb[5])>>`;
$run = `mag <<float($bb[0] - $bb[3]), 0, float($bb[2] - $bb[5])>>`;
$rise = abs(float($bb[1] - $bb[4]));
$slope = $rise / $run;
$angle = atan($slope) * 57.295779513;
inViewMessage -msg (
"edge length: " + string($len) +
"\nrun: " + string($run) +
"\nslope: " + ($slope*100) + "%" +
"\nangle: " + $angle + "°" +
"\n\nbounding box size:\n" + string(abs(float($bb[0]-$bb[3]))) + "\n" + string(abs(float($bb[1]-$bb[4]))) + "\n" + string(abs(float($bb[2]-$bb[5])))
) -fade -fit 00 -fst 600 -fot 1200 -pos midCenterTop -fts 30 -bkc 0x000000;
}
else if(`selectType -q -v` && size(`filterExpand -sm 31`) == 2) {
$len = `mag <<float($bb[0] - $bb[3]), float($bb[1] - $bb[4]), float($bb[2] - $bb[5])>>`;
$run = `mag <<float($bb[0] - $bb[3]), 0, float($bb[2] - $bb[5])>>`;
$rise = abs(float($bb[1] - $bb[4]));
$slope = $rise / $run;
$angle = atan($slope) * 57.295779513;
inViewMessage -msg (
"distance: " + string($len) +
"\nrun: " + string($run) +
"\nslope: " + ($slope*100) + "%" +
"\nangle: " + $angle + "°" +
"\n\nbounding box size:\n" + string(abs(float($bb[0]-$bb[3]))) + "\n" + string(abs(float($bb[1]-$bb[4]))) + "\n" + string(abs(float($bb[2]-$bb[5])))
) -fade -fit 00 -fst 600 -fot 1200 -pos midCenterTop -fts 30 -bkc 0x000000;
}
else {
inViewMessage -msg ("bounding box size:\n" + string(abs(float($bb[0]-$bb[3]))) + "\n" + string(abs(float($bb[1]-$bb[4]))) + "\n" + string(abs(float($bb[2]-$bb[5]))) ) -fade -fit 00 -fst 600 -fot 1400 -pos midCenterTop -fts 30 -bkc 0x000000;
}
}Samples a texture and applies it to the vertex colors. Comments in the script explain which variables can be modified.
{
SelectUVMask;
dR_selectAll;
string $verts1[] = `filterExpand -sm 35`;
int $count2 = `size($verts1)`;
for($i=0; $i < $count2; $i++) {
select $verts1[$i];
float $cuvs[] = `polyEditUV -query -u`;
float $sr = 0.005; // sampling rect uv size
int $sam = 3; // this by this grid of samples
string $texname = "baketest1_D_1"; //texture name
float $cols[] = `colorAtPoint -mu $cuvs[0] -mv ($cuvs[1]-$sr) -xu ($cuvs[0]+$sr) -xv ($cuvs[1]+$sr) -su 3 -sv 3 -o RGB $texname`;
for($j=1; $j < $sam; $j++) {
$cols[0] = $cols[0] + $cols[3*$j];
$cols[1] = $cols[1] + $cols[3*$j+1];
$cols[2] = $cols[2] + $cols[3*$j+2];
}
$cols[0] = `pow $cols[0] 2.2`;
$cols[1] = `pow $cols[1] 2.2`;
$cols[2] = `pow $cols[2] 2.2`;
ConvertSelectionToVertexFaces;
polyColorPerVertex -rgb $cols[0] $cols[1] $cols[2];
}
select -cl;
changeSelectMode -object;
}When I make any updates, I'll list them here.
- BreakComponentsOrShells - now splits UVs if in edge mode and hovering UV editor.
- Added inViewMessage to almost all UV related scripts.
- QuickCreatePlane - fixed window title saying "cylinder" instead of "plane".
- BreakComponentsOrShells - fixed issue where splitting UVs resulted in also creating UV shells.
- DetachFaces - now works even when in UV shell selection mode.
- Added HardUVBorders - i almost never use it but could be useful for high to low texture baker people.
- IsolateSelectedAllViews - now it hides all sets in the outliner and has inViewMessages.
- UnhideAll - added inViewMessage.
- Added PivotCenterBottom
- Added FreezeCenterBottomClear
- Added TriangulateFaces and QuadrangulateFaces - same as regular triangulate and quadrangulate but should work properly across multiple objects.
- Added MeasureEdgeOrBB - measures and shows bounding box dimensions of the current selection, but if exactly 1 edge is selected shows edge length.
- Updated BridgeEdges to BridgeEdgesOrFaces - now it supports bridging both edges or faces across multiple objects.
- Added CornerAngle - similar to Corner45A/Corner45B but has an input box for a custom angle.
- Added BendNormalPosX, BendNormalPosY, BendNormalPosZ, BendNormalNegX, BendNormalNegY, BendNormalNegZ - bends normals of selected vertices in a particular axis direction.
- Added SetBoundingBox - scales the current component selection so the bounding box matches the input values. Inputting 0 skips scaling that axis.
- Updated CombineObjects - now it preserves the pivot of the first object, as well as reattaches the resulting shape to any found instances of the first object, preserving instances.
- Updated CombineObjects - almost entirely rewritten to be more reliable and not such a mess.
- Updated SetBoundingBox - a fix, also now scales from the current pivot position, but forces world pivot since bounding boxes are world oriented.
- Added PushVertices - transforms currently selected vertices in their normal direction (local translate z) by the input amount. Works across multiple objects.
- Added UV_Automatic - performs automatic UV projection, but disables transform constraint afterwards, because for some reason sometimes vanilla automatic projection leaves me with an unwanted enabled transform constraint.
- Updated SetBoundingBox - fix, hopefully it scales based on custom pivot properly now.
- Added Straighten - rotates the current component selection so that the custom pivot is aligned with the world ground plane.
- Updated SetBoundingBox - yet another attempt at fixing it.
- Updated UV_Straighten to straighten based on the degrees set in the uv toolkit ui, instead of the hardcoded 5.
- Updated all Align, Distribute, Stack scripts to preserve the original pivot when performing them on a single object.
- Added SetBackgroundColor.
- Fixed PivotCenterBottom to work with multiple objects selected.
- Added UV_StitchTogetherAB and UV_StitchTogetherBA.
- Changed CollapseEdges to CollapseOrSewEdges - now it sews edges if uv editor is in focus.
- Updated DuplicateObjectsOrFaces - now warns if no objects are selected.
- Added MergeAllVerts - merges all vertices of selected objects.
- Updated ResetCams - puts cameras a bit further from center than before.
- Added BakeTexVertexColors - samples a texture and applies it to the vertex colors.
- Updated FreezeCenterBottomClear - now works with multiple objects.
- Updated ResetCams - now also disables texture resolution clamping.
- Updated ResetGrid - now also sets scene working units to meters.
- Added FlattenNormalX, FlattenNormalY, FlattenNormalZ - averages and flattens normals on X axis. Split hard edges beforehand to preserve them.
- Added PivotReset - resets pivot for the object, as in going into the move tool settings and resetting pivot there. Not to be confused with resetting custom pivot.
- Updated CombineObjects to correctly combine objects if multiple of them have instances by deinstancing all selected objects except the first.
- Updated WireframeOnShaded and FlatLight to work properly on the currently focused viewport instead of a specific one.
- Added CustomSelectPress and CustomSelectRelease as a workaround for new maya versions not hiding gizmo when tab selecting.
- Added CustomFrame - a more reliable way to frame the selection.
- Added TransferNormals - transfers normals from one mesh to another.
- Updated MeasureEdgeOrBB - now it can measure distance between 2 vertices, slope percentange, angle degrees for edges or 2 verts as well.