how to use mel command "pointOnPolyConstraint"?

how to use mel command "pointOnPolyConstraint"?

g2m.agent
Collaborator Collaborator
1,455 Views
3 Replies
Message 1 of 4

how to use mel command "pointOnPolyConstraint"?

g2m.agent
Collaborator
Collaborator

i have a scene:

2017-06-16_035721.png

 

i want "joint3" constraint to the "pCube1.vtx[5]", like this:

2017-06-16_035914.png

 

but when i use mel:

pointOnPolyConstraint pCube1.vtx[5] joint3;

i get this:

2017-06-16_040208.png

 

why??

0 Likes
Accepted solutions (1)
1,456 Views
3 Replies
Replies (3)
Message 2 of 4

mspeer
Consultant
Consultant

Hi!

 

This command does not use components as input, only objects, maybe this function is broken or should be updated.

 

0 Likes
Message 3 of 4

g2m.agent
Collaborator
Collaborator

but if i select that vertex first, then select joint3, then "Constrain -> Point On Poly", i get good result:

 

2017-06-16_054638.png

 

maya outputs this code:

 

select -r pCube1.vtx[5] ;
select -tgl joint3 ;

doCreatePointOnPolyConstraintArgList 2 {   "0" ,"0" ,"0" ,"1" ,"" ,"1" ,"0" ,"0" ,"0" ,"0" };
{string $constraint[]=`pointOnPolyConstraint -offset 0 0 0  -weight 1`; 
setAttr ($constraint[0]+".pCube1U0") 0.625000; 
setAttr ($constraint[0]+".pCube1V0") 0.500000;};

 

 

i can't find "doCreatePointOnPolyConstraintArgList" in the manual.

0 Likes
Message 4 of 4

g2m.agent
Collaborator
Collaborator
Accepted solution

Finally able to work properly!
should be ……

 

This is my final script:

proc test(){
string $sel[]=`ls -sl`; // 返回选择物体的列表,如 pPlane1, pCube1 ...
float $selPos[3] = `xform -ws -q -t $sel`;//在物体轴心建根骨骼。
joint -p $selPos[0] $selPos[1] $selPos[2] -rad 10 -n "joint_root";
//polyEvaluate -face $sel[0]; //返回多边形的面数。
int $v[] = `polyEvaluate -vertex $sel[0]`; //返回多边形的顶点数。
print("vertex numbers: " + $v[0] + "\n\n");
for($i=0; $i<$v[0]; $i++){
    float $pos[3] = `pointPosition -world ($sel[0] + ".vtx[" + $i + "]")`;
    string $jName = `joint -p $pos[0] $pos[1] $pos[2] -rad 5 "joint_root"`; // 在顶点处新建 joint,并返回新joint的名字。
	print($sel[0] + ".vtx[" + $i + "]: "+ $pos[0] + " " + $pos[1] + " " + $pos[2] + "\n");
	
	// 获取顶点处 UV 的坐标
	//select -r pCube1.map[2];// 选择 pCube1.vtx[2] 处的 UV 点。
	select -r ($sel[0] + ".map[" + $i + "]");
	float $uv[2] = `polyEditUV -query`;// Result: 0.375 0.25 // 
	print($sel[0] + ".map[" + $i + "] UV="+$uv[0]+" "+$uv[1]+"\n");

	// 把每个 joint 约束到对应的顶点
	//select -r ($sel[0] + ".vtx[" + $i + "]");//直接选择顶点会让下面的 setAttr 指向 pCubeShape1 节点,导致找不到约束对象而报错:
	// Error: line 0: setAttr: No object matches name: joint1_pointOnPolyConstraint1.pCubeShape1U0 // 
	select -r $sel[0];
	select -tgl $jName;

	doCreatePointOnPolyConstraintArgList 2 {   "0" ,"0" ,"0" ,"1" ,"" ,"1" ,"0" ,"0" ,"0" ,"0" }; // 不知何意,手册中也查不到。
	{string $constraint[]=`pointOnPolyConstraint -offset 0 0 0  -weight 1`; 
	setAttr ($constraint[0]+"."+$sel[0]+"U0") $uv[0];
	setAttr ($constraint[0]+"."+$sel[0]+"V0") $uv[1];};

}

}
test();