//[MEL] 選択されているオブジェクトの親を選択する
{
string $sels[] = `ls -sl`;
string $parents[];
select -cl;
for( $s in $sels ){
$parent = `listRelatives -p $s`;
select -add $parent[0];
}
}
2007年04月04日
選択されているオブジェクトの親を選択する
UV列挙サンプル
//[MEL] UV列挙サンプル
proc getTexturingCoords( string $mesh )
{
// get number of uvs on the mesh
int $uvCount[] = `polyEvaluate -uv $mesh`;// write the number of UV coords
print( "numTexCoords=" + $uvCount[0] + "\n" );// add each uv coord to the string also
for( $i=0;$i<$uvCount[0];$i++)
{
// get the uv coord
float $uvs[] = `getAttr ($mesh + ".uv[" +$i+"]")`;// print it's value
print( $uvs[0] + " " + $uvs[1] + "\n" );
if( 1.0 < $uvs[0] || 0.0 > $uvs[0] || 1.0 < $uvs[1] || 0.0 > $uvs[1] ){
select -r ($mesh + ".map[" + $i + "]");
}
}
}
string $tmp[] = `ls -sl`;
select -clear;
getTexturingCoords($tmp[0]);
メッシュ頂点の位置を列挙するサンプル
// [MEL] メッシュ頂点の位置を列挙するサンプル
{
string $selected[] = `ls -sl`;
string $obj = $selected[0];float $pos[];
int $nVerts[] = `polyEvaluate -v $obj`;
int $nVert = $nVerts[0];
int $i, $j;for( $i=0; $i<$nVert; $i++){
$pos = `pointPosition -local ($obj + ".vtx[" + $i + "]")`;
print ("< " + $pos[0] + ", " + $pos[1] + ", " + $pos[2] + " >\n");
}
int $nFaces[] = `polyEvaluate -f $obj`;
int $nFace = $nFaces[0];
string $face[];
string $buf[];for( $i=0; $i<$nFace; $i++){
$face = `polyInfo -fv ($obj + ".f[" + $i + "]")`;
$face[0] = `substitute "\n$" $face[0] ""`;
tokenize $face[0] " " $buf;
for( $j=2; $j<size($buf); $j++){
print ($buf[$j] + " ");
}
print "\n";
}
}