Basic MEL script not working

Basic MEL script not working

Anonymous
Not applicable
2,619 Views
3 Replies
Message 1 of 4

Basic MEL script not working

Anonymous
Not applicable

Hi everyone,

 

after copying (manually) a MEL script I've tried to run it (it should create a joint at the center of the selected vertices), but each time I receive this error:

 

//---------------------------------------------------------------------------------------

select -cl ;
select -r pSphere1.vtx[0:381] ;
////Create a Joint at the center of selected vertices

// Convert selection to vertices:
ConvertSelectionToVertices;hilite; selectType -ocm -alc false;selectType -ocm -polymeshVertex true;

// Find selection of components:
string $selVert[] = `ls -sl -fl`;

// Create a cluster
string $cl[] = `newCluster " -relative -envelope l"`;

// Create a world joint
select -cl;
string $jnt = `joint`;

// Point constraint the point to the cluster
string $ptCnsJnt[] = `pointConstraint $cl $jnt`;

// Find the point constraint:
string $findPtCns[] = `listRelatives -type pointConstraint $jnt`;

// Select and delete the point constrain and cluster:
select $findPtCns[0] $cl[0]; doDelete;

// Select the joint:
select -cl; select $jnt;
select -d pSphere1.vtx[0:381] ;
select -add pSphere1.vtx[0:381] ;
// Error: line 0: Error while parsing arguments. //

 

//---------------------------------------------------------------------------------------

 

This is the script:

 

//---------------------------------------------------------------------------------------

////Create a Joint at the center of selected vertices

 

// Convert selection to vertices:

ConvertSelectionToVertices;hilite; selectType -ocm -alc false;selectType -ocm -polymeshVertex true;

 

// Find selection of components:

string $selVert[] = `ls -sl -fl`;

 

// Create a cluster

string $cl[] = `newCluster " -relative -envelope l"`;

 

// Create a world joint

select -cl;

string $jnt = `joint`;

 

// Point constraint the point to the cluster

string $ptCnsJnt[] = `pointConstraint $cl $jnt`;

 

// Find the point constraint:

string $findPtCns[] = `listRelatives -type pointConstraint $jnt`;

 

// Select and delete the point constrain and cluster:

select $findPtCns[0] $cl[0]; doDelete;

 

// Select the joint:

select -cl; select $jnt;

//---------------------------------------------------------------------------------------

 

I can't really understand what's wrong with this, can anyone help me?

 

Thanks

 

Maya 2018, Mac Edition, latest update, MacBook PRO (mid 2015), OS Sierra

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

Roland.Reyer
Alumni
Alumni
Accepted solution

Hi,

 

yes, I see the problem:

When you create a cluster from the menu it echoes: newCluster "-envelope ..."

 

This newCluster is a procedure defined in a file (find the file with "whatIs newCluster").

I don't know why the developer took this detour.

 

Change the creation of the cluster to:

// Create a cluster
string $cl[] = `cluster  -relative -envelope 1`;

and it works fine.

 

BTW:

In the conversion of the selection to verticies the first command in the line should do it:

ConvertSelectionToVertices;

 

 

Message 3 of 4

Anonymous
Not applicable

I see.

 

Well thanks a lot for the quick answer, I'll try your solution as soon as possible and Ill let you know.

 

Thanks a lot for your time

0 Likes
Message 4 of 4

Anonymous
Not applicable
Accepted solution

Well I'm honestly really stupid.

It was a 1 not an l at the end of the code. Now even with the original version it works perfectly.

 

Sorry and thanks again

0 Likes