tryPrintCurveEP.mel

こんな感じでカーブオブジェクトを作成したら、選択状態でコマンドラインへ
tryPrintCurveEP 桁数
で実行。



{
string $sel[]=`ls -sl -typ "transform"`;
for( $e in $sel )
{
string $attrs[]=`listAttr -k -se -w $e`;
for( $attr in $attrs )
{
string $NA=($e+"."+$attr);
float $v=ROUND(`getAttr $NA`,2);
setAttr $NA $v;
}
}
}

{
string $p[]=listRelatives -p $current`;
print("\n"+$p[0]+"\n");
}
listRelativesは文字配列を返すため、いったん配列に代入しないといけないのは頂けません。
{
string $p = firstParentOf( $current );
print("\n"+$p+"\n");
}
文字列で返ってくるのは中々良いのですが、オブジェクト名がロングネームでしか返ってこないので注意。
{
string $tmp[]= stringToStringArray( $long,"|" );
string $short=$tmp[size($tmp)-1];
print("\n"+$short+"\n");
}
こんな感じで配列の最後に入った値を取得するみたいな、なかなかの面倒くささ。
{
string $short = shortNameOf( $long );
print("\n"+$short+"\n");
}
ただし、ネームスペースは分離できないようなので、
{
string $shape[]=`listRelatives -c -pa -ni -s $target`;
string $type=`nodeType $shape[0]`;
print("\n"+$type+"\n");
}
{
string $lines[];
$lines[0]="nodeName\ttranslateX\ttranslateY\ttranslateZ\tvisibility";
string $lcts[]={"locator1","locator2","locator3","locator4"};
for( $lct in $lcts )
{
float $tr[]=`getAttr ($lct+".t")`;
string $vis=(`getAttr ($lct+".v")`) ? "on": "off";
$lines[size($lines)]=($lct+"\t"+$tr[0]+"\t"+$tr[1]+"\t"+$tr[2]+"\t"+$vis);
}
print $lines;
}
print("\n-- new lines --\n");
string $newLines[]=stringArrayTranspose( $lines,"\t");
print $newLines;
proc string _createLabelFrame(
int $w , // 幅px
string $align, // 位置合わせ"left","right","center"
string $label ) // ラベル文字
{
string $frame=`frameLayout -lv 0 -bv 1 -w $w -mw 6`;
text -l $label -al $align;
setParent ..;
return $frame;
}
global proc labelTest()
{
string $win="testWindow";
if(`window -q -ex $win`) deleteUI $win;
window $win;
rowLayout -nc 4;
_createLabelFrame( 46,"center","項目A" );
_createLabelFrame( 96,"center","けっこう長い項目B" );
_createLabelFrame( 96,"left","項目C" );
_createLabelFrame( 96,"right","項目D" );
window -e -w 342 -h 32 $win;
showWindow $win;
}







pythonコマンドを使用することで簡単に処理する事ができます。
mayaLTでPythonを実行する















proc _hogehoge0(
string $CBR[],
string $outList[],
string $list[] )
/**************************************************************************//**
@protected
@brief test procedure.
@param[in,out] $CBR 説明※参照渡し
@param[out] $outList 説明※参照渡し、初期化あり
@param[in] $list リスト
******************************************************************************/
{

proc _hogehoge1(
string $CBR[], //!< [in,out] 説明※参照渡し
string $outList[], //!< [out] 説明※参照渡し、初期化あり
string $list[] ) //!< [in] リスト
/**************************************************************************//**
@protected
@brief test procedure.
******************************************************************************/
{

proc _hogehoge2(
string $test, //!< test comment.
string $CBR[],
string $outList[],
string $list[] )
/**************************************************************************//**
@protected
@brief test procedure.
@param[in,out] $CBR 説明※参照渡し
@param[out] $outList 説明※参照渡し、初期化あり
@param[in] $list リスト
******************************************************************************/
{





global proc assert()
{
warning "warning:hogehoge";
error "error:hogehoge";
print "hogehoge";
}

global proc assert2()
{
int $buf=`commandEcho -q -ln`;
commandEcho -ln off;
warning "warning:hogehoge";
catch(`error "error:hogehoge"`);
commandEcho -ln $buf;
print "hogehoge";
}

global proc assert3()
{
warning -noContext "warning:hogehoge";
error -noContext "error:hogehoge";
print "hogehoge";
}

global proc trySetRotateOrder(
string $node, // ノード名
string $order ) // 回転順序
{
if(!`attributeExists "ro" $node`) return;
$order=tolower( $order );
int $ro;
switch( $order )
{
case "xyz": $ro=0; break;
case "yzx": $ro=1; break;
case "zxy": $ro=2; break;
case "xzy": $ro=3; break;
case "yxz": $ro=4; break;
case "zyx": $ro=5; break;
default: $ro=-1; break;
}
if( $ro<0 ) return;
evalEcho("setAttr "+$node+".rotateOrder "+$ro);
}
proc string _round(
int $digit, //!< 区切る桁数
string $mode, //!< 出力モード
float $value ) //!< 区切る値
/**************************************************************************//**
@private
@brief 指定の桁数で四捨五入する。
@return 四捨五入 [string型] を返す。
******************************************************************************/
{
float $mlt=pow( 10, $digit );

global proc tryRecoverSceneConfiguration()
{
string $scNode[]=`ls -typ "script" "*sceneConfigurationScriptNode*"`;
if( 1==`size $scNode` )
{
string $cmd=`scriptNode -q -bs $scNode[0]`;
if(""!=$cmd) evalEcho( $cmd );
}
}



@echo off title %~n0 %1 set TPROC="C:\Program Files\TortoiseSVN\bin\TortoiseProc.exe" :: ファイルをD&Dした場合 set PATH_LIST=%1 set COMMAND=%~x1 set COMMAND=%COMMAND:.=% :: ファイルのD&Dが無かった場合 if ""=="%PATH_LIST%" set PATH_LIST=%~dpn0.update & set COMMAND=update if not exist %PATH_LIST% echo "%PATH_LIST%" is Not Found. & pause & goto :EOF :: 更新実行 for /f %%a in (%PATH_LIST%) do echo %COMMAND%: & echo "%%a" & %TPROC% /command:%COMMAND% /path:"%%a"

D:\myProjects\maya\scripts*D:\myProjects\batch
