Last active
June 7, 2018 03:39
-
-
Save deathponta/a1c50cc3f87e7edc8e592d811809f38d to your computer and use it in GitHub Desktop.
1番目に選択したオブジェクトの位置・回転を2番めに選択したオブジェクトに合わせる
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
最後に選択したオブジェクトに位置・回転合わせを行う | |
複数オブジェクト対応 | |
*/ | |
proc ObjectAligner(){ | |
ObjectAligner_GUI(); | |
} | |
// 位置合わせ | |
proc ObjectAligner_Trans(){ | |
$sels = `ls -sl -type transform`; | |
int $lastIdx = `size($sels)` - 1; | |
// 最後に選択したオブジェクトの絶対位置取得 | |
$pos = `xform -q -ws -t $sels[$lastIdx]`; | |
// 最後に選択したオブジェクト以外を移動 | |
for( $i=0;$i<$lastIdx;$i++ ){ | |
xform -ws -t $pos[0] $pos[1] $pos[2] $sels[$i]; | |
} | |
} | |
// 回転合わせ | |
proc ObjectAligner_Rot(){ | |
$sels = `ls -sl -type transform`; | |
int $lastIdx = `size($sels)` - 1; | |
$rot = `xform -q -ws -ro $sels[$lastIdx]`; | |
for( $i=0;$i<$lastIdx;$i++ ){ | |
xform -ws -ro $rot[0] $rot[1] $rot[2] $sels[$i]; | |
} | |
} | |
proc ObjectAligner_GUI(){ | |
string $window = "oa_win"; | |
if(`window -exists $window`){ | |
deleteUI $window; | |
} | |
window -title "ObjectAligner" -width 100 -toolbox true $window; | |
columnLayout -columnAttach "both" 5 -rowSpacing 10 -columnWidth 100; | |
button -l "位置合わせ" -command "ObjectAligner_Trans()"; | |
button -l "回転合わせ" -command "ObjectAligner_Rot()"; | |
showWindow $window; | |
} | |
ObjectAligner_GUI(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment