在MEL中,如何仅在一个方向上转换对象?

问题描述 投票:0回答:2

我想编写一个脚本,它将采用多个对象,将各自的枢轴居中,然后将y中的枢轴转换为0。

以下是我目前尝试的两种变体:

string $sel[] = `ls -sl -typ transform`;
string $obj;

for ($obj in $sel) {
    CenterPivot
    setAttr ($obj + ".scalePivot") -ty 0;
    setAttr ($obj + ".rotatePivot") -ty 0;
}

string $sel[] = `ls -sl -typ transform`;
string $obj;

for ($obj in $sel) {
    xform -cp;
    xform -piv 0 -0.098814 0;
}

在第二个脚本中,平移y移动到零(从其起始位置开始-0.098814)但是z和x远离源对象的中心。

3d maya mel
2个回答
0
投票
string $sel[] = `ls -sl -typ transform`;
string $obj;
for ($obj in $sel)
{
    xform -ws -cp;
    xform -ws -piv 0 -0.098814 0;
}

添加世界空间将解决我的问题。


0
投票

如果我理解正确的话:

for( $i in `ls -sl`){
    select $i; 
    xform -ws -cp;
    $p = `xform -q -piv -ws`;
    xform -ws -piv $p[0] 0 $p[2];}
© www.soinside.com 2019 - 2024. All rights reserved.