PDA

View Full Version : Storing an object


GrogMcGee
05-29-2009, 02:54 PM
[EDIT: Solved... sort of]

This seems like it should be really obvious - I'm still incredibly new to mel scripting; but how do I store the selected object for later use?

eg, I want to duplicate an object and the combine the duplicate and the original ... I'm completely failing to see how I do that.

----

Okay so I've solved my problem for the time being I'm still curious about it all though so:

this script works:
{
string $original[]=`ls -sl`;
duplicate $original;
string $new[]=`ls -sl`;
perfromPolyNormal 0 -1 0;
polyUnite -object 1 $original $new;
};

this didn't
{
string $original[]=`ls -sl`;
string $new[];
duplicate $original;
$new[]=`ls -sl`;
perfromPolyNormal 0 -1 0;
polyUnite -object 1 $original $new;
};

I think it's stupidly obvious and I'm just being dumb... but a little guidance can go a long way.

Also, is that the correct way to store and object?

djtomservo
05-29-2009, 05:21 PM
minor syntax errors:


{
string $original[]=`ls -sl`;
string $new[];
duplicate $original;

//this line should just be $new= `ls -sl`; no brackets
$new[]=`ls -sl`;

//sp?
perfromPolyNormal 0 -1 0;
polyUnite -object 1 $original $new;
};

GrogMcGee
05-29-2009, 06:12 PM
thanks,

why does the $new not need the brackets, it it because I only need the brackets when declaring?

that was the line the was causing a syntax error - the spelling mistake was a typo.

djtomservo
05-29-2009, 06:27 PM
why does the $new not need the brackets, it it because I only need the brackets when declaring?

Correct! since maya already knows $new is an array type because of the declaration, you don't need the brackets unless doing a specific assignment.

GrogMcGee
05-29-2009, 06:46 PM
Thanks

So when i need to store an object I do use the strings, right?

Also is this legal?
string $object[] = `ls -sl`;
some_command $object.scalePivot

the underlined is what I'm curious about...

djtomservo
05-29-2009, 06:56 PM
So when i need to store an object I do use the strings, right?


in MEL, yep:(



Also is this legal?
string $object[] = `ls -sl`;
some_command $object.scalePivot


sadly not in MEL, you're looking at something like:


//for a single object
some_command ($object[0]+".scalePivot");
//or
select $object[0];
some_command .scalePivot

//for multiple objects, this may not work depending on the command
select $object; //or select `ls -sl`;
some_command .scalePivot;


There's always Python though...

CGTalk Moderation
05-29-2009, 06:56 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.