Pass object as argument to global proc in MEL

65 Views Asked by At

Is it possible to pass an object (mesh / transform), located in the scene, as an argument to a global proc in Maya's expression editor (MEL)?

For example:

global proc int foo( ??? $object_ ) // what's the type of the parameter?
{
    float $vtx[] = `pointPosition -w object_.vtx[0]`;
    ...
}

foo( pCube1 );

The only way I can think of right now is pass the name of the object as a string and then use if-else statements or a switch statement to determine the object within the body of the function. For example:

global proc int foo( string $object_name_ )
{
   if ($object_name_ == "pCube1")
   {
       float $vtx[] = `pointPosition -w pCube1.vtx[0]`;
       ...
   }
   else if ($object_name_ == "pCube2")
   {
       float $vtx[] = `pointPosition -w pCube2.vtx[0]`;
       ...
   }
   else
   {
      ...
   }
}
    
foo( "pCube1" );
1

There are 1 best solutions below

1
On

Unfortunately mel only uses strings, not objects. Even if the expression language look as if you could do it, it does not use objects and only uses the direct object for creating connections inside an expression.